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

Update swc_core to v0.83.12 #55216

Merged
merged 31 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
539 changes: 390 additions & 149 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ next-transform-dynamic = { path = "packages/next-swc/crates/next-transform-dynam
next-transform-strip-page-exports = { path = "packages/next-swc/crates/next-transform-strip-page-exports" }

# SWC crates
swc_core = { version = "=0.79.55", features = ["ecma_loader_lru", "ecma_loader_parking_lot"] }
testing = { version = "0.33.21" }
swc_core = { version = "0.83.12", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "0.34.1" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230914.5" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230914.5" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230914.5" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }

# General Deps

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"@picocss/pico": "1.5.10",
"@svgr/webpack": "5.5.0",
"@swc/cli": "0.1.55",
"@swc/core": "1.3.55",
"@swc/helpers": "0.5.1",
"@swc/core": "1.3.85",
"@swc/helpers": "0.5.2",
"@testing-library/jest-dom": "6.1.2",
"@testing-library/react": "13.0.0",
"@types/cheerio": "0.22.16",
Expand Down
5 changes: 3 additions & 2 deletions packages/next-swc/crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct TransformOptions {
pub server_components: Option<react_server_components::Config>,

#[serde(default)]
pub styled_jsx: bool,
pub styled_jsx: Option<turbopack_binding::swc::custom_transform::styled_jsx::visitor::Config>,

#[serde(default)]
pub styled_components:
Expand Down Expand Up @@ -202,11 +202,12 @@ where
)),
_ => Either::Right(noop()),
},
if opts.styled_jsx {
if let Some(config) = opts.styled_jsx {
Either::Left(
turbopack_binding::swc::custom_transform::styled_jsx::visitor::styled_jsx(
cm.clone(),
file.name.clone(),
config,
),
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/src/optimize_barrel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl Fold for OptimizeBarrel {
.into(),
raw: None,
}),
asserts: None,
with: None,
type_only: false,
})));
}
Expand Down
6 changes: 3 additions & 3 deletions packages/next-swc/crates/core/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
raw: None,
}),
type_only: false,
asserts: None,
with: None,
})));
}

Expand Down Expand Up @@ -1001,7 +1001,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
raw: None,
}),
type_only: false,
asserts: None,
with: None,
})));
new.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt {
span: DUMMY_SP,
Expand Down Expand Up @@ -1076,7 +1076,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
raw: None,
}),
type_only: false,
asserts: None,
with: None,
})));
// Make it the first item
new.rotate_right(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/tests/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn test(input: &Path, minify: bool) {
is_server: false,
server_components: None,
styled_components: Some(assert_json("{}")),
styled_jsx: true,
styled_jsx: Some(assert_json("{}")),
remove_console: None,
react_remove_properties: None,
relay: None,
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/tests/full/example/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ import t from "other";
}())[0];
export var __N_SSG = !0;
export default function e() {
return React.createElement("div", null);
return /*#__PURE__*/ React.createElement("div", null);
}
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230914.5",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230914.5",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230915.2",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230915.2",
"anser": "^2.1.1",
"css.escape": "^1.5.1",
"next": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ error - [rendering] [root of the server]/invalid Error during SSR Rendering
at defaultLoader (packages/next/dist/shared/lib/image-loader.js:41:27)
37 | process.env.NEXT_RUNTIME !== "edge") {
38 | // We use dynamic require because this should only error in development
39 | const { hasMatch } = require("./match-remote-pattern");
39 | const { hasMatch } = require("./match-remote-pattern");
40 | if (!hasMatch(config.domains, config.remotePatterns, parsedSrc)) {
| v
41 + throw new Error("Invalid src prop (" + src + ') on `next/image`, hostname "' + parsedSrc.hostname + '" i...xt.config.js`\n' + "See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host");
Expand All @@ -18,7 +18,7 @@ error - [rendering] [root of the server]/invalid Error during SSR Rendering
45 | }

at <unknown> (packages/next/dist/shared/lib/get-img-props.js:101:36)
97 | const { widths , kind } = getWidths(config, width, sizes);
97 | const { widths, kind } = getWidths(config, width, sizes);
98 | const last = widths.length - 1;
99 | return {
100 | sizes: !sizes && kind === "w" ? "100vw" : sizes,
Expand All @@ -31,7 +31,7 @@ error - [rendering] [root of the server]/invalid Error during SSR Rendering
105 | width: w

at generateImgAttrs (packages/next/dist/shared/lib/get-img-props.js:101:24)
97 | const { widths , kind } = getWidths(config, width, sizes);
97 | const { widths, kind } = getWidths(config, width, sizes);
98 | const last = widths.length - 1;
99 | return {
100 | sizes: !sizes && kind === "w" ? "100vw" : sizes,
Expand All @@ -44,4 +44,4 @@ error - [rendering] [root of the server]/invalid Error during SSR Rendering
105 | width: w

at getImgProps (packages/next/dist/shared/lib/get-img-props.js:392:27)
at <unknown> (packages/next/dist/client/image-component.js:275:82)
at <unknown> (packages/next/dist/client/image-component.js:275:80)
8 changes: 4 additions & 4 deletions packages/next-swc/crates/next-transform-dynamic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl NextDynamicPatcher {
],
src: Box::new(specifier.into()),
type_only: false,
asserts: None,
with: None,
})));
}
TurbopackImport::DevelopmentId {
Expand All @@ -506,7 +506,7 @@ impl NextDynamicPatcher {
})],
src: Box::new(specifier.into()),
type_only: false,
asserts: None,
with: None,
})));
}
TurbopackImport::BuildTransition {
Expand Down Expand Up @@ -535,7 +535,7 @@ impl NextDynamicPatcher {
})],
src: Box::new(specifier.into()),
type_only: false,
asserts: None,
with: None,
})));
}
TurbopackImport::BuildId {
Expand All @@ -561,7 +561,7 @@ impl NextDynamicPatcher {
})],
src: Box::new(specifier.into()),
type_only: false,
asserts: None,
with: None,
})));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> FontImportsGenerator<'a> {
}),
specifiers: vec![],
type_only: false,
asserts: None,
with: None,
span: DUMMY_SP,
});
}
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<'a> Visit for FontImportsGenerator<'a> {
})],
src: None,
type_only: false,
asserts: None,
with: None,
}),
));
}
Expand Down
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
"dependencies": {
"@next/env": "13.4.20-canary.31",
"@swc/helpers": "0.5.1",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
Expand Down Expand Up @@ -193,7 +193,7 @@
"@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0",
"@vercel/nft": "0.22.6",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230914.5",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230915.2",
"acorn": "8.5.0",
"ajv": "8.11.0",
"amphtml-validator": "1.0.35",
Expand Down
5 changes: 3 additions & 2 deletions packages/next/src/build/swc/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function getBaseSWCOptions({
externalHelpers: !process.versions.pnp && !jest,
parser: parserConfig,
experimental: {
keepImportAssertions: true,
keepImportAttributes: true,
emitAssertForImportAttributes: true,
plugins,
cacheRoot: swcCacheDir,
},
Expand Down Expand Up @@ -162,7 +163,7 @@ function getBaseSWCOptions({
: undefined,
relay: compilerOptions?.relay,
// Always transform styled-jsx and error when `client-only` condition is triggered
styledJsx: true,
styledJsx: {},
// Disable css-in-js libs (without client-only integration) transform on server layer for server components
...(!isServerLayer && {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
Expand Down
Loading