build: Update swc_core
to v0.86.40
and update turbopack (#57904)
### What? * https://github.com/vercel/turbo/pull/6286 * https://github.com/vercel/turbo/pull/6367 * https://github.com/vercel/turbo/pull/6354 * https://github.com/vercel/turbo/pull/6343 --- - Update `swc_core` to `v0.86.40` - Revert #56281 and fix `node-fetch` by disabling inlining - Use `inline: 2` instead of `keep_fnames: true` ### Why? `keep_fnames` increases the bundle size too much. ### How? - Fixes #56612 - Fixes #57886 - Fixes #55682 (by https://github.com/swc-project/swc/pull/8205) - Reverts #56281 - Closes PACK-1902
This commit is contained in:
parent
da0f2ea11a
commit
c370c179b5
8 changed files with 305 additions and 227 deletions
478
Cargo.lock
generated
478
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -33,18 +33,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.86.10", features = [
|
||||
swc_core = { version = "0.86.40", features = [
|
||||
"ecma_loader_lru",
|
||||
"ecma_loader_parking_lot",
|
||||
] }
|
||||
testing = { version = "0.35.0" }
|
||||
testing = { version = "0.35.7" }
|
||||
|
||||
# Turbo crates
|
||||
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231106.2" }
|
||||
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231107.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-231106.2" }
|
||||
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231107.2" }
|
||||
# [TODO]: need to refactor embed_directory! macro usage in next-core
|
||||
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231106.2" }
|
||||
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231107.2" }
|
||||
|
||||
# General Deps
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ turbopack-binding = { workspace = true, features = [
|
|||
"__swc_transform_modularize_imports",
|
||||
"__swc_transform_relay",
|
||||
] }
|
||||
react_remove_properties = "0.5.0"
|
||||
remove_console = "0.6.0"
|
||||
react_remove_properties = "0.10.0"
|
||||
remove_console = "0.11.0"
|
||||
|
||||
[dev-dependencies]
|
||||
turbopack-binding = { workspace = true, features = [
|
||||
|
|
|
@ -31,8 +31,9 @@ use fxhash::FxHashMap;
|
|||
use napi::bindgen_prelude::*;
|
||||
use serde::Deserialize;
|
||||
use turbopack_binding::swc::core::{
|
||||
base::{try_with_handler, TransformOutput},
|
||||
base::{config::JsMinifyOptions, try_with_handler, BoolOrDataConfig, TransformOutput},
|
||||
common::{errors::ColorConfig, sync::Lrc, FileName, SourceFile, SourceMap, GLOBALS},
|
||||
ecma::minifier::option::terser::{TerserCompressorOptions, TerserInlineOption},
|
||||
};
|
||||
|
||||
use crate::{get_compiler, util::MapErr};
|
||||
|
@ -100,6 +101,16 @@ impl Task for MinifyTask {
|
|||
}
|
||||
}
|
||||
|
||||
/// `inline: 3` breaks some codes.
|
||||
///
|
||||
/// https://github.com/vercel/next.js/pull/57904
|
||||
fn patch_opts(opts: &mut JsMinifyOptions) {
|
||||
opts.compress = BoolOrDataConfig::from_obj(TerserCompressorOptions {
|
||||
inline: Some(TerserInlineOption::Num(2)),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn minify(
|
||||
input: Buffer,
|
||||
|
@ -107,7 +118,8 @@ pub fn minify(
|
|||
signal: Option<AbortSignal>,
|
||||
) -> napi::Result<AsyncTask<MinifyTask>> {
|
||||
let code = serde_json::from_slice(&input)?;
|
||||
let opts = serde_json::from_slice(&opts)?;
|
||||
let mut opts = serde_json::from_slice(&opts)?;
|
||||
patch_opts(&mut opts);
|
||||
|
||||
let c = get_compiler();
|
||||
|
||||
|
@ -119,7 +131,8 @@ pub fn minify(
|
|||
#[napi]
|
||||
pub fn minify_sync(input: Buffer, opts: Buffer) -> napi::Result<TransformOutput> {
|
||||
let code: MinifyTarget = serde_json::from_slice(&input)?;
|
||||
let opts = serde_json::from_slice(&opts)?;
|
||||
let mut opts = serde_json::from_slice(&opts)?;
|
||||
patch_opts(&mut opts);
|
||||
|
||||
let c = get_compiler();
|
||||
|
||||
|
|
|
@ -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-231106.2",
|
||||
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2",
|
||||
"acorn": "8.5.0",
|
||||
"amphtml-validator": "1.0.35",
|
||||
"anser": "1.4.9",
|
||||
|
|
|
@ -166,12 +166,7 @@ export class TerserPlugin {
|
|||
}
|
||||
: {}),
|
||||
compress: true,
|
||||
// This is the same option as terser
|
||||
mangle: {
|
||||
toplevel: true,
|
||||
keep_classnames: true,
|
||||
keep_fnames: true,
|
||||
},
|
||||
mangle: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -1065,8 +1065,8 @@ importers:
|
|||
specifier: 0.22.6
|
||||
version: 0.22.6
|
||||
'@vercel/turbopack-ecmascript-runtime':
|
||||
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231106.2
|
||||
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231106.2(react-refresh@0.12.0)(webpack@5.86.0)'
|
||||
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2
|
||||
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2(react-refresh@0.12.0)(webpack@5.86.0)'
|
||||
acorn:
|
||||
specifier: 8.5.0
|
||||
version: 8.5.0
|
||||
|
@ -24646,9 +24646,9 @@ packages:
|
|||
/zwitch@2.0.4:
|
||||
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
||||
|
||||
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231106.2(react-refresh@0.12.0)(webpack@5.86.0)':
|
||||
resolution: {registry: https://registry.npmjs.org/, tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231106.2}
|
||||
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231106.2'
|
||||
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2(react-refresh@0.12.0)(webpack@5.86.0)':
|
||||
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2}
|
||||
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231107.2'
|
||||
name: '@vercel/turbopack-ecmascript-runtime'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
|
|
@ -167,7 +167,7 @@ describe('Application Export Intent Output', () => {
|
|||
|
||||
it('should build and export', async () => {
|
||||
const result = await nextBuild(appDir, [], { stderr: true })
|
||||
expect(result.stderr).toMatch('A.getInitialProps()')
|
||||
expect(result.stderr).toMatch('.getInitialProps()')
|
||||
expect(result.code).toBe(1)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue