Babel ignore equivalent in ember engines?

379 Views Asked by At

In a traditional Ember app, I have something along the lines of this in my ember-cli-build.js:

//ember-cli-build.js
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
    babel: {
        includePolyfill: true,
        ignore: ['my-ember-ui/models/myFile.js'] // <-- question is here
    },

Is there an equivalent to this when using an Ember Engine (or addon)? I couldn't find anything within ember-cli-babel or ember-engines.

I understand that ember-cli-build.js is just for the dummy app when using an engine, so I wouldn't make the change there. I attempted similar to above in the index.js file, but did not have any luck. The file was not ignored by babel. I need a way to ignore a particular file. Thanks!

1

There are 1 best solutions below

0
On

Well, adding new rules to Cli.build.js is ok depends on what you want to do. However, I may have another solution that you can give it a try.

Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel up the directory tree until it finds either a .babelrc, or a package.json with a "babel": {} hash within.(.babelrc files are serializable JSON).

{
  "plugins": ["transform-react-jsx"],
  "ignore": [
    "foo.js",
    "bar/**/*.js"
  ]
}

or

{
  "name": "my-package",
  "version": "1.0.0",
  "babel": {
    // my babel config here
  }
}

There should be another way which seems ok to use. the following does work:

babel src --out-dir build --ignore "**/*.test.js"  // or simply add your file

For more information, you can read Babel document