You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During a production build Parcel or possibly Terser generates the same function hash for two different functions:
I have created a project using Parcel that includes jquery, gsap and pixi.js as dependencies. A development build works as expected, but a production build generates the same function hash for two different, but similarly named functions:
These two functions:
/**
* Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).
*
* @example
* PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1]
* @memberof PIXI.utils
* @function hex2rgb
* @param {number} hex - The hexadecimal number to convert
* @param {number[]} [out=[]] - If supplied, this array will be used rather than returning a new one
* @return {number[]} An array representing the [R, G, B] of the color where all values are floats.
*/ function $a43a28938b26b986$export$9b426722ac942144(hex, out) {
if (out === void 0) out = [];
out[0] = (hex >> 16 & 255) / 255;
out[1] = (hex >> 8 & 255) / 255;
out[2] = (hex & 255) / 255;
return out;
}
/**
* Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number.
*
* @example
* PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff
* @memberof PIXI.utils
* @function rgb2hex
* @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0.
* @return {number} Number in hexadecimal.
*/ function $a43a28938b26b986$export$9b426722ac942144(rgb) {
return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
}
Which as you can see are clearly different, with different signatures, but it seems a hash collision occurs on the names: hex2rgb and rgb2hex.
🤔 Expected Behavior
Generate different hash based on different functions.
😯 Current Behavior
Generates the same hash based on different functions.
This is the error I get in the browser when loading the code:
11:15:58.100 Uncaught SyntaxError: redeclaration of function
$a43a28938b26b986$export$9b426722ac942144invaders.1fffc83b.js:10983:13
note: Previously declared at line 10932, column 13invaders.1fffc83b.js:10932:13
💁 Possible Solution
Conflict occurs during hash of function name. Suggestion would be to hash on the function and signature, or add some randomization to the hash.
🔦 Context
Cannot produce a working production build when including pixi.js as part of the bundle.
💻 Code Sample
🌍 Your Environment
Software
Version(s)
Parcel
2.0.0-rc.0
terser
5.7.1
Node
13.9.0
npm/Yarn
6.13.7
Operating System
Windows 10 Pro for Workstations
EDIT: Fixed typo.
The text was updated successfully, but these errors were encountered:
At least in this simple example, it's not a collision of the Rust hashing function that's used for that (but I don't know why I'm not getting the hash that Parcel outputs in the bundle)
🐛 bug report
During a production build Parcel or possibly Terser generates the same function hash for two different functions:
I have created a project using Parcel that includes jquery, gsap and pixi.js as dependencies. A development build works as expected, but a production build generates the same function hash for two different, but similarly named functions:
These two functions:
These two functions are part of pixi.js.
Which as you can see are clearly different, with different signatures, but it seems a hash collision occurs on the names: hex2rgb and rgb2hex.
🤔 Expected Behavior
Generate different hash based on different functions.
😯 Current Behavior
Generates the same hash based on different functions.
This is the error I get in the browser when loading the code:
💁 Possible Solution
Conflict occurs during hash of function name. Suggestion would be to hash on the function and signature, or add some randomization to the hash.
🔦 Context
Cannot produce a working production build when including pixi.js as part of the bundle.
💻 Code Sample
🌍 Your Environment
EDIT: Fixed typo.
The text was updated successfully, but these errors were encountered: