Skip to content

Commit 6e77584

Browse files
authored
fix: use stable swc lexer for correct asi (#11555)
* fix: use stable swc lexer for correct asi
1 parent c85f843 commit 6e77584

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pnp = { version = "0.12.1", default-features = false }
129129
swc = { version = "36.0.0", default-features = false }
130130
swc_config = { version = "3.1.1", default-features = false }
131131
swc_core = { version = "37.0.0", default-features = false, features = ["parallel_rayon"] }
132+
swc_ecma_lexer = { version = "=23.0.1", default-features = false }
132133
swc_ecma_minifier = { version = "30.0.1", default-features = false }
133134
swc_error_reporters = { version = "16.0.1", default-features = false }
134135
swc_html = { version = "26.0.0", default-features = false }

crates/rspack_plugin_javascript/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ swc_core = { workspace = true, features = [
5050
"base",
5151
"ecma_quote",
5252
] }
53+
swc_ecma_lexer = { workspace = true }
5354
swc_node_comments = { workspace = true }
5455
tokio = { workspace = true, features = ["sync"] }
5556
tracing = { workspace = true }

crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
197197
Some(&comments),
198198
);
199199

200-
let lexer = swc_core::ecma::parser::Lexer::new(
200+
let lexer = swc_ecma_lexer::Lexer::new(
201201
Syntax::Es(EsSyntax {
202202
allow_return_outside_function: matches!(
203203
module_type,

crates/rspack_plugin_javascript/src/visitors/semicolon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use swc_core::{
33
common::{BytePos, Span},
44
ecma::{
55
ast::ClassMember,
6-
parser::unstable::{Token, TokenAndSpan},
76
visit::{Visit, VisitWith},
87
},
98
};
9+
use swc_ecma_lexer::token::{Token, TokenAndSpan};
1010

1111
/// Auto inserted semicolon
1212
/// See: https://262.ecma-international.org/7.0/#sec-rules-of-automatic-semicolon-insertion

packages/rspack-test-tools/tests/normalCases/parsing/asi/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ function bb() {
3131
function d() {}
3232
export function c() {}
3333
d(), foo();
34+
35+
const tpl = `${1}tpl`
36+
const arr = []
37+
foo(arr, tpl)

0 commit comments

Comments
 (0)