Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] include dynamic import syntax plugin automatically #515

Closed
hzoo opened this issue Sep 21, 2017 · 4 comments · May be fixed by thiagoarrais/babel#1
Closed

[feature request] include dynamic import syntax plugin automatically #515

hzoo opened this issue Sep 21, 2017 · 4 comments · May be fixed by thiagoarrais/babel#1

Comments

@hzoo
Copy link
Member

hzoo commented Sep 21, 2017

I've written/talked about this before a few times, might as well make it an issue.

We shouldn't have to ask users to include the dynamic import plugin if webpack is supporting it and is a source of pain. Ideally it would work with preset-env where webpack is it's own target or something but this is already babel-loader so we know that a user is using webpack + babel together. We could just make it a dependency (or just use parserOpts: { plugins: ['dynamicImport'] } and no dependency necessary).

So like at

babel-loader/src/index.js

Lines 128 to 129 in 1ca5c78

const defaultOptions = {
metadataSubscribers: [],

const defaultOptions = {
+  parserOpts: { plugins: ['dynamicImport'] },

Or we'd have to do append the plugin to the end of the plugins:

options.plugins.push(require('babel-plugin-syntax-dynamic-import'))
@DrewML
Copy link
Member

DrewML commented Jan 8, 2018

I can't think of a reason not to do this, since the current version only supports webpack versions >= 2

@mikeaustin
Copy link

This wa a source of pain for me because I was using the Webpack version of the plugin vs the Babel version. I was pulling out my hair tying to get the webpackChunkName comment to work. Then there’s the @babel namespace that you should use for some modules because they’ve been moved. In general, I find it hard to find the right module sometimes because of similar names, clones, and name spacing. Of course that’s a whole topic on its own :)

@loganfsmyth loganfsmyth changed the title Feature: include dynamic import syntax plugin automatically [feature request] include dynamic import syntax plugin automatically Sep 2, 2018
@thiagoarrais
Copy link

Just started a PR for this. Can someone please help me get it merged?

@nicolo-ribaudo
Copy link
Member

Fixed by babel/babel#10109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants