Support dynamic import in vanilla template for Babel v7#1931
Support dynamic import in vanilla template for Babel v7#1931CompuIves merged 3 commits intocodesandbox:masterfrom
Conversation
|
@pshrmn Very nice! Doesn't seem to be working with v6, though? http://pr1931.cs.lbogdan.tk/s/muddy-field-v05k2 |
|
@lbogdan I think that is because it is using the minified version, which I didn't fix. |
|
Ideally I would prefer to get Babel 6 working without touching those static files, but if that is the best approach, I would rather not try manually editing the minified version. Are those modules generated by some external script? |
|
I removed the Babel 6 support for now. Both static Babel files were added in #446, so I think that the builds must have happened externally. |
|
Ahh, good point! I think we can merge this one in the meantime. I think I got the other ones by building |
|
Does the PR build through |
|
Hey @pshrmn , We recently made some improvements to the PR building workflow, while moving it to a different domain, please push a new (empty) commit so that it will pick up and build this PR. |
|
Or you can merge |
|
I think that this is fine to merge. I'm not sure why the integration test is failing; the failing sandbox (https://codesandbox.io/s/6w66jzw3mn) is a Preact starter while this PR only affects Parcel templates. |
What kind of change does this PR introduce?
This PR enables use of dynamic
import()in the vanilla template.Fixes #1930
What is the current behavior?
A syntax error occurs.
What is the new behavior?
import()works as expected.Checklist:
I split the way that the change is added based on how Parcel does it internally.
v7 should be ready, it simply uses
parserOpts.v6 could use some work. My "fix" uses a plugin, which is what Parcel does for Babel v6. Parcel creates a custom plugin that is essentially the same as
babel-plugin-syntax-dynamic-import. That wasn't playing nicely when I tried to do the same, so I updated thebabel.6.26.jsmodule to supportbabel-plugin-syntax-dynamic-import. I don't like this solution, particularly because thebabel.6.26.min.jsmodule wasn't updated, but it wasn't immediately obvious where these static files get generated.Edit: I realized why the custom plugin wasn't working.
getDefaultCodeserializes the return object, so the function is transformed intonull. I think the best solution will be to usebabel-plugin-syntax-dynamic-importprovided I figure out how to generate the minified Babel 6 module.