Skip to content

Commit 43d5d19

Browse files
mischnicjondlm
andauthored
Bump swc (#9574)
* Bump swc, enable stacker feature Bump swc * Adapt for breaking swc AST change * Support testing with Miri * Grow stack when visiting expressions * WIP add example * Revert "WIP add example" This reverts commit d4dba2c. * Add swc update script * Update test fixtures * Fix windows stack overflow with larger stack red_zone (#9693) * Bump swc * Bump a few crates for vulnerabilites * Bump swc * Fix esm2js transform when export destructuring --------- Co-authored-by: Jon de la Motte <[email protected]>
1 parent a4a4033 commit 43d5d19

24 files changed

+512
-499
lines changed

Cargo.lock

+310-303
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/macros/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ napi = ["dep:napi", "dep:napi-derive", "dep:crossbeam-channel"]
99

1010
[dependencies]
1111
indexmap = "1.9.2"
12-
swc_core = { version = "0.89.6", features = [
12+
swc_core = { version = "0.92.4", features = [
1313
"common",
1414
"common_ahash",
1515
"common_sourcemap",
1616
"ecma_ast",
1717
"ecma_parser",
1818
"ecma_visit",
19+
"stacker"
1920
] }
2021
serde = "1.0.123"
2122
napi-derive = { version = "2.12.5", optional = true }

crates/macros/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashMap;
22
use std::collections::HashSet;
33
use std::sync::Arc;
4+
use swc_core::ecma::utils::stack_size::maybe_grow_default;
45

56
use indexmap::IndexMap;
67
use swc_core::common::util::take::Take;
@@ -254,7 +255,7 @@ impl<'a> Fold for Macros<'a> {
254255
return Expr::Call(call);
255256
}
256257

257-
node.fold_children_with(self)
258+
maybe_grow_default(|| node.fold_children_with(self))
258259
}
259260

260261
fn fold_var_decl(&mut self, mut node: VarDecl) -> VarDecl {

crates/node-bindings/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use std::alloc::Layout;
77

88
mod init_sentry;
99

10-
#[cfg(target_os = "macos")]
10+
#[cfg(all(target_os = "macos", not(miri)))]
1111
#[global_allocator]
1212
static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
1313

14-
#[cfg(windows)]
14+
#[cfg(all(windows, not(miri)))]
1515
#[global_allocator]
1616
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
1717

packages/core/core/test/Parcel.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ describe('ParcelAPI', function () {
8686
afterEach(() => workerFarm.end());
8787

8888
describe('parcel.unstable_transform()', () => {
89-
it('should transforms simple file', async () => {
89+
it('should transform simple file', async () => {
9090
let parcel = createParcel({workerFarm});
9191
let res = await parcel.unstable_transform({
9292
filePath: path.join(__dirname, 'fixtures/parcel/index.js'),
9393
});
9494
let code = await res[0].getCode();
95-
assert(code.includes('exports.default = "test"'));
95+
assert(code.includes(`exports.default = 'test'`));
9696
});
9797

9898
it('should transform with standalone mode', async () => {
@@ -103,9 +103,9 @@ describe('ParcelAPI', function () {
103103
});
104104
let code = await res[0].getCode();
105105

106-
assert(code.includes('require("./index.js")'));
107-
assert(code.includes('new URL("index.js", "file:" + __filename);'));
108-
assert(code.includes('import("index.js")'));
106+
assert(code.includes(`require("./index.js")`));
107+
assert(code.includes(`new URL("index.js", "file:" + __filename);`));
108+
assert(code.includes(`import('index.js')`));
109109
});
110110
});
111111

packages/core/integration-tests/test/cache.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5875,17 +5875,17 @@ describe('cache', function () {
58755875
},
58765876
async update(b) {
58775877
let res = await run(b.bundleGraph);
5878-
assert(res.includes(`let a = "a"`));
5878+
assert(res.includes(`let a = 'a'`));
58795879

58805880
await overlayFS.writeFile(
58815881
path.join(inputDir, 'src/entries/a.js'),
5882-
`export let a = "b";`,
5882+
`export let a = 'b';`,
58835883
);
58845884
},
58855885
});
58865886

58875887
let res = await run(b.bundleGraph);
5888-
assert(res.includes(`let a = "b"`));
5888+
assert(res.includes(`let a = 'b'`));
58895889
});
58905890

58915891
it('should invalidate when switching to a different packager for an inline bundle', async function () {

packages/core/integration-tests/test/html.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,7 @@ describe('html', function () {
26892689
await getNextBuild(b);
26902690

26912691
let html = await outputFS.readFile('/dist/index.html', 'utf8');
2692-
assert(html.includes(`console.log("test")`));
2692+
assert(html.includes(`console.log('test')`));
26932693

26942694
await overlayFS.writeFile(
26952695
path.join(__dirname, '/html-inline-js-require/test.js'),
@@ -2698,7 +2698,7 @@ describe('html', function () {
26982698
await getNextBuild(b);
26992699

27002700
html = await outputFS.readFile(path.join(distDir, '/index.html'), 'utf8');
2701-
assert(html.includes(`console.log("foo")`));
2701+
assert(html.includes(`console.log('foo')`));
27022702
});
27032703

27042704
it('should invalidate parent bundle when nested inline bundles change', async function () {

packages/core/integration-tests/test/incremental-bundling.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ console.log('adding a new console');`,
9090
result.bundleGraph.getBundles()[0].filePath,
9191
'utf8',
9292
);
93-
assert(contents.includes(`console.log("adding a new console")`));
93+
assert(contents.includes(`console.log('adding a new console')`));
9494
} finally {
9595
if (subscription) {
9696
await subscription.unsubscribe();
@@ -132,7 +132,7 @@ console.log('adding a new console');`,
132132
result.bundleGraph.getBundles()[0].filePath,
133133
'utf8',
134134
);
135-
assert(contents.includes(`console.log("adding a new console")`));
135+
assert(contents.includes(`console.log('adding a new console')`));
136136
} finally {
137137
if (subscription) {
138138
await subscription.unsubscribe();
@@ -174,7 +174,7 @@ console.log('adding a new console');`,
174174
result.bundleGraph.getBundles()[0].filePath,
175175
'utf8',
176176
);
177-
assert(contents.includes(`console.log("adding a new console")`));
177+
assert(contents.includes(`console.log('adding a new console')`));
178178
} finally {
179179
if (subscription) {
180180
await subscription.unsubscribe();
@@ -217,7 +217,7 @@ console.log(a);
217217
'utf8',
218218
);
219219
assert(
220-
contents.includes(`console.log("index.js - updated string");`),
220+
contents.includes(`console.log('index.js - updated string');`),
221221
);
222222
} finally {
223223
if (subscription) {
@@ -308,7 +308,7 @@ module.exports = a;`,
308308
'utf8',
309309
);
310310

311-
assert(contents.includes(`console.log("adding a new console")`));
311+
assert(contents.includes(`console.log('adding a new console')`));
312312

313313
let bundleOutput = await run(result.bundleGraph);
314314
assert.equal(bundleOutput, 'a updated');
@@ -404,7 +404,7 @@ console.log(a, 'updated');`,
404404
'utf8',
405405
);
406406

407-
assert(contents.includes(`console.log((0, _a.a), "updated");`));
407+
assert(contents.includes(`console.log((0, _a.a), 'updated');`));
408408

409409
let bundleCSS = result.bundleGraph.getBundles()[1];
410410
assert.equal(bundleCSS.type, 'css');
@@ -504,7 +504,7 @@ console.log(a);
504504
'utf8',
505505
);
506506

507-
assert(contents.includes(`console.log("index.js", (0, _b.b));`));
507+
assert(contents.includes(`console.log('index.js', (0, _b.b));`));
508508
} finally {
509509
if (subscription) {
510510
await subscription.unsubscribe();
@@ -612,7 +612,7 @@ console.log(a, b);
612612
);
613613
assert(
614614
dynamicContent.includes(`parcelHelpers.export(exports, "b", ()=>b);
615-
const b = "b";`),
615+
const b = 'b';`),
616616
);
617617
} finally {
618618
if (subscription) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const {foo} = {foo: 1};
2+
export const [bar] = [2];

packages/core/integration-tests/test/javascript.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1109,8 +1109,8 @@ describe('javascript', function () {
11091109
let main = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
11101110
dedicated = await outputFS.readFile(dedicated.filePath, 'utf8');
11111111
shared = await outputFS.readFile(shared.filePath, 'utf8');
1112-
assert(/new Worker(.*?, {[\n\s]+type: "module"[\n\s]+})/.test(main));
1113-
assert(/new SharedWorker(.*?, {[\n\s]+type: "module"[\n\s]+})/.test(main));
1112+
assert(/new Worker(.*?, {[\n\s]+type: 'module'[\n\s]+})/.test(main));
1113+
assert(/new SharedWorker(.*?, {[\n\s]+type: 'module'[\n\s]+})/.test(main));
11141114
});
11151115

11161116
for (let shouldScopeHoist of [true, false]) {
@@ -1263,8 +1263,8 @@ describe('javascript', function () {
12631263
);
12641264

12651265
let main = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
1266-
assert(/new Worker(.*?, {[\n\s]+name: "worker"[\n\s]+})/.test(main));
1267-
assert(/new SharedWorker(.*?, {[\n\s]+name: "shared"[\n\s]+})/.test(main));
1266+
assert(/new Worker(.*?, {[\n\s]+name: 'worker'[\n\s]+})/.test(main));
1267+
assert(/new SharedWorker(.*?, {[\n\s]+name: 'shared'[\n\s]+})/.test(main));
12681268
});
12691269

12701270
it('should error if importing in a worker without type: module', async function () {
@@ -1463,7 +1463,7 @@ describe('javascript', function () {
14631463
]);
14641464

14651465
let res = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
1466-
assert(res.includes(`importScripts("imported.js")`));
1466+
assert(res.includes(`importScripts('imported.js')`));
14671467
});
14681468

14691469
it('should ignore importScripts in script workers when not passed a string literal', async function () {
@@ -1509,7 +1509,7 @@ describe('javascript', function () {
15091509
]);
15101510

15111511
let res = await outputFS.readFile(b.getBundles()[1].filePath, 'utf8');
1512-
assert(res.includes(`importScripts("https://unpkg.com/parcel")`));
1512+
assert(res.includes(`importScripts('https://unpkg.com/parcel')`));
15131513
});
15141514

15151515
it('should support bundling service-workers', async function () {
@@ -1584,7 +1584,7 @@ describe('javascript', function () {
15841584
let main = bundles.find(b => !b.env.isWorker());
15851585
let mainContents = await outputFS.readFile(main.filePath, 'utf8');
15861586
assert(
1587-
/navigator.serviceWorker.register\(.*?, {[\n\s]*scope: "foo"[\n\s]*}\)/.test(
1587+
/navigator.serviceWorker.register\(.*?, {[\n\s]*scope: 'foo'[\n\s]*}\)/.test(
15881588
mainContents,
15891589
),
15901590
);
@@ -4386,7 +4386,7 @@ describe('javascript', function () {
43864386
let res = await run(b);
43874387
assert.equal(
43884388
res.default,
4389-
`<p>test</p>\n<script>console.log("hi");\n\n</script>\n`,
4389+
`<p>test</p>\n<script>console.log('hi');\n\n</script>\n`,
43904390
);
43914391
});
43924392

@@ -5238,6 +5238,14 @@ describe('javascript', function () {
52385238
assert.deepEqual(res, {ns: {a: 4, default: 1}});
52395239
});
52405240

5241+
it('should support export declarations with destructuring', async function () {
5242+
let b = await bundle(
5243+
path.join(__dirname, 'integration/js-export-destructuring/index.js'),
5244+
);
5245+
let res = await run(b);
5246+
assert.deepEqual(res, {foo: 1, bar: 2});
5247+
});
5248+
52415249
it('should support export default declarations', async function () {
52425250
let b = await bundle(
52435251
path.join(__dirname, 'integration/js-export-default/index.js'),

packages/core/integration-tests/test/output-formats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ describe('output formats', function () {
10601060
.find(bundle => bundle.name.startsWith('async'));
10611061
assert(
10621062
new RegExp(
1063-
`getBundleURL\\("[a-zA-Z0-9]+"\\) \\+ "` +
1063+
`getBundleURL\\('[a-zA-Z0-9]+'\\) \\+ "` +
10641064
path.basename(asyncBundle.filePath) +
10651065
'"',
10661066
).test(entry),

packages/core/integration-tests/test/sourcemaps.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ describe('sourcemaps', function () {
12581258
source: input,
12591259
generated: raw,
12601260
str: "console.log('foo')",
1261-
generatedStr: `console.log("foo")`,
1261+
generatedStr: `console.log('foo')`,
12621262
sourcePath,
12631263
});
12641264

@@ -1267,7 +1267,7 @@ describe('sourcemaps', function () {
12671267
source: input,
12681268
generated: raw,
12691269
str: "console.log('bar')",
1270-
generatedStr: `console.log("bar")`,
1270+
generatedStr: `console.log('bar')`,
12711271
sourcePath,
12721272
});
12731273

@@ -1276,7 +1276,7 @@ describe('sourcemaps', function () {
12761276
source: input,
12771277
generated: raw,
12781278
str: "console.log('baz')",
1279-
generatedStr: `console.log("baz")`,
1279+
generatedStr: `console.log('baz')`,
12801280
sourcePath,
12811281
});
12821282

@@ -1285,7 +1285,7 @@ describe('sourcemaps', function () {
12851285
source: input,
12861286
generated: raw,
12871287
str: "console.log('idhf')",
1288-
generatedStr: `console.log("idhf")`,
1288+
generatedStr: `console.log('idhf')`,
12891289
sourcePath,
12901290
});
12911291
});
@@ -1425,7 +1425,7 @@ describe('sourcemaps', function () {
14251425
source: sourceContent,
14261426
generated: raw,
14271427
str: `foo = 'Lorem ipsum`,
1428-
generatedStr: `foo = "Lorem ipsum`,
1428+
generatedStr: `foo = 'Lorem ipsum`,
14291429
sourcePath,
14301430
});
14311431
});

packages/core/integration-tests/test/svg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ describe('svg', function () {
195195
),
196196
);
197197
assert(svg.includes('<script>'));
198-
assert(svg.includes(`console.log("script")`));
198+
assert(svg.includes(`console.log('script')`));
199199
assert(!svg.includes('import '));
200200
});
201201

packages/transformers/js/core/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
crate-type = ["rlib"]
99

1010
[dependencies]
11-
swc_core = { version = "0.89.6", features = [
11+
swc_core = { version = "0.92.4", features = [
1212
"common",
1313
"common_ahash",
1414
"common_sourcemap",
@@ -22,7 +22,9 @@ swc_core = { version = "0.89.6", features = [
2222
"ecma_transforms_proposal",
2323
"ecma_transforms_react",
2424
"ecma_transforms_typescript",
25+
"ecma_utils",
2526
"ecma_visit",
27+
"stacker"
2628
] }
2729
indoc = "1.0.3"
2830
serde = "1.0.123"

0 commit comments

Comments
 (0)