Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
57b7654
init next-rspack-binding
SyMind Aug 20, 2025
7841dc3
chore: take next-rspack out crago workspace
SyMind Aug 27, 2025
3d4f6df
can build rspack package
SyMind Aug 27, 2025
e3083fb
share NEVER_EXTERNAL_RE
SyMind Aug 28, 2025
8ef6aae
reuse EDGE_NODE_EXTERNALS
SyMind Aug 28, 2025
4aff8fc
refactor get_edge_polyfilled_modules
SyMind Aug 28, 2025
36f687b
use std::async::OnceLock
SyMind Aug 28, 2025
5d22a7b
cargo fmt
SyMind Aug 28, 2025
e09194d
refactor code
SyMind Aug 28, 2025
132f0ef
reuse NODE_EXTERNALS and BUN_EXTERNALS
SyMind Aug 28, 2025
0d2b27d
rm BARREL_OPTIMIZATION_PREFIX
SyMind Aug 28, 2025
5867752
fix: rm dead code
SyMind Aug 28, 2025
69d9435
fix
SyMind Aug 28, 2025
9869699
fix ast-grep
SyMind Aug 28, 2025
0bbfa5b
prettier
SyMind Aug 28, 2025
c617f9c
change dir
SyMind Aug 28, 2025
d2b39c7
change package json
SyMind Aug 28, 2025
635c8dd
rename workflow
SyMind Aug 28, 2025
d3624ef
fix: crago exclude
SyMind Aug 28, 2025
01b6266
fix ci
SyMind Aug 28, 2025
291e1ea
prettier
SyMind Sep 1, 2025
7bfce07
fix: the github ci
SyMind Sep 16, 2025
1890645
change @next-rspack scope
SyMind Sep 17, 2025
bcbcfd2
Merge branch 'canary' into next-rspack-binding
SyMind Sep 17, 2025
f905042
Merge branch 'canary' into next-rspack-binding
SyMind Sep 17, 2025
ae782d2
update uses action
SyMind Sep 17, 2025
0cbedf7
fix: working-directory
SyMind Sep 17, 2025
5295b0a
update dependency
SyMind Sep 17, 2025
2badb46
fix: workflow
SyMind Sep 17, 2025
ebc7f9b
add rust-toolchain
SyMind Sep 17, 2025
6878c02
cargo update
SyMind Sep 17, 2025
7950121
update workflow
SyMind Sep 17, 2025
87fbd17
fix cargo lock
SyMind Sep 17, 2025
6b6a225
ApplyContext
SyMind Sep 17, 2025
db1975e
use patch.crates-io for next-taskless
SyMind Sep 18, 2025
0bfc98a
cargo fmt
SyMind Sep 18, 2025
53f60cc
fix build failed
SyMind Sep 18, 2025
bc65d09
fix: cross bug
SyMind Sep 18, 2025
8afa6dc
update rspack-toolchain
SyMind Sep 18, 2025
f38d5b5
chore: update rspack-contrib
SyMind Sep 18, 2025
acd807e
Merge branch 'canary' into next-rspack-binding
SyMind Sep 18, 2025
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
124 changes: 124 additions & 0 deletions .github/workflows/release-next-rspack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Release next-rspack bindings

on:
workflow_dispatch:
inputs:
dry-run:
description: 'Run in dry-run mode (no actual publishing)'
required: false
default: false
type: boolean
npm-tag:
description: 'NPM tag for publishing'
required: false
default: 'latest'
type: choice
options:
- latest
- alpha
- beta
- canary

env:
DEBUG: napi:*

jobs:
build:
name: Build
uses: rspack-contrib/rspack-toolchain/.github/workflows/build.yml@f69dc04fcae6b38d97b87acef448ed7a285b01cc
with:
package-json-path: rspack/crates/binding/package.json
napi-build-command: pnpm build --release
working-directory: rspack

release:
runs-on: ubuntu-latest
environment: npm
name: Release
permissions:
contents: write
id-token: write
needs: [build]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Display release mode
run: |
echo "🚀 Release Configuration:"
echo " - Dry-run mode: ${{ inputs.dry-run }}"
echo " - NPM tag: ${{ inputs.npm-tag || 'latest' }}"
if [ "${{ inputs.dry-run }}" == "true" ]; then
echo " - ⚠️ This is a DRY RUN - no packages will be published"
else
echo " - 📦 This will PUBLISH packages to npm"
fi

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Enable corepack
run: corepack enable

- name: Setup pnpm
run: corepack prepare

- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pnpm-

- name: Install dependencies
run: pnpm install
working-directory: ./rspack

- name: Get NAPI info
id: napi-info
uses: rspack-contrib/rspack-toolchain/get-napi-info@f69dc04fcae6b38d97b87acef448ed7a285b01cc
with:
package-json-path: rspack/crates/binding/package.json

- name: Download rspack binding
uses: rspack-contrib/rspack-toolchain/download-rspack-binding@f69dc04fcae6b38d97b87acef448ed7a285b01cc
with:
path: ${{ steps.napi-info.outputs.binding-directory }}/artifacts

- name: List artifacts
run: ls -R artifacts
working-directory: ${{ steps.napi-info.outputs.binding-directory }}

- name: Create npm dirs
run: pnpm napi create-npm-dirs
working-directory: ${{ steps.napi-info.outputs.binding-directory }}

- name: Move artifacts
run: pnpm napi artifacts
working-directory: ${{ steps.napi-info.outputs.binding-directory }}

- name: List npm dirs
run: ls -R npm
working-directory: ${{ steps.napi-info.outputs.binding-directory }}

- name: Create npm token
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release npm binding packages
run: |
npm config set access public
npm config set provenance true
pnpm napi pre-publish --no-gh-release -t npm ${{ inputs.dry-run && '--dry-run' || '' }}
working-directory: ${{ steps.napi-info.outputs.binding-directory }}

- name: Release npm packages
run: |
pnpm publish -r --tag ${{ inputs.npm-tag }} --no-git-checks --provenance --access public ${{ inputs.dry-run && '--dry-run' || '' }}
working-directory: ./rspack
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ members = [
"turbopack/xtask",
]

exclude = ["crates/next-error-code-swc-plugin"]
exclude = [
"crates/next-error-code-swc-plugin",
"rspack/crates/binding"
]

[workspace.lints.clippy]
too_many_arguments = "allow"
Expand Down
9 changes: 1 addition & 8 deletions crates/next-core/src/next_server/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::sync::LazyLock;

use anyhow::Result;
use regex::Regex;
use next_taskless::NEVER_EXTERNAL_RE;
use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, trace::TraceRawVcs};
Expand Down Expand Up @@ -101,11 +99,6 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
return Ok(ResolveResultOption::none());
};

// from https://github.com/vercel/next.js/blob/8d1c619ad650f5d147207f267441caf12acd91d1/packages/next/src/build/handle-externals.ts#L188
static NEVER_EXTERNAL_RE: LazyLock<Regex> = LazyLock::new(|| {
Regex::new("^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|cache|document|link|form|head|image|legacy\\/image|constants|dynamic|script|navigation|headers|router|compat\\/router|server)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper$)").unwrap()
});

let (Pattern::Constant(package), Pattern::Constant(package_subpath)) =
(package, package_subpath)
else {
Expand Down
77 changes: 77 additions & 0 deletions crates/next-taskless/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
pub const NODE_EXTERNALS: [&str; 64] = [
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"http2",
"https",
"inspector",
"module",
"net",
"os",
"path",
"path/posix",
"path/win32",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
"timers",
"timers/promises",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
"pnpapi",
"_http_agent",
"_http_client",
"_http_common",
"_http_incoming",
"_http_outgoing",
"_http_server",
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_wrap",
"_stream_writable",
];

pub const EDGE_NODE_EXTERNALS: [&str; 5] = ["buffer", "events", "assert", "util", "async_hooks"];

pub const BUN_EXTERNALS: [&str; 6] = [
"bun:ffi",
"bun:jsc",
"bun:sqlite",
"bun:test",
"bun:wrap",
"bun",
];
5 changes: 5 additions & 0 deletions crates/next-taskless/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#![doc = include_str!("../README.md")]

mod constants;
mod patterns;

use std::sync::LazyLock;

use anyhow::{Context, Result, bail};
pub use constants::*;
pub use patterns::*;
use regex::Regex;
use turbo_unix_path::{get_parent_path, get_relative_path_to, join_path, normalize_path};

Expand Down
8 changes: 8 additions & 0 deletions crates/next-taskless/src/patterns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use std::sync::LazyLock;

use regex::Regex;

// from https://github.com/vercel/next.js/blob/8d1c619ad650f5d147207f267441caf12acd91d1/packages/next/src/build/handle-externals.ts#L188
pub static NEVER_EXTERNAL_RE: LazyLock<Regex> = LazyLock::new(|| {
Regex::new("^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|cache|document|link|form|head|image|legacy\\/image|constants|dynamic|script|navigation|headers|router|compat\\/router|server)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper|private-next-rsc-track-dynamic-import$)").unwrap()
});
1 change: 1 addition & 0 deletions rspack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.node
13 changes: 13 additions & 0 deletions rspack/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
max_width = 100

comment_width = 100
wrap_comments = true

tab_spaces = 4
hard_tabs = false

format_strings = true
use_field_init_shorthand = true

imports_granularity = "Crate"
group_imports = "StdExternalCrate"
Loading
Loading