Reputation: 5869
I'm using Gulp and Babel to compile client-side es6 code to es5. After upgrade I got this error (in the browser):
Uncaught ReferenceError: exports is not defined
The reason for this error, is that Babel compiles my client scripts as CommonJS modules and adds this lines in the beginning of each file:
Object.defineProperty(exports, "__esModule", { // <-- ReferenceError: exports is not defined
value: true
});
But I'm not using any UMD/CommonJS module loaders on the client, so this code causes errors. With Babel 5, to avoid this, I was using option modules: 'ignore'
in my gulpfile:
return gulp.src(src, {base: 'src'})
.pipe(babel({
modules: 'ignore' // <-- dropped from Babel 6
}))
.pipe(gulp.dest(dest));
so it compiled my scripts as is, raw and clear. But this option was dropped from Babel 6 and now it causes error
[ReferenceError: [BABEL] ..myscript.js: Unknown option: base.modules]
, so I had to comment this line.
Is there any alternative to modules: 'ignore'
in Babel 6?
Upvotes: 3
Views: 757
Reputation: 161457
Since you are using es2015
this set of plugins enabled by default. Note that babel-plugin-transform-es2015-modules-commonjs
is in there.
If you wish to not perform any type of module conversion, you'll need to explicitly list the plugins that you'd like to use, rather than using es2015
.
Upvotes: 4