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

Keep assert and with keywords as is #8893

Closed
petamoriken opened this issue Apr 25, 2024 · 3 comments
Closed

Keep assert and with keywords as is #8893

petamoriken opened this issue Apr 25, 2024 · 3 comments
Labels

Comments

@petamoriken
Copy link
Contributor

petamoriken commented Apr 25, 2024

Describe the bug

V8 will remove support for the assert keywords, so Node.js and Chrome will follow suit.

Hey, quick update on this. Node.js is planning to remove support for assert in v22 (which will be released in April) and Chrome in v126 (which will be released in May).

denoland/deno#17944 (comment)

I'm trying to implement this in Deno as well (denoland/deno#23541), but it doesn't work because swc commonizes the assert and with keywords. Please add a new option to pass those keywords as is to V8.

Input code

import foo from "./foo.json" with { type: "json" };
import bar from "./bar.json" assert { type: "json" };
console.log(foo);
console.log(bar);

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    },
    "experimental": {
      "keepImportAttributes": true
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.5.0&code=H4sIAAAAAAAAA8vMLcgvKlFIy89XSCvKz1VQ0tMHsvWyivPzlBTKM0syFKoVSioLUq0UlCBitdZcmRA9SYlFcD1ANlRPYnFxKlASU1dyfl5xfk6qXk5%2BugbQCk1UEaABmtYAe1o9F40AAAA%3D&config=H4sIAAAAAAAAA21QOw6DMAzdOQXy3KFi6NCtY4ceIqUGpU1IZBsJhLg7CSSUSt3i9%2FNzpqIs4c01XMspPMPgFTHSPgeEx07UEBCQ0SPXpL3AKbPCkWqUYVyheWNAFLUo0YVcnasqOcA4x5gdCbO608143Fk76wmZf4VRqrrW4N%2BNOHgkbTG0NcesD6K%2FW%2B9IbiKkn71gzBXqk79IGWDdq1%2FD01%2FEe7cLLvAV5bJ7MdD8yM41dV4AwZk7Q1cBAAA%3D

SWC Info output

No response

Expected behavior

import foo from "./foo.json" with {
    type: "json"
};
import bar from "./bar.json" assert {
    type: "json"
};
console.log(foo);
console.log(bar);

Actual behavior

import foo from "./foo.json" with {
    type: "json"
};
import bar from "./bar.json" with {
    type: "json"
};
console.log(foo);
console.log(bar);

Version

1.5.0

Additional context

related options:

https://github.com/swc-project/swc/blob/c76cd9eccf080da67d1c8d75063f8286dfc4acc1/packages/types/index.ts#L607-L616C9

@kdy1
Copy link
Member

kdy1 commented Apr 26, 2024

Closing as not planned. This require modification of AST, but it does not worth it without a concrete usecase.

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@petamoriken
Copy link
Contributor Author

@kdy1 Then, could you add importAssertions: boolean to TsParserConfig to disable the assert keywords in TypeScript?

@kdy1
Copy link
Member

kdy1 commented Apr 27, 2024

I'll accept a PR, but it should named differently so the default value can be false

bartlomieju pushed a commit to denoland/deno that referenced this issue Apr 29, 2024
Ref #17944, swc-project/swc#8893

TypeScript removes the `assert` keywords in the transpile, so this PR
only works for JavaScript files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants