-
-
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
Crash when --source-file-name used with non-es6 module type - index out of bounds: the len is 0 but the index is 0
#7035
Comments
@kdy1 assign to me? |
@realtimetodie swc/bindings/swc_cli/src/commands/compile.rs Line 549 in bb80c65
Will this function need to be removed? since #1388 is resolved. The rootcause is when we set swc/crates/swc_ecma_codegen/src/lib.rs Line 95 in bb80c65
begin to emit node: Module(Module { span: Span { lo: BytePos(1), hi: BytePos(23), ctxt: #0 }, body: [Stmt(Expr(ExprStmt { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, expr: Lit(Str(Str { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, value: Atom('use strict' type=dynamic), raw: None })) })), Stmt(Expr(ExprStmt { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, expr: Call(CallExpr { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, callee: Expr(Member(MemberExpr { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, obj: Ident(Ident { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, sym: Atom('Object' type=static), optional: false }), prop: Ident(Ident { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, sym: Atom('defineProperty' type=dynamic), optional: false }) })), args: [ExprOrSpread { spread: None, expr: Ident(Ident { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, sym: Atom('exports' type=inline), optional: false }) }, ExprOrSpread { spread: None, expr: Lit(Str(Str { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, value: Atom('__esModule' type=dynamic), raw: None })) }, ExprOrSpread { spread: None, expr: Object(ObjectLit { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, props: [Prop(KeyValue(KeyValueProp { key: Ident(Ident { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, sym: Atom('value' type=inline), optional: false }), value: Lit(Bool(Bool { span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, value: true })) }))] }) }], type_args: None }) }))], shebang: None }) so after emitting, the Line 498 in bb80c65
I think an empty |
I think we may skip #L549 when |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
Running the native cli binary on a typescript file that only contain types cause a crash when the
--source-file-name
flag is used together with thecommonjs
/umd
/amd
module type, it doesn't crash with thees6
module typeIt seems to work fine for the
es6
module type because it still produces a sourcemap when the file is types only while the others are producing empty sourcemapsInput code
Config
Playground link
No response
Expected behavior
Compiles without crashing
Actual behavior
Crashes
Version
1.3.38
Additional context
No response
The text was updated successfully, but these errors were encountered: