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

transformModulesToAmd + unbundled option fails to resolve bare imports #3402

Closed
btopro opened this issue Apr 18, 2019 · 5 comments
Closed

transformModulesToAmd + unbundled option fails to resolve bare imports #3402

btopro opened this issue Apr 18, 2019 · 5 comments

Comments

@btopro
Copy link
Contributor

btopro commented Apr 18, 2019

the transformModulesToAmd option in build routinse in Polymer build does not correctly resolve bare dynamic imports. This is visible in firefox where it will convert it to a require statement but not actually alter the path, causing it to try and be relative to where ever the current file is.

TypeError: "Failed to fetch https://cdn.waxam.io/build/es5-amd/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-editor-builder.js"

in this example: https://cdn.waxam.io/build/es5-amd/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-builder.js will call import("@lrnwebcomponents/haxcms-elements/lib/core/haxcms-editor-builder.js"). This works fine in ES6 but when it goes to path resolve in ES5 you get what you see above as opposed to any kind of ../../../../ being appended to make the path relative accurately

@btopro btopro changed the title ES5 build does not resolve dynamic import paths transformModulesToAmd option in build does not resolve dynamic import paths Apr 19, 2019
@btopro
Copy link
Contributor Author

btopro commented Apr 19, 2019

here's my polymer.json https://github.com/elmsln/HAXcms/blob/master/polymer.json#L47 which is leveraged to kick things over to that CDN.

@btopro
Copy link
Contributor Author

btopro commented Apr 19, 2019

TLDR;

  • Good: transformModulesToAmd + bundled + dynamic imports
  • Good: unbundled + dynamic imports
  • Broken: transformModulesToAmd + unbundled + dynamic imports

This is an issue with unbundled AMD module compiling.
steps to reproduce:

This repo's output will WORK for the one marked unbroken and will break for the one marked broken. The only difference is the bundling. What's breaking appears to be a combination of transformModulesToAmd when using the unbundled flag. Dynamic imports Unbundled works fine without the AMD transform. AMD works fine without dynamic imports.

@btopro
Copy link
Contributor Author

btopro commented Apr 19, 2019

thanks to @Westbrook for making the repo to confirm I wasn't crazy

@btopro btopro changed the title transformModulesToAmd option in build does not resolve dynamic import paths transformModulesToAmd + unbundled option fails to resolve bare imports Apr 19, 2019
btopro added a commit to btopro/tools that referenced this issue Apr 19, 2019
usergenic added a commit that referenced this issue Apr 25, 2019
[polymer-build] #3402 resolveBareSpecifiers must be a Program
@usergenic
Copy link
Contributor

Just published [email protected] and [email protected] which incorporate your PR.

Please install and verify fix for your use case. Reopen this issue if you have continued trouble. :)

@btopro
Copy link
Contributor Author

btopro commented Apr 29, 2019

installed to double check and yes this appears to have fixed it. Thank you for accepting so quickly!

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

No branches or pull requests

2 participants