vendredi 15 janvier 2021

Ember - best way to include large data stubs

I have a folder in an Ember addon containing some very large JSON payloads, which I use to stub responses in my tests. Each response is exported from a .js file using ES6 imports, because this makes it easy to import the stubs into my tests.

The problem is that these files are massively slowing down my builds, as Babel is parsing them.

I can't find a way to use the Babel ignore option with ember-cli-babel. If this is possible, having Babel ignore that directory would be first prize.

One other idea I have is to place all of the JSON in a string property as below, and then parsing it when I import the file.

stubs/payload.js

export default {jsonString: `...Large JSON payload here`}

testfile.js

import payload from 'stubs/payload.js'
...
var response = JSON.parse(payload.jsonString);
...

I'm not entirely sure if that will really help. Has anyone found a more sane solution to this?




Aucun commentaire:

Enregistrer un commentaire