-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
@swc/wasm-typescript exits on Windows arm64 when fed with certain syntax #9520
Comments
Is this issue only related to the strip-only? import { transformSync } from "@swc/wasm-typescript";
const options = {
mode: "transform",
transform: {
verbatimModuleSyntax: true,
nativeClassProperties: true,
noEmptyExport: true,
importNotUsedAsValues: "preserve",
}
}
console.log("Begin 1");
console.log(
transformSync(`
export function foo() {
return 'foo';
};
`, options).code,
);
console.log("End 1");
console.log("Begin 2");
console.log(
transformSync(`
export function foo() {
if (false) {
}
return 'foo';
};
`, options).code,
);
console.log("End 2"); |
@magic-akari No luck:
|
It's suspected that the issue arises at an earlier stage, possibly in the parser. |
let's do more experiments to pinpoint this issue.
npx swc_ast_viewer path/to/your_file.js |
Ad 1 - This worked perfectly fine, on latest Microsoft Edge, arm64 build. input === output. Output
Module(
Module {
span: 1..59,
body: [
ModuleDecl(
ExportDecl(
ExportDecl {
span: 1..58,
decl: Fn(
FnDecl {
ident: Ident {
span: 17..20,
ctxt: #2,
sym: "foo",
optional: false,
},
declare: false,
function: Function {
params: [],
decorators: [],
span: 8..58,
ctxt: #3,
body: Some(
BlockStmt {
span: 23..58,
ctxt: #3,
stmts: [
If(
IfStmt {
span: 26..41,
test: Lit(
Bool(
Bool {
span: 30..35,
value: false,
},
),
),
cons: Block(
BlockStmt {
span: 37..41,
ctxt: #4,
stmts: [],
},
),
alt: None,
},
),
Return(
ReturnStmt {
span: 43..56,
arg: Some(
Lit(
Str(
Str {
span: 50..55,
value: "foo",
raw: Some(
"'foo'",
),
},
),
),
),
},
),
],
},
),
is_generator: false,
is_async: false,
type_params: None,
return_type: None,
},
},
),
},
),
),
Stmt(
Empty(
EmptyStmt {
span: 58..59,
},
),
),
],
shebang: None,
},
)
|
It seems that our WASM version parser isn't working on Windows ARM64 with Node.js. Moreover, there are no methods in WASM that trigger What are your thoughts? @kdy1 |
My feeling is that there is no crash/error, it simply exits the transpilation early with an empty output. |
@magic-akari I think we can use the CI of SWC. You can add some node.js tests and run the publish action with only nightly enabled. |
Let's try with |
I see the CI is green, might be related to WASM? |
I got an arm64 windows device. My mother had one 👍 |
I managed to install VS and rust on it. I'll try later today. |
Running |
|
However, the same WASM works in the browser but not in node. |
I've tried with newer versions and the problem persists. Just to confirm, is the bug in the javascript wasm glue or in the wasm itself? |
Actually, I don't remember. I'll retry and report back. |
My notebook is somehow broken, so I think I should try using some hosting |
This is the PR that can reproduce this behavior |
Can my real machine be of any use? |
@wojtekmaj Steps to reproduce:
Can you try it? |
I'm stuck on build phase :/ Getting
despite installing the dependencies as documented... |
@marco-ippolito I created a separate repository to test it using Github Actions. I'll monitor this to ensure that it does not fail with unrelated stuffs |
It seems like napi default template does not have arm64 windows. |
@kdy1 https://github.com/kdy1/swc-win-arm64/actions/runs/12219567059/job/34086308398 The binary was built, but the GitHub Actions doesn't provide Windows on ARM runner, so I think it's hard to setup Windows on ARM test |
I'll try to see if I can repro this. |
Apparently it now works on Node nodejs/node#54645 I assume it was some weird combination of v8/windows arm64 |
Unfortunately, this is not my experience. I updated @swc/wasm-typescript in my original repro from 1.7.23 to 1.10.1 and this is still very much reproducible, with SWC quietly exiting:
|
Can you try with Node 23? |
On Node main and v23.5.0 (Windows 11 arm64 VM I got on azure): // test.swc.js
import { stripTypeScriptTypes } from "node:module";
console.log("Begin 1");
console.log(
stripTypeScriptTypes(`
export function foo() {
return 'foo';
};
`),
);
console.log("End 1");
console.log("Begin 2");
console.log(
stripTypeScriptTypes(`
export function foo() {
if (false) {
}
return 'foo';
};
`),
);
console.log("End 2"); Output:
Output on Node 23.5.0:
Also the interaction with loaders has been fixed. |
@marco-ippolito I suggest you verify that the output of process.arch under Node.js in your ARM64 VM is arm64. It is easy to accidentally install the x64 version on a Windows arm64 system. |
It is arm 100% |
Describe the bug
After investigation in nodejs/node#54645 I finally came to conclusion that on Windows arm64 (this particular configuration, not Windows other than arm64, not arm64 other than Windows), swc fails to transform certain syntax and just silently exits instead.
Input code
Config
n/a
Playground link (or link to the minimal reproduction)
https://gist.github.com/wojtekmaj/c37e1eb07676cde83e5201ade8b7f02f
SWC Info output
Expected behavior
Code should be transformed, types should be stripped, swc should not silently exit.
Actual behavior
swc silently exists, and neither the output, nor "End 2" console.log (see playground link) never appears on the screen.
Version
1.7.22
Additional context
No response
The text was updated successfully, but these errors were encountered: