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
1 change: 1 addition & 0 deletions .github/externals-loading-webpack-plugin.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ applyTo: "packages/webpack/externals-loading-webpack-plugin/**"
---

Keep `ExternalsLoadingPlugin` focused on consuming finalized `externals` maps and generating runtime loading code. Do not bake project-specific preset expansion or filesystem-backed dev serving into this low-level plugin; those concerns belong in higher-level Rsbuild integrations such as `pluginExternalBundle`. It is acceptable for this low-level plugin to resolve a relative `bundlePath` against the runtime `publicPath`, because that stays within generic bundler/runtime behavior instead of Rspeedy-specific URL inference.
When migrating this package's config-case tests to `@rspack/test-tools`, preserve the existing two-bundle coverage by using `test/configCases/**` with `test.config.js` files whose `findBundle()` returns both emitted entry bundles, typically `['main:main-thread.js', 'main:background.js']`, instead of collapsing coverage to a single bundle.
1 change: 1 addition & 0 deletions .github/webpack-rstest-migration.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ applyTo: "packages/webpack/**/*"
---

When migrating webpack package tests from Vitest to Rstest, define `setupFiles` in `rstest.config.ts` via `createRequire(import.meta.url).resolve(...)` instead of bare package subpaths to avoid module resolution issues.
When migrating webpack package config cases from `test/**/cases/**` to `test/**/configCases/**`, keep root ESLint ignores aligned so config-case fixtures continue to be treated like other harness-owned case files instead of suddenly failing generic `no-undef` and `import/no-unresolved` rules.
For ESM case config files (`*.config.js` under package tests), prefer explicit ESM-safe imports (for example `../../../../lib/index.js`) and use `createRequire(import.meta.url)` plus `new URL('.', import.meta.url).pathname` when `require.resolve` or `__dirname` behavior is needed.
If hot-snapshot cases report incomplete update steps after migration, run targeted snapshot refresh with `rstest -u` on the specific `HotSnapshot.test` filter before broad reruns.
When shared `@lynx-js/test-tools` helpers are migrated to read test APIs from `globalThis`, keep `globals: true` in Vitest configs for still-Vitest suites that consume those helpers (for example webpack react/css-extract plugin suites).
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default tseslint.config(
'packages/rspeedy/create-rspeedy/template-*/**',
'packages/i18n/**/tests/fixtures/**',
'packages/{rspeedy,webpack}/*/test/**/cases/**',
'packages/{rspeedy,webpack}/*/test/**/configCases/**',
'packages/{rspeedy,webpack}/*/test/**/hotCases/**',
'packages/{rspeedy,webpack}/*/test/**/diagnostic/**',
'packages/{rspeedy,webpack}/*/test/**/fixtures/**',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
"test": "rstest"
},
"devDependencies": {
"@lynx-js/test-tools": "workspace:*",
"@rspack/core": "catalog:rspack",
"@rspack/test-tools": "catalog:rspack",
"@rspack/test-tools": "1.7.9",
"@rstest/core": "catalog:rstest",
"bar": "./test/helpers/external-bundle-mock/bar",
"baz": "./test/helpers/external-bundle-mock/baz",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { defineConfig } from '@rstest/core';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const require = createRequire(import.meta.url);

const config: Parameters<typeof defineConfig>[0] = {
Expand All @@ -15,6 +19,10 @@ const config: Parameters<typeof defineConfig>[0] = {
require.resolve('@rspack/test-tools/setup-expect'),
require.resolve('./test/helpers/setup-env.js'),
],
env: {
__TEST_PATH__: path.resolve(__dirname),
__TEST_DIST_PATH__: path.resolve(__dirname, 'test', 'js'),
},
};

const rstestConfig: ReturnType<typeof defineConfig> = defineConfig(config);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { fileURLToPath } from 'node:url';

import { createNormalCase, describeByWalk } from '@rspack/test-tools';

const __filename = fileURLToPath(import.meta.url);

describeByWalk(__filename, (name, src, dist) => {
createNormalCase(name, src, dist);
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { add } from 'foo';

const consoleInfoMock = rstest.spyOn(console, 'info').mockImplementation(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import x from 'foo';
import x2 from 'foo2';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import x from 'foo';

console.info(x);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { add } from 'foo';
import { minus } from 'bar';
import { mul } from 'baz/sub1';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { a } from 'pkg-a';
import { b } from 'pkg-b';
import { c } from 'pkg-c';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import lodash from 'lodash';
import x from 'foo';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { add } from 'foo';

const consoleInfoMock = rstest.spyOn(console, 'info').mockImplementation(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { add } from 'foo';

const consoleInfoMock = rstest.spyOn(console, 'info').mockImplementation(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="@rspack/test-tools/rstest" />

import { add } from '@lynx-js/foo';

const consoleInfoMock = rstest.spyOn(console, 'info').mockImplementation(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const externalsGlobalSymbol = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');

export function beforeExecute() {
if (lynx[externalsGlobalSymbol]) {
delete lynx[externalsGlobalSymbol];
}
}

export function findBundle() {
return ['main:main-thread.js', 'main:background.js'];
}
20 changes: 2 additions & 18 deletions pnpm-lock.yaml

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

Loading