Determine mechanism to add plugins after `babel-preset-env` plugins.
See original GitHub issueCurrently, all user supplied plugins (in options.babel.plugins
) are added before the babel-preset-env
plugins (see final plugin construction code here). I believe that this is the correct default position for all plugins (as most want to operate on the raw source AST).
However, there are some circumstances where you want to write plugins that operate on the AST after the various babel transforms have occurred. The prime example of this is the babel6-plugin-strip-class-callcheck
plugin, which removes the _classCallCheck
for production code (which is used by ember-data).
I can think of a couple of possible solutions here, we just need to decide what to implement.
- Option A: this emulates babel@5’s setup (which would have
{ transformer: ***, position: 'after' }
).
this.options.babel.plugins.push({
plugin: require('babel6-plugin-strip-class-callcheck'),
postion: 'after'
});
- Option B
this.options.babel.pluginsAfterTransformation = [
require('babel6-plugin-strip-class-callcheck')
];
I’m sure there are additional options, and I’m happy for suggestions.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Plugins - Babel.js
If the plugin is on npm, you can pass in the name of the plugin and Babel will check that it's installed in...
Read more >babel/preset-env
@babel/preset-env takes any target environments you've specified and checks them against its mappings to compile a list of plugins and passes it to...
Read more >Presets - Babel.js
Babel presets can act as sharable set of Babel plugins and/or config options . Official Presets. We've assembled a few presets for common...
Read more >Configure Babel
const presets = [ ... ]; const plugins = [ ... ]; if (process.env["ENV"] === "prod") { plugins.push(...); } module. · babel --plugins...
Read more >Babel 7 fails with single plugin saying "Duplicate plugin/preset ...
This is a babel error basically saying that you have defined your plugin @babel/plugin-transform-regenerator twice - more or less indirectly ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Modules are processed before the rest of preset env at the moment (I’m open to changing that if y’all disagree). So I don’t really think we are offering any options other than before or after preset env.
I looked into using a DAG last night, and it would be easy enough to implement but there isn’t a defining property we could use for the before/after (e.g. Babel plugins don’t have a
name
property). Which means it would be very difficult…