Skip to content

Commit 0a101e2

Browse files
authored
Merge branch 'main' into release/1.6.0-beta
2 parents aac3548 + e259bc7 commit 0a101e2

File tree

155 files changed

+364
-1216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+364
-1216
lines changed

.github/workflows/reusable-build-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
- name: Build wasm32-wasip1-threads with linux in Docker
180180
if: ${{ inputs.target == 'wasm32-wasip1-threads' && inputs.profile != 'release' }}
181181
run: |
182-
DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads BROWSER=1 pnpm build:binding:${{ inputs.profile }}
182+
DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads RSPACK_TARGET_BROWSER=1 pnpm build:binding:${{ inputs.profile }}
183183
DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads pnpm build:binding:${{ inputs.profile }}
184184
185185
# WASM Release (use profile = release-wasi) + wasm-opt

crates/node_binding/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"build:release": "node scripts/build.js --profile release",
2424
"build:dev:wasm": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads node scripts/build.js",
2525
"build:release:wasm": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads node scripts/build.js --profile release-wasi",
26-
"build:dev:browser": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads BROWSER=1 node scripts/build.js",
27-
"build:release:browser": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads BROWSER=1 node scripts/build.js --profile release-wasi",
26+
"build:dev:browser": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads RSPACK_TARGET_BROWSER=1 node scripts/build.js",
27+
"build:release:browser": "DISABLE_PLUGIN=1 RUST_TARGET=wasm32-wasip1-threads RSPACK_TARGET_BROWSER=1 node scripts/build.js --profile release-wasi",
2828
"move-binding": "node scripts/move-binding",
2929
"test": "tsc -p tsconfig.type-test.json"
3030
},

crates/node_binding/scripts/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function build() {
6161
args.push("--no-default-features");
6262
features.push("plugin");
6363
}
64-
if (process.env.BROWSER) {
64+
if (process.env.RSPACK_TARGET_BROWSER) {
6565
features.push("browser")
6666
// Strip debug format to reduce wasm size of @rspack/browser
6767
rustflags.push("-Zfmt-debug=none");
@@ -138,7 +138,7 @@ async function build() {
138138
);
139139

140140
// For browser wasm, we rename the artifacts to distinguish them from node wasm
141-
if (process.env.BROWSER) {
141+
if (process.env.RSPACK_TARGET_BROWSER) {
142142
renameSync("rspack.wasm32-wasi.debug.wasm", "rspack.browser.debug.wasm")
143143
renameSync("rspack.wasm32-wasi.wasm", "rspack.browser.wasm")
144144
}

packages/rspack-test-tools/etc/test-tools.api.md

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ export class BasicCaseCreator<T extends ECompilerType> {
6565
// @public (undocumented)
6666
export function checkChunkModules(statsJson: any, chunkModulesMap: any, strict?: boolean): boolean;
6767

68-
// @public (undocumented)
69-
export function checkChunkRuntime(statsJson: any, chunkModulesMap: any, strict?: boolean): boolean;
70-
7168
// @public (undocumented)
7269
export function compareContent(sourceContent: string | false, distContent: string | false, compareOptions: ICompareOptions): TCompareResult;
7370

@@ -117,16 +114,16 @@ export function createHashCase(name: string, src: string, dist: string): void;
117114
export function createHookCase(name: string, src: string, dist: string, source: string): void;
118115

119116
// @public (undocumented)
120-
export function createHotCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
117+
export function createHotCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
121118

122119
// @public (undocumented)
123-
export function createHotIncrementalCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
120+
export function createHotIncrementalCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
124121

125122
// @public (undocumented)
126123
export function createHotNormalCase(name: string, src: string, dist: string): void;
127124

128125
// @public (undocumented)
129-
export function createHotStepCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
126+
export function createHotStepCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
130127

131128
// @public (undocumented)
132129
export function createMultiCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
@@ -176,32 +173,6 @@ export class DiffComparator {
176173
compare(): Promise<void>;
177174
}
178175

179-
// @public (undocumented)
180-
export class DiffHtmlReporter implements ITestReporter<TModuleCompareResult[]> {
181-
constructor(options: IDiffHtmlReporterOptions);
182-
// (undocumented)
183-
failure(id: string): Promise<void>;
184-
// (undocumented)
185-
increment(id: string, data: TModuleCompareResult[]): Promise<void>;
186-
// (undocumented)
187-
init(data?: TModuleCompareResult[]): Promise<void>;
188-
// (undocumented)
189-
output(): Promise<void>;
190-
}
191-
192-
// @public (undocumented)
193-
export class DiffStatsReporter implements ITestReporter<TModuleCompareResult[]> {
194-
constructor(options: IDiffStatsReporterOptions);
195-
// (undocumented)
196-
failure(id: string): Promise<void>;
197-
// (undocumented)
198-
increment(id: string, data: TModuleCompareResult[]): Promise<void>;
199-
// (undocumented)
200-
init(data?: TModuleCompareResult[]): Promise<void>;
201-
// (undocumented)
202-
output(): Promise<void>;
203-
}
204-
205176
// @public (undocumented)
206177
export enum ECompareResultType {
207178
// (undocumented)
@@ -328,26 +299,6 @@ export interface IDiffComparatorOptions {
328299
webpackDist: string;
329300
}
330301

331-
// @public (undocumented)
332-
export interface IDiffHtmlReporterOptions {
333-
// (undocumented)
334-
dist: string;
335-
// (undocumented)
336-
ignore?: RegExp;
337-
}
338-
339-
// @public (undocumented)
340-
export interface IDiffStatsReporterOptions {
341-
// (undocumented)
342-
file: string;
343-
// (undocumented)
344-
footer?: string[];
345-
// (undocumented)
346-
header?: string[];
347-
// (undocumented)
348-
report?: boolean;
349-
}
350-
351302
// @public (undocumented)
352303
export interface IFormatCodeOptions {
353304
// (undocumented)
@@ -704,12 +655,6 @@ class RspackTestDiff {
704655
value: string;
705656
}
706657

707-
// @public (undocumented)
708-
export type TCaseSummary = Record<TCaseSummaryId, number>;
709-
710-
// @public (undocumented)
711-
export type TCaseSummaryId = `${TCompilerTypeId}|${TModuleTypeId}|${TDimenTypeId}`;
712-
713658
// @public (undocumented)
714659
export type TCompareModules = string[] | true;
715660

@@ -768,9 +713,6 @@ export type TCompilerStats<T> = T extends ECompilerType.Rspack ? Stats : Stats_2
768713
// @public (undocumented)
769714
export type TCompilerStatsCompilation<T> = T extends ECompilerType.Rspack ? StatsCompilation : StatsCompilation_2;
770715

771-
// @public (undocumented)
772-
export type TCompilerTypeId = ECompilerType.Rspack | ECompilerType.Webpack | "common";
773-
774716
// @public (undocumented)
775717
export type TConfigCaseConfig = Omit<TTestConfig<ECompilerType.Rspack>, "validate">;
776718

@@ -804,9 +746,6 @@ export type TDiffStatsItem = {
804746
type: ECompareResultType;
805747
};
806748

807-
// @public (undocumented)
808-
export type TDimenTypeId = "modules" | "lines" | "lines-in-common";
809-
810749
// @public (undocumented)
811750
export type TErrorCaseConfig = {
812751
description: string;
@@ -917,9 +856,6 @@ export type TModuleObject = {
917856
exports: unknown;
918857
};
919858

920-
// @public (undocumented)
921-
export type TModuleTypeId = "normal" | "runtime";
922-
923859
// @public (undocumented)
924860
export type TMultiCompilerCaseConfig = {
925861
description: string;

packages/rspack-test-tools/src/case/hot-step.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import {
1010
type ITestEnv,
1111
type TCompilerOptions,
1212
type TCompilerStats,
13-
type TCompilerStatsCompilation,
14-
type THotUpdateContext
13+
type TCompilerStatsCompilation
1514
} from "../type";
1615
import { getCompiler } from "./common";
1716
import { createHotProcessor, createHotRunner } from "./hot";
@@ -75,8 +74,13 @@ const creators: Map<
7574
BasicCaseCreator<ECompilerType.Rspack>
7675
> = new Map();
7776

78-
function createHotStepProcessor(name: string, target: TTarget) {
79-
const processor = createHotProcessor(name, target);
77+
function createHotStepProcessor(
78+
name: string,
79+
src: string,
80+
temp: string,
81+
target: TTarget
82+
) {
83+
const processor = createHotProcessor(name, src, temp, target);
8084
const entries: Record<string, string[]> = {};
8185
const hashes: string[] = [];
8286

@@ -107,9 +111,9 @@ function createHotStepProcessor(name: string, target: TTarget) {
107111
const changedFiles: string[] =
108112
step === 0
109113
? []
110-
: processor.hotUpdateContext.changedFiles.map((i: string) =>
111-
escapeSep(path.relative(context.getSource(), i))
112-
);
114+
: processor.updatePlugin
115+
.getModifiedFiles()
116+
.map((i: string) => escapeSep(path.relative(temp, i)));
113117
changedFiles.sort();
114118

115119
const resultHashes: Record<string, string> = {
@@ -330,7 +334,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
330334
name,
331335
"hotUpdateStepChecker",
332336
(
333-
hotUpdateContext: THotUpdateContext,
337+
updateIndex: number,
334338
stats: TCompilerStats<ECompilerType.Rspack>,
335339
runtime: THotStepRuntimeData
336340
) => {
@@ -359,7 +363,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
359363
matchStepSnapshot(
360364
env,
361365
context,
362-
hotUpdateContext.updateIndex,
366+
updateIndex,
363367
compilerOptions,
364368
statsJson,
365369
runtime
@@ -371,7 +375,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
371375
name,
372376
"hotUpdateStepErrorChecker",
373377
(
374-
_: THotUpdateContext,
378+
updateIndex: number,
375379
stats: TCompilerStats<ECompilerType.Rspack>,
376380
runtime: THotStepRuntimeData
377381
) => {
@@ -428,8 +432,13 @@ function getCreator(target: TTarget) {
428432
clean: true,
429433
describe: false,
430434
target,
431-
steps: ({ name, target }) => [
432-
createHotStepProcessor(name, target as TTarget)
435+
steps: ({ name, target, src, temp, dist }) => [
436+
createHotStepProcessor(
437+
name,
438+
src,
439+
temp || path.resolve(dist, "temp"),
440+
target as TTarget
441+
)
433442
],
434443
runner: {
435444
key: (context: ITestContext, name: string, file: string) => name,
@@ -446,8 +455,9 @@ export function createHotStepCase(
446455
name: string,
447456
src: string,
448457
dist: string,
458+
temp: string,
449459
target: TCompilerOptions<ECompilerType.Rspack>["target"]
450460
) {
451461
const creator = getCreator(target);
452-
creator.create(name, src, dist);
462+
creator.create(name, src, dist, temp);
453463
}

0 commit comments

Comments
 (0)