-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support dynamic import in vanilla template for Babel v7 #1931
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.js
module to supportbabel-plugin-syntax-dynamic-import
. I don't like this solution, particularly because thebabel.6.26.min.js
module 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.
getDefaultCode
serializes the return object, so the function is transformed intonull
. I think the best solution will be to usebabel-plugin-syntax-dynamic-import
provided I figure out how to generate the minified Babel 6 module.