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

Support new import attributes "with" syntax. #1529

Open
freshp86 opened this issue May 9, 2024 · 5 comments
Open

Support new import attributes "with" syntax. #1529

freshp86 opened this issue May 9, 2024 · 5 comments

Comments

@freshp86
Copy link

freshp86 commented May 9, 2024

The new with syntax will soon be required by Chromium (and other Chromium based browsers), and the old assert syntax will no longer work (see https://chromium-review.googlesource.com/c/v8/v8/+/5512879).

Also see [1], [2] for the status of the "import attributes" feature. The older syntax had been implemented at #1095, and it seems that some similar updates are needed to support the new syntax.

[1] https://caniuse.com/mdn-javascript_statements_import_import_attributes
[2] https://chromestatus.com/feature/5205869105250304

Bug report or Feature request?

Bug.

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

5.31.0

Complete CLI command or minify() options used

{
  module: true,
  compress: {},
  mangle: {},
  output: {},
  parse: {},
  rename: {},
}

terser input

import mysheet from './foo.css' with {type : 'css'};

terser output or error

ERROR: Unexpected token: keyword (with)

Expected result

Should not crash.

@freshp86
Copy link
Author

Also possibly related bug at acornjs/acorn#1289.

@fabiosantoscode
Copy link
Collaborator

What should be the output for people who wrote assert? Should it be garbage-in-garbage-out or always output with? assert wasn't JS syntax proper, but it might be supported by some browsers that users of assert support, that wouldn't support with.

@fabiosantoscode
Copy link
Collaborator

This is why I should always wait for stage 4 :)

@freshp86
Copy link
Author

freshp86 commented May 22, 2024

What should be the output for people who wrote assert?

Whatever happens today? I don't think the feature request here to support with should affect what happens when assert is used. Terser authors can decide when/if support for assert should be completely removed.

Should it be garbage-in-garbage-out or always output with?

Personal opinion is that a minifier should not make assert -> with transformations to the code, as this is not strictly speaking a minifiers responsibility. If the code used assert it should output assert. Having said that, I am not a Terser author, so just my perspective.

@fabiosantoscode
Copy link
Collaborator

You are correct that the minifier shouldn't convert between them, at least in theory.

I'll wait for Stage 4 to implement, otherwise I might have to support 3 different versions of the feature.

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

No branches or pull requests

2 participants