-
-
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
For scope hoisting, Asset IDs cannot contain + or / (base64) #2681
Conversation
Perhaps it would be a better idea to just not base64 encode it? Base64 has a bunch of invalid variable characters including Sent with GitHawk |
Hex should always be valid variable names if preceded by a letter Sent with GitHawk |
What would be an alternative to base64? With base64's many possible chars, collisions are less likely than with hex.
The "only letters at beginning" is not an issue, because scope hoisting always puts a dollar sign in front. And the md5 is encoded as base64: parcel/packages/core/parcel-bundler/src/utils/md5.js Lines 4 to 9 in a1567e1
|
I know it’s currently being encoded just thought hex would probably be more reliable to prevent special characters. This PR is probably sufficient for what it’s aiming a, but I don’t think 4 char base64 var names will be sufficient in the long term, seems like collisions and issues are inevitable. If I remember correctly I even had a PR open to use larger names a lil while back because there were issues with large apps Sent with GitHawk |
Hmm we also use the toIdentifier function from Babel for all of the scope hoisting generated variable names, which should be removing those bad characters. Perhaps you ran into a case where we forgot to do that? |
Yes, was missing in VueAsset |
I just ran into this error while trying out parcel to bundle a vue app. I did not notice that this fix is just a few days old and not released yet. In case anyone is interested, here is a small repo to reproduce this error. See the readme for steps to reproduce. Renaming the component works around this problem but leads to another one ( |
Could you please open an issue for this, if it doesn't already exist? |
↪️ Pull Request
Asset IDs are base64 encoded, so
+
and/
are also possible. The IDs are used for hoisting imports and exports, but with an IDkA+M
then$kA+M$exports
is not a valid JS identifier, causing an error (see issue):Unexpected token, expected ; (2:19)
Collisions might have become more likely now, but shouldn't be that significant?
Fixes #1971
💻 Examples
https://github.com/njscholfield/new-tracks/tree/8eba7b08f286cac510d55e5d85800d64633dd3fe
✔️ PR Todo