Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .vitrine-hooks/pre-merge-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
echo "error: merge is not allowed in task worktrees" >&2
exit 1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 0 additions & 7 deletions LICENSES-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ Component,Origin,Licence,Copyright
@jridgewell/trace-mapping,npm,MIT,Justin Ridgewell (https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping)
@kwsites/file-exists,npm,MIT,Steve King (https://www.npmjs.com/package/@kwsites/file-exists)
@kwsites/promise-deferred,npm,MIT,Steve King (https://www.npmjs.com/package/@kwsites/promise-deferred)
@module-federation/error-codes,npm,MIT,zhanghang (https://www.npmjs.com/package/@module-federation/error-codes)
@module-federation/runtime,npm,MIT,zhouxiao (https://www.npmjs.com/package/@module-federation/runtime)
@module-federation/runtime-core,npm,MIT,zhouxiao (https://www.npmjs.com/package/@module-federation/runtime-core)
@module-federation/runtime-tools,npm,MIT,zhanghang (https://www.npmjs.com/package/@module-federation/runtime-tools)
@module-federation/sdk,npm,MIT,zhanghang (https://www.npmjs.com/package/@module-federation/sdk)
@module-federation/webpack-bundler-runtime,npm,MIT,zhanghang (https://www.npmjs.com/package/@module-federation/webpack-bundler-runtime)
@mswjs/interceptors,npm,MIT,Artem Zakharchenko (https://www.npmjs.com/package/@mswjs/interceptors)
@nodelib/fs.scandir,npm,MIT,(https://www.npmjs.com/package/@nodelib/fs.scandir)
@nodelib/fs.stat,npm,MIT,(https://www.npmjs.com/package/@nodelib/fs.stat)
Expand All @@ -198,7 +192,6 @@ Component,Origin,Licence,Copyright
@rspack/binding-darwin-arm64,npm,MIT,(https://rspack.rs)
@rspack/binding-darwin-x64,npm,MIT,(https://rspack.rs)
@rspack/core,virtual,MIT,(https://rspack.rs)
@rspack/lite-tapable,npm,MIT,(https://www.npmjs.com/package/@rspack/lite-tapable)
@samverschueren/stream-to-observable,virtual,MIT,(https://www.npmjs.com/package/@samverschueren/stream-to-observable)
@simple-git/args-pathspec,npm,MIT,(https://www.npmjs.com/package/@simple-git/args-pathspec)
@simple-git/argv-parser,npm,MIT,(https://www.npmjs.com/package/@simple-git/argv-parser)
Expand Down
2 changes: 1 addition & 1 deletion packages/published/rspack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@babel/parser": "^7.24.5",
"@babel/traverse": "^7.24.5",
"@babel/types": "^7.24.5",
"@rspack/core": "1.x",
"@rspack/core": "1.x || 2.x",
"magic-string": "^0.30.0"
},
"peerDependenciesMeta": {
Expand Down
3 changes: 3 additions & 0 deletions packages/tests/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const config: JestConfigWithTsJest = {
clearMocks: true,
globalSetup: '<rootDir>/src/_jest/globalSetup.ts',
roots: ['<rootDir>/../'],
// @rspack/core v2 is pure ESM; use a custom resolver to load it via a .cjs shim
// so Jest's CJS mode can require() it without triggering ERR_REQUIRE_ESM.
resolver: '<rootDir>/src/_jest/rspack-jest-resolver.cjs',
setupFilesAfterEnv: ['<rootDir>/src/_jest/setupAfterEnv.ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.*'],
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"ts-jest": "29.4.0"
},
"devDependencies": {
"@rspack/core": "1.4.9",
"@rspack/core": "2.0.8",
"@types/faker": "5.5.9",
"@types/jest": "^29",
"@types/node": "^20",
Expand Down
26 changes: 26 additions & 0 deletions packages/tests/src/_jest/rspack-cjs-shim.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* CJS shim for @rspack/core v2 (which is pure ESM).
*
* @rspack/core v2 is a pure ESM package. Jest's CJS module runtime cannot
* require() it directly when --experimental-vm-modules is active (because
* shouldLoadAsEsm() returns true for packages with "type":"module", causing
* Jest to throw ERR_REQUIRE_ESM before reaching its transformer).
*
* This shim is resolved by the Jest custom resolver (rspack-jest-resolver.cjs)
* for any require('@rspack/core') call. It re-exports rspack using Node's
* createRequire(), which bypasses Jest's module interception entirely and
* uses Node's native loader that supports require(esm) in Node >=20.17.
*
* The shim file uses the .cjs extension so that shouldLoadAsEsm() returns
* false unconditionally, bypassing the ESM guard in Jest's requireModule().
*/

const { createRequire } = require('module');

// Create a require function anchored to this file's location.
// Unlike module.require (which Jest patches), createRequire() returns Node's
// native loader function, allowing it to load ESM packages via require(esm).
const nativeRequire = createRequire(__filename);
const rspack = nativeRequire('@rspack/core');

module.exports = rspack;
23 changes: 23 additions & 0 deletions packages/tests/src/_jest/rspack-jest-resolver.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Custom Jest resolver that maps @rspack/core to a CJS-compatible shim.
*
* @rspack/core v2 is a pure ESM package. Jest's CJS module runtime cannot
* require() it directly when --experimental-vm-modules is active (because
* shouldLoadAsEsm() returns true for packages with "type":"module", causing
* Jest to throw ERR_REQUIRE_ESM before reaching its transformer).
*
* This resolver intercepts require('@rspack/core') and returns the path to
* rspack-cjs-shim.cjs instead. The .cjs extension makes shouldLoadAsEsm()
* return false unconditionally, allowing Jest to load the module normally.
* The shim itself uses Node's native Module._load to load the real rspack
* (Node >=20.17 supports require(esm) natively).
*/

const path = require('path');

module.exports = (request, options) => {
if (request === '@rspack/core') {
return path.resolve(__dirname, 'rspack-cjs-shim.cjs');
}
return options.defaultResolver(request, options);
};
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@inquirer/select": "2.3.3",
"@rollup/plugin-commonjs": "28.0.1",
"@rollup/plugin-node-resolve": "15.3.0",
"@rspack/core": "1.4.9",
"@rspack/core": "2.0.8",
"chalk": "2.3.1",
"clipanion": "4.0.0-rc.3",
"esbuild": "0.25.8",
Expand Down
9 changes: 5 additions & 4 deletions packages/tools/src/bundlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ export const configXpack = (config: BundlerConfig): Configuration & RspackOption
const baseConfig: Configuration & RspackOptions = {
context: config.workingDir,
entry,
experiments: {
css: true,
},
mode: 'none',
output: {
path: config.outDir,
Expand Down Expand Up @@ -226,7 +223,11 @@ export const configXpack = (config: BundlerConfig): Configuration & RspackOption
extensions: ['.tsx', '.ts', '.js'],
};
baseConfig.module = {
rules: [{ test: /\.([cm]?ts|tsx)$/, loader: 'ts-loader' }],
rules: [
{ test: /\.([cm]?ts|tsx)$/, loader: 'ts-loader' },
// rspack v2 requires explicit CSS type rule (experiments.css was removed)
{ test: /\.css$/, type: 'css' },
],
};

return baseConfig;
Expand Down
Loading