-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Move or alias #
directories for better ES Modules compatibility
#106
Comments
@davidwallacejackson thanks for report. I can imagine how painful it can be. The way it's being tackled is that new version of this package was published under Still ofc packages that depend on Note it's technically a duplicate of #30 |
Thank you so much for responding so quickly! I'm sorry about missing those existing issues. I didn't know about ext -- that sounds like the right path forward. There's four or five dependencies in my project using this package, but most of them are dev tooling, so I may not need to change those. The ones that are probably problematic are Oh, also: would it make sense to put some info about this issue and the new ext package in the project README? Edit: after investigating If you have time to upgrade them, that'd be awesome! If not, I'll probably submit something myself in the next couple days 🙂 |
Thanks @davidwallacejackson Problem is that also As I look in case of In case of |
I was trying to migrate a create-react-app project to Vite and got import errors related to es5-ext. A bit of investigation led me to this Vite bug. I'm trying to make a PR to fix it, but it's proven unexpectedly challenging and I though it'd be worth opening a ticket on this end as well.
The issue is that Vite, like many other next-generation build tools, uses native ES Modules to load modules in development mode. As a result the browser makes HTTP requests for modules, which leads to requests like
GET http://localhost:8080/node_modules/es5-ext/array/#/concat
. The hash is interpreted as a URI fragment delimiter, causing the server to receive a request forhttp://localhost:8080/node_modules/es5-ext/array/
instead.In theory, this can be solved on Vite's end -- the approach is to replace hash characters in module paths with a URL-safe identifier, then convert back to the hash when the request reaches the server. Doing so, however, makes any code in the request-handling pipeline that does URL-parsing invalid after the replacement is performed. It can be sorted out, but it's a pretty heavy lift. In theory, this is eventually problematic for
es5-ext
itself -- if a production deployment using ES Modules depends on es5-ext, browsers will have no way to load it.My understanding is that the hash is used to indicate prototype polyfills. Would there be any problem in moving the prototype polyfills to a URL-safe path like
proto
, and then leaving#
as an alias that imports from the new path for compatibility with existing projects?The text was updated successfully, but these errors were encountered: