Skip to content

prop conflic during mangle-props #1428

Open

Description

@lolovo

Bug report

Prop mangled name conflict during sequance usage with --name-cache as result wrong output with duplicated prop name.

Version (complete output of terser -V or specific git commit)

5.19.2

Complete CLI command or minify() options used

I'm using terser on several files with same config :

del .\dist\cache.json
terser ./dist/tools.js --format beautify --mangle --mangle-props keep_quoted --name-cache ./dist/cache.json -o ./dist/_tools.js
terser ./dist/index.js --format beautify --mangle --mangle-props keep_quoted --name-cache ./dist/cache.json -o ./dist/_index.js

after first execute on tools.js ./dist/cache.json contains the following problem prop "$o":"sb" that makes conflict during second execute and as result object contains prop with duplicate wrong name

for simplification to reproduce it we can make cache.json only with problem prop and we've got these cmds (index.js also simplified for reproduction):
echo {"vars":{"props":{}},"props":{"props":{"$o":"sb"}}} > .\dist\cache.json
terser ./dist/index.js --format beautify --mangle --mangle-props keep_quoted --name-cache ./dist/cache.json -o ./dist/_index.js

terser input

./dist/cache.json:
{"vars":{"props":{}},"props":{"props":{"$o":"sb"}}}

index.js:

		var args = {
			sb: 'sb',
			o: 'o',
		};
		console.log(args.sb);

terser output or error

we've got duplicated name in _index.js:

var args = {
    sb: "sb",
    sb: "o"
};
console.log(args.sb);

sb: "sb" -- stayed untouched and not renamed (cache.json doesn't changed after execute), but should be

Expected result
_index.js:

		var args = {
			UNIQUE_NAME_HERE: 'sb',
			sb: 'o',
		};
		console.log(args.UNIQUE_NAME_HERE);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions