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
global URL constructor is mangled to match URL variable in dependency module #10
Comments
hotfix until browserify/tinyify#10 is resolved
hotfix until browserify/tinyify#10 is resolved
It looks like a problem in browser-pack-flat: (it's usually the one responsible for variable name conflicts so far 😅 ) // ajv.js
var URL = 'abc'
// index.js
require('./ajv')
new URL('test') With (function(){
var _$ajv_1 = {};
var URL = 'abc'
var _$tinyifyGlobalUrlBug_2 = {};
/* removed: var _$ajv_1 = require('./ajv') */;
new URL('test')
}()); browser-pack-flat is supposed to rename module-global variables when they collide with variable names in other modules, but the |
Adding a failing test to browser-pack-flat for this case: goto-bus-stop/browser-pack-flat#27 Unfortunately the fix seems kinda tricky; may need to split up some of the logic in separate steps so that variable names are collected over the entire bundle and then marked as duplicates over the entire bundle, instead of doing the collection and duplicate marking in one step. |
📦 |
thanks @goto-bus-stop 💝 🐈 |
hi, thanks for
tinyify
, it's real rad! 😊i noticed a bug with the mangled variable names affecting the global
URL
constructor, i'm not sure exactly which module is responsible so i'm posting here.in one of my dependency modules (
redux-bundler/src/create-url-bundler.js
) the code uses the globalURL
constructor to parse urls.in another dependency module (
ajv/lib/compile/formats.js
) there is a local variable calledURL
(a regular expression to match urls).for some reason, they are both being mangled to the same minified name, which means the call to
new URL()
fails because it's now something likenew ie()
which is not a constructor function.i made a reproducible test case here:
ahdinosaur/tinyify-global-url-bug
, which is simply:which with
browserify -p tinyify .
becomesi haven't yet figured out to replicate the same behavior without
ajv
but hey.thanks for listening. 🐱
The text was updated successfully, but these errors were encountered: