ember-cli / ember-cli-terser

JavaScript minification for Ember-CLI
MIT License
23 stars 27 forks source link

v4.0.2 gives build error `Unexpected token: punc (:)` #287

Open kellyselden opened 3 years ago

kellyselden commented 3 years ago

Updating to v4.0.2 gives us the following in our build logs:

error   08-Jul-2021 12:04:17    Error: Unexpected token: punc (:)
error   08-Jul-2021 12:04:17            at TerserWriter
error   08-Jul-2021 12:04:17    -~- created here: -~-
error   08-Jul-2021 12:04:17        at new Plugin (/node_modules/broccoli-terser-sourcemap/node_modules/broccoli-plugin/dist/index.js:47:36)

v4.0.1 is working. Are we missing a transitive dependency update? Or is there an issue with v4.0.2?

rami-alloush commented 1 year ago

I'm still facing this year old issue! is this package deprecated?

bertdeblock commented 1 year ago

@rami-alloush No, at the moment, it's not. @kellyselden Did you manage to figure out what was causing this?

kellyselden commented 1 year ago

I have not.

runspired commented 1 year ago

confirmed its still an issue with the recent changes. @bertdeblock its due to broccoli-asset-rev prepend, can help you track down why if needed. see also https://github.com/ember-cli/broccoli-terser-sourcemap/issues/310 and https://github.com/ember-cli/ember-cli-terser/issues/275 which are all the same regression I believe

runspired commented 1 year ago

The code it chokes on is this:

const file = await fetch(<<CDN_RUL>>`/translations/en-us-0875d483587e8fe8b6c09c9f9f8008f6.json`);

note how that is outside of the backticks

this is the original source code:

const file = await fetch(`/translations/en-us.json`);

It would appear that potentially broccoli-asset-rev is not handling prepend correct when backticks are in use

runspired commented 1 year ago

Actual issue I think: https://github.com/ember-cli/broccoli-asset-rev/issues/143

bertdeblock commented 1 year ago

https://github.com/ember-cli/ember-cli/issues/9528 seems like the same issue and https://github.com/ember-cli/broccoli-asset-rewrite/pull/73 was made as an attempt to fix it.