Skip to content
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
717 changes: 331 additions & 386 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,25 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }

# SWC crates
swc_core = { version = "30.1.1", features = [
swc_core = { version = "34", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
"parallel_rayon",
] }
testing = { version = "14.0.0" }
testing = "15.0.0"

# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.19.0" }
browserslist-rs = "0.19.0"
mdxjs = "1.0.3"
modularize_imports = { version = "0.90.0" }
styled_components = { version = "0.118.0" }
styled_jsx = { version = "0.94.0" }
swc_emotion = { version = "0.94.0" }
swc_relay = { version = "0.64.0" }
modularize_imports = "0.93.0"
styled_components = "0.121.0"
styled_jsx = "0.97.0"
swc_emotion = "0.97.0"
swc_relay = "0.67.0"
react_remove_properties = "0.47.0"
remove_console = "0.48.0"
preset_env_base = "5.0.0"


# General Deps
chromiumoxide = { version = "0.5.4", features = [
Expand Down Expand Up @@ -439,6 +443,6 @@ webbrowser = "0.8.7"

[patch.crates-io]
hyper = { git = "https://github.com/bgw/hyper-rs.git", branch = "v1.6.0-with-macos-intel-miscompilation-workaround" }
mdxjs = { git = "https://github.com/mischnic/mdxjs-rs.git", branch = "swc-core-32" }
lightningcss = { git = "https://github.com/parcel-bundler/lightningcss.git", branch = "mischnic/bump-browserslist" }
mdxjs = { git = "https://github.com/kdy1/mdxjs-rs.git", branch = "swc-core-30" }
parcel_selectors = { git = "https://github.com/parcel-bundler/lightningcss.git", branch = "mischnic/bump-browserslist" }
1 change: 1 addition & 0 deletions crates/napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ swc_core = { workspace = true, features = [
"ecma_ast",
"ecma_ast_serde",
"ecma_codegen",
"ecma_helpers_inline",
"ecma_loader_lru",
"ecma_loader_node",
"ecma_minifier",
Expand Down
18 changes: 17 additions & 1 deletion crates/napi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ static ALLOC: dhat::Alloc = dhat::Alloc;
#[cfg(not(target_arch = "wasm32"))]
#[napi::module_init]
fn init() {
use std::panic::{set_hook, take_hook};
use std::{
cell::RefCell,
panic::{set_hook, take_hook},
time::{Duration, Instant},
};

thread_local! {
static LAST_SWC_ATOM_GC_TIME: RefCell<Option<Instant>> = const { RefCell::new(None) };
}

use tokio::runtime::Builder;
use turbo_tasks::panic_hooks::handle_panic;
Expand All @@ -87,6 +95,14 @@ fn init() {
.on_thread_stop(|| {
TurboMalloc::thread_stop();
})
.on_thread_park(|| {
LAST_SWC_ATOM_GC_TIME.with_borrow_mut(|cell| {
if cell.is_none_or(|t| t.elapsed() > Duration::from_secs(2)) {
swc_core::ecma::atoms::hstr::global_atom_store_gc();
*cell = Some(Instant::now());
}
});
})
.disable_lifo_slot()
.build()
.unwrap();
Expand Down
13 changes: 13 additions & 0 deletions crates/next-api/benches/hmr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
cell::RefCell,
fs::{create_dir_all, write},
mem::forget,
path::{Path, PathBuf},
Expand Down Expand Up @@ -154,11 +155,23 @@ fn load_next_config() -> RcStr {
}

fn runtime() -> Runtime {
thread_local! {
static LAST_SWC_ATOM_GC_TIME: RefCell<Option<Instant>> = const { RefCell::new(None) };
}

tokio::runtime::Builder::new_multi_thread()
.enable_all()
.on_thread_stop(|| {
turbo_tasks_malloc::TurboMalloc::thread_stop();
})
.on_thread_park(|| {
LAST_SWC_ATOM_GC_TIME.with_borrow_mut(|cell| {
if cell.is_none_or(|t| t.elapsed() > Duration::from_secs(2)) {
swc_core::ecma::atoms::hstr::global_atom_store_gc();
*cell = Some(Instant::now());
}
});
})
.build()
.context("Failed to build tokio runtime")
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions crates/next-build-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ next-api = { workspace = true }
next-core = { workspace = true }
num_cpus = "1.16.0"
rand = { workspace = true, features = ["small_rng"] }
swc_core = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tokio-stream = "0.1.15"
Expand Down
18 changes: 17 additions & 1 deletion crates/next-build-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{convert::Infallible, str::FromStr, time::Instant};
use std::{
cell::RefCell,
convert::Infallible,
str::FromStr,
time::{Duration, Instant},
};

use next_api::project::{DefineEnv, ProjectOptions};
use next_build_test::{Strategy, main_inner};
Expand Down Expand Up @@ -70,12 +75,23 @@ fn main() {
factor = 1;
}

thread_local! {
static LAST_SWC_ATOM_GC_TIME: RefCell<Option<Instant>> = const { RefCell::new(None) };
}
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.on_thread_stop(|| {
TurboMalloc::thread_stop();
tracing::debug!("threads stopped");
})
.on_thread_park(|| {
LAST_SWC_ATOM_GC_TIME.with_borrow_mut(|cell| {
if cell.is_none_or(|t| t.elapsed() > Duration::from_secs(2)) {
swc_core::ecma::atoms::hstr::global_atom_store_gc();
*cell = Some(Instant::now());
}
});
})
.build()
.unwrap()
.block_on(async {
Expand Down
4 changes: 2 additions & 2 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ futures = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
rustc-hash = { workspace = true }
react_remove_properties = "0.44.0"
remove_console = "0.45.0"
react_remove_properties = { workspace = true }
remove_console = { workspace = true }
itertools = { workspace = true }
percent-encoding = "2.3.1"
serde_path_to_error = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/next-custom-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ turbopack-ecmascript-plugins = { workspace = true, optional = true }
turbo-rcstr = { workspace = true }
urlencoding = { workspace = true }

react_remove_properties = "0.44.0"
remove_console = "0.45.0"
preset_env_base = "4.0.0"
react_remove_properties = { workspace = true }
remove_console = { workspace = true }
preset_env_base = { workspace = true }

[dev-dependencies]
swc_core = { workspace = true, features = ["testing_transform"] }
Expand Down
23 changes: 12 additions & 11 deletions packages/next/src/build/swc/generated-native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ export interface NapiWatchOptions {
}
export interface NapiProjectOptions {
/**
* An absolute root path from which all files must be nested under. Trying to access
* a file outside this root will fail, so think of this as a chroot.
* An absolute root path (Unix or Windows path) from which all files must be nested under.
* Trying to access a file outside this root will fail, so think of this as a chroot.
* E.g. `/home/user/projects/my-repo`.
*/
rootPath: RcStr
/**
* A path which contains the app/pages directories, relative to [`Project::root_path`].
* E.g. `apps/my-app`
* A path which contains the app/pages directories, relative to [`Project::root_path`], always
* Unix path. E.g. `apps/my-app`
*/
projectPath: RcStr
/**
* A path where to emit the build outputs, relative to [`Project::project_path`].
* Corresponds to next.config.js's `distDir`.
* A path where to emit the build outputs, relative to [`Project::project_path`], always Unix
* path. Corresponds to next.config.js's `distDir`.
* E.g. `.next`
*/
distDir: RcStr
Expand Down Expand Up @@ -151,19 +151,20 @@ export interface NapiProjectOptions {
/** [NapiProjectOptions] with all fields optional. */
export interface NapiPartialProjectOptions {
/**
* An absolute root path from which all files must be nested under. Trying to access
* a file outside this root will fail, so think of this as a chroot.
* An absolute root path (Unix or Windows path) from which all files must be nested under.
* Trying to access a file outside this root will fail, so think of this as a chroot.
* E.g. `/home/user/projects/my-repo`.
*/
rootPath?: RcStr
/**
* A path which contains the app/pages directories, relative to [`Project::root_path`].
* A path which contains the app/pages directories, relative to [`Project::root_path`], always
* a Unix path.
* E.g. `apps/my-app`
*/
projectPath?: RcStr
/**
* A path where to emit the build outputs, relative to [`Project::project_path`].
* Corresponds to next.config.js's `distDir`.
* A path where to emit the build outputs, relative to [`Project::project_path`], always a
* Unix path. Corresponds to next.config.js's `distDir`.
* E.g. `.next`
*/
distDir?: RcStr | undefined | null
Expand Down
30 changes: 15 additions & 15 deletions test/development/acceptance-app/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/server/page.js (2:27)
"source": "./app/server/page.js (2:26)
Parsing ecmascript source code failed
> 2 | return <p>Hello world</p>
| ^",
| ^",
"stack": [],
}
`)
Expand All @@ -160,7 +160,7 @@ describe('Error recovery app', () => {
,-[2:1]
1 | export default function Page() {
2 | return <p>Hello world</p>
: ^
: ^
\`----
Caused by:
Syntax Error
Expand Down Expand Up @@ -206,10 +206,10 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/client/page.js (2:27)
"source": "./app/client/page.js (2:26)
Parsing ecmascript source code failed
> 2 | return <p>Hello world</p>
| ^",
| ^",
"stack": [],
}
`)
Expand All @@ -224,7 +224,7 @@ describe('Error recovery app', () => {
,-[2:1]
1 | export default function Page() {
2 | return <p>Hello world</p>
: ^
: ^
\`----
Caused by:
Syntax Error
Expand Down Expand Up @@ -619,10 +619,10 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (10:41)
"source": "./index.js (10:39)
Parsing ecmascript source code failed
> 10 | export default function FunctionNamed() {
| ^",
| ^",
"stack": [],
}
`)
Expand All @@ -636,7 +636,7 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>'
,-[10:1]
10 | export default function FunctionNamed() {
: ^
: ^
\`----
Caused by:
Syntax Error
Expand All @@ -656,10 +656,10 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (10:41)
"source": "./index.js (10:39)
Parsing ecmascript source code failed
> 10 | export default function FunctionNamed() {
| ^",
| ^",
"stack": [],
}
`)
Expand All @@ -673,7 +673,7 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>'
,-[10:1]
10 | export default function FunctionNamed() {
: ^
: ^
\`----
Caused by:
Syntax Error
Expand Down Expand Up @@ -1012,10 +1012,10 @@ describe('Error recovery app', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (1:3)
"source": "./app/page.js (1:2)
Parsing ecmascript source code failed
> 1 | {{{
| ^",
| ^",
"stack": [],
}
`)
Expand All @@ -1029,7 +1029,7 @@ describe('Error recovery app', () => {
Error: x Expected '}', got '<eof>'
,----
1 | {{{
: ^
: ^
\`----
Caused by:
Syntax Error",
Expand Down
12 changes: 6 additions & 6 deletions test/development/acceptance/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,10 +840,10 @@ describe('pages/ error recovery', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (7:41)
"source": "./index.js (7:39)
Parsing ecmascript source code failed
> 7 | export default function FunctionNamed() {
| ^",
| ^",
"stack": [],
}
`)
Expand Down Expand Up @@ -886,7 +886,7 @@ describe('pages/ error recovery', () => {
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
: ^
\`----
Caused by:
Syntax Error
Expand All @@ -908,10 +908,10 @@ describe('pages/ error recovery', () => {
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js (7:41)
"source": "./index.js (7:39)
Parsing ecmascript source code failed
> 7 | export default function FunctionNamed() {
| ^",
| ^",
"stack": [],
}
`)
Expand Down Expand Up @@ -954,7 +954,7 @@ describe('pages/ error recovery', () => {
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
: ^
\`----
Caused by:
Syntax Error
Expand Down
2 changes: 1 addition & 1 deletion test/integration/custom-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Custom _error', () => {
await retry(async () => {
// retry because the page might not be built yet
const html = await renderViaHTTP(appPort, '/404')
expect(html).toContain('Unexpected token')
expect(html).toContain('Unexpected eof')
expect(stderr).not.toMatch(customErrNo404Match)
})
} finally {
Expand Down
Loading
Loading