babel-plugin-add-module-exports
babel-plugin-add-module-exports copied to clipboard
add-module-exports without es2015 preset
I would like to keep ES6 code and transpile only modules loading, so do not add preset, but I add:
plugins: [ 'transform-es2015-modules-amd', 'add-module-exports' ]
For some reason, this plugin does not work in such configuration. It also does not work also even if I add all plugins from the es2015
preset, but without adding the preset.
Is it possible to make it works in such configuration?
This really is an issue for small modules in a ci environment as downloading plugins from npm takes up most of the time spent on building.
Contents of .babelrc:
{
"plugins": [
"add-module-exports",
"transform-es2015-template-literals",
"transform-es2015-modules-commonjs"
]
}
The thing is, it doesn't matter what you define in your .babelrc, as long as the es2015 preset is installed.
If I use the plugin in a similar fashion as described above I get the following error:
> babel lib/install-hooks.js -o dist/install-hooks.js
/usr/local/lib/node_modules/babel/lib/babel/util.js:55
throw err;
^
TypeError: The plugin "add-module-exports" didn't export a Plugin instance
at PluginManager.validate (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/transformation/file/plugin-manager.js:164:13)
at PluginManager.add (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/transformation/file/plugin-manager.js:213:10)
at File.buildTransformers (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/transformation/file/index.js:240:21)
at new File (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/transformation/file/index.js:140:10)
at Pipeline.transform (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at Object.exports.transform (/usr/local/lib/node_modules/babel/lib/babel/util.js:40:22)
at Object.exports.compile (/usr/local/lib/node_modules/babel/lib/babel/util.js:49:20)
at /usr/local/lib/node_modules/babel/lib/babel/file.js:123:23
at arrayEach (/usr/local/lib/node_modules/babel/node_modules/lodash/index.js:1289:13)
at Function.<anonymous> (/usr/local/lib/node_modules/babel/node_modules/lodash/index.js:3345:13)