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

Identifier has already been declared #365

Open
o-serhiichyk opened this issue Aug 22, 2023 · 0 comments
Open

Identifier has already been declared #365

o-serhiichyk opened this issue Aug 22, 2023 · 0 comments

Comments

@o-serhiichyk
Copy link

o-serhiichyk commented Aug 22, 2023

Are you using the latest verion of NUglify, especially if used through BunderMinifier? Update before raising a bug as your issue is probably already fixed.
I'm using the last version.

Describe the bug
In specific scenario minifier uses the same variable name twice. It leads to an error like "Identifier 'n' has already been declared".

To Reproduce
I have code like this:

define("SomeModule", [], function() {
	return {
		someProperty: [{
			property1: "SomeString",
			property2: async () => {
				if (someVariable) {
					return;
				} else {
					let service1 = new SomeService();
					service1.someMethod();
					const const1 = await someFunction1();
					const const2 = await someFunction2();
					// another code
				}
			}
		}, ],
	};
});

Code settings:
ConstStatementsMozilla = true

Minified output or stack trace
Minified code:

define("SomeModule",[],function(){return{someProperty:[{property1:"SomeString",property2:async()=>{if(someVariable)return;else{let n=new SomeService;n.someMethod();const n=await someFunction1(),t=await someFunction2()}}},]}})

Formatted version:

define("SomeModule", [], function() {
	return {
		someProperty: [{
			property1: "SomeString",
			property2: async () => {
				if (someVariable) return;
				else {
					let n = new SomeService;
					n.someMethod();
					const n = await someFunction1(),
						t = await someFunction2()
				}
			}
		}, ]
	}
})

As you can see, name n used for both variable service1 and const1 in the same block.

Excepted output code
Another name instead of n for variable const1.

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

No branches or pull requests

2 participants