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
11 changes: 6 additions & 5 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ impl Compiler {
),
);
match self.cache.before_compile(&mut self.compilation).await {
Ok(is_hot) => {
if is_hot {
// If it's a hot start, we can use incremental
self.compilation.incremental = Incremental::new_hot(self.options.experiments.incremental);
}
Ok(_is_hot) => {
// TODO: disable it for now, enable it once persistent cache is added to all artifacts
// if is_hot {
// // If it's a hot start, we can use incremental
// self.compilation.incremental = Incremental::new_hot(self.options.experiments.incremental);
// }
}
Err(err) => self.compilation.push_diagnostic(err.into()),
}
Expand Down
16 changes: 8 additions & 8 deletions packages/rspack-test-tools/etc/test-tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export function createHookCase(name: string, src: string, dist: string, source:
export function createHotCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;

// @public (undocumented)
export function createHotNewIncrementalCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
export function createHotIncrementalCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;

// @public (undocumented)
export function createHotStepCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
Expand All @@ -280,7 +280,7 @@ export function createTreeShakingCase(name: string, src: string, dist: string):
export function createWatchCase(name: string, src: string, dist: string, temp: string): void;

// @public (undocumented)
export function createWatchNewIncrementalCase(name: string, src: string, dist: string, temp: string, options?: WatchNewIncrementalOptions): void;
export function createWatchIncrementalCase(name: string, src: string, dist: string, temp: string, options?: WatchIncrementalOptions): void;

// @public (undocumented)
export class DefaultsConfigProcessor<T extends ECompilerType> extends SimpleTaskProcessor<T> {
Expand Down Expand Up @@ -532,14 +532,14 @@ export class HookTaskProcessor<T extends ECompilerType> extends SnapshotProcesso
}

// @public (undocumented)
export class HotNewIncrementalProcessor<T extends ECompilerType> extends HotProcessor<T> {
constructor(_hotOptions: IHotNewIncrementalProcessorOptions<T>);
export class HotIncrementalProcessor<T extends ECompilerType> extends HotProcessor<T> {
constructor(_hotOptions: IHotIncrementalProcessorOptions<T>);
// (undocumented)
afterAll(context: ITestContext): Promise<void>;
// (undocumented)
static defaultOptions<T extends ECompilerType>(this: HotNewIncrementalProcessor<T>, context: ITestContext): TCompilerOptions<T>;
static defaultOptions<T extends ECompilerType>(this: HotIncrementalProcessor<T>, context: ITestContext): TCompilerOptions<T>;
// (undocumented)
protected _hotOptions: IHotNewIncrementalProcessorOptions<T>;
protected _hotOptions: IHotIncrementalProcessorOptions<T>;
// (undocumented)
run(env: ITestEnv, context: ITestContext): Promise<void>;
}
Expand Down Expand Up @@ -895,7 +895,7 @@ export interface IHookProcessorOptions<T extends ECompilerType> extends ISnapsho
}

// @public (undocumented)
export interface IHotNewIncrementalProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
export interface IHotIncrementalProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
// (undocumented)
target: TCompilerOptions<T>["target"];
// (undocumented)
Expand Down Expand Up @@ -1665,7 +1665,7 @@ export type TUpdateOptions = {
};

// @public (undocumented)
export type WatchNewIncrementalOptions = {
export type WatchIncrementalOptions = {
ignoreNotFriendlyForIncrementalWarnings?: boolean;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "node:fs";
import path from "node:path";

import { HotNewIncrementalProcessor } from "../processor/hot-new-incremental";
import { HotIncrementalProcessor } from "../processor/hot-incremental";
import { WatchProcessor, WatchStepProcessor } from "../processor/watch";
import { HotRunnerFactory, WatchRunnerFactory } from "../runner";
import { BasicCaseCreator } from "../test/creator";
Expand All @@ -24,7 +24,7 @@ function getHotCreator(target: TTarget, webpackCases: boolean) {
describe: true,
target,
steps: ({ name, target }) => [
new HotNewIncrementalProcessor({
new HotIncrementalProcessor({
name,
target: target as TTarget,
compilerType: ECompilerType.Rspack,
Expand All @@ -40,7 +40,7 @@ function getHotCreator(target: TTarget, webpackCases: boolean) {
return hotCreators.get(key)!;
}

export function createHotNewIncrementalCase(
export function createHotIncrementalCase(
name: string,
src: string,
dist: string,
Expand All @@ -56,11 +56,11 @@ const watchCreators: Map<
BasicCaseCreator<ECompilerType.Rspack>
> = new Map();

export type WatchNewIncrementalOptions = {
export type WatchIncrementalOptions = {
ignoreNotFriendlyForIncrementalWarnings?: boolean;
};

function getWatchCreator(options: WatchNewIncrementalOptions) {
function getWatchCreator(options: WatchIncrementalOptions) {
const key = JSON.stringify(options);
if (!watchCreators.has(key)) {
watchCreators.set(
Expand Down Expand Up @@ -128,12 +128,12 @@ function getWatchCreator(options: WatchNewIncrementalOptions) {
return watchCreators.get(key)!;
}

export function createWatchNewIncrementalCase(
export function createWatchIncrementalCase(
name: string,
src: string,
dist: string,
temp: string,
options: WatchNewIncrementalOptions = {}
options: WatchIncrementalOptions = {}
) {
const creator = getWatchCreator(options);
creator.create(name, src, dist, temp);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export * from "./stats-api";
export * from "./stats-output";
export * from "./treeshaking";
export * from "./watch";
export * from "./new-incremental";
export * from "./incremental";
export * from "./cache";
export * from "./serial";
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {
import type { IBasicProcessorOptions } from "./basic";
import { HotProcessor } from "./hot";

export interface IHotNewIncrementalProcessorOptions<T extends ECompilerType>
export interface IHotIncrementalProcessorOptions<T extends ECompilerType>
extends Omit<IBasicProcessorOptions<T>, "runable"> {
target: TCompilerOptions<T>["target"];
webpackCases: boolean;
}

export class HotNewIncrementalProcessor<
export class HotIncrementalProcessor<
T extends ECompilerType
> extends HotProcessor<T> {
constructor(protected _hotOptions: IHotNewIncrementalProcessorOptions<T>) {
constructor(protected _hotOptions: IHotIncrementalProcessorOptions<T>) {
super({
defaultOptions: HotNewIncrementalProcessor.defaultOptions,
defaultOptions: HotIncrementalProcessor.defaultOptions,
..._hotOptions
});
}
Expand All @@ -46,7 +46,7 @@ export class HotNewIncrementalProcessor<
}

static defaultOptions<T extends ECompilerType>(
this: HotNewIncrementalProcessor<T>,
this: HotIncrementalProcessor<T>,
context: ITestContext
): TCompilerOptions<T> {
const options = super.defaultOptions<T>(context);
Expand All @@ -55,9 +55,7 @@ export class HotNewIncrementalProcessor<
rspackOptions.experiments ??= {};
rspackOptions.experiments.incremental ??= "advance-silent";
} else {
throw new Error(
"HotNewIncrementalProcessor should only used for Rspack."
);
throw new Error("HotIncrementalProcessor should only used for Rspack.");
}
return options;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/rspack-test-tools/src/processor/hot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export class HotProcessor<T extends ECompilerType> extends BasicProcessor<T> {
target: this._hotOptions.target,
experiments: {
css: true,
// test incremental: "safe" here, we test default incremental in Incremental-*.test.js
incremental: "safe",
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export * from "./error";
export * from "./hash";
export * from "./hook";
export * from "./hot";
export * from "./hot-new-incremental";
export * from "./hot-incremental";
export * from "./hot-step";
export * from "./multi";
export * from "./normal";
Expand Down
4 changes: 4 additions & 0 deletions packages/rspack-test-tools/src/processor/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ export class WatchProcessor<
(
options as TCompilerOptions<ECompilerType.Rspack>
).experiments!.rspackFuture!.bundlerInfo!.force ??= false;
// test incremental: "safe" here, we test default incremental in Incremental-*.test.js
(
options as TCompilerOptions<ECompilerType.Rspack>
).experiments!.incremental ??= "safe";

if (!global.printLogger) {
options.infrastructureLogging = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
const path = require("path");
const {
describeByWalk,
createHotNewIncrementalCase
createHotIncrementalCase
} = require("@rspack/test-tools");

function v(name) {
return path.join(__dirname, `new-incremental ${name}`);
return path.join(__dirname, `incremental ${name}`);
}

// Run tests rspack-test-tools/tests/hotCases in target async-node
describeByWalk(
v("hot async-node"),
(name, src, dist) => {
createHotNewIncrementalCase(name, src, dist, "async-node", false);
createHotIncrementalCase(name, src, dist, "async-node", false);
},
{
source: path.resolve(__dirname, "./hotCases"),
dist: path.resolve(__dirname, `./js/new-incremental/hot-async-node`),
dist: path.resolve(__dirname, `./js/incremental/hot-async-node`),
exclude: [/^css$/]
}
);
Expand All @@ -28,13 +28,13 @@ describeByWalk(
describeByWalk(
v("hot async-node (webpack-test)"),
(name, src, dist) => {
createHotNewIncrementalCase(name, src, dist, "async-node", true);
createHotIncrementalCase(name, src, dist, "async-node", true);
},
{
source: path.resolve(__dirname, "../../../tests/webpack-test/hotCases"),
dist: path.resolve(
__dirname,
`./js/new-incremental/webpack-test/hot-async-node`
`./js/incremental/webpack-test/hot-async-node`
),
exclude: [/require-disposed-module-warning/]
}
Expand All @@ -44,11 +44,11 @@ describeByWalk(
describeByWalk(
v("hot node (webpack-test)"),
(name, src, dist) => {
createHotNewIncrementalCase(name, src, dist, "node", true);
createHotIncrementalCase(name, src, dist, "node", true);
},
{
source: path.resolve(__dirname, "../../../tests/webpack-test/hotCases"),
dist: path.resolve(__dirname, `./js/new-incremental/webpack-test/hot-node`),
dist: path.resolve(__dirname, `./js/incremental/webpack-test/hot-node`),
exclude: [/require-disposed-module-warning/]
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
const path = require("path");
const {
describeByWalk,
createWatchNewIncrementalCase
createWatchIncrementalCase
} = require("@rspack/test-tools");

function v(name) {
return path.join(__dirname, `new-incremental ${name}`);
return path.join(__dirname, `incremental ${name}`);
}

// Run tests webpack-test/watchCases
Expand All @@ -17,14 +17,14 @@ describeByWalk(
(name, src, dist) => {
const tempDir = path.resolve(
__dirname,
`./js/new-incremental/webpack-test/temp`
`./js/incremental/webpack-test/temp`
);
createWatchNewIncrementalCase(name, src, dist, path.join(tempDir, name), {
createWatchIncrementalCase(name, src, dist, path.join(tempDir, name), {
ignoreNotFriendlyForIncrementalWarnings: true
});
},
{
source: path.resolve(__dirname, "../../../tests/webpack-test/watchCases"),
dist: path.resolve(__dirname, `./js/new-incremental/webpack-test/watch`)
dist: path.resolve(__dirname, `./js/incremental/webpack-test/watch`)
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
const path = require("path");
const {
describeByWalk,
createWatchNewIncrementalCase
createWatchIncrementalCase
} = require("@rspack/test-tools");

function v(name) {
return path.join(__dirname, `new-incremental ${name}`);
return path.join(__dirname, `incremental ${name}`);
}

// Run tests rspack-test-tools/tests/watchCases
describeByWalk(
v("watch"),
(name, src, dist) => {
const tempDir = path.resolve(__dirname, `./js/new-incremental/temp`);
createWatchNewIncrementalCase(name, src, dist, path.join(tempDir, name));
const tempDir = path.resolve(__dirname, `./js/incremental/temp`);
createWatchIncrementalCase(name, src, dist, path.join(tempDir, name));
},
{
source: path.resolve(__dirname, "./watchCases"),
dist: path.resolve(__dirname, `./js/new-incremental/watch`)
dist: path.resolve(__dirname, `./js/incremental/watch`)
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
const path = require("path");
const {
describeByWalk,
createHotNewIncrementalCase
createHotIncrementalCase
} = require("@rspack/test-tools");

function v(name) {
return path.join(__dirname, `new-incremental ${name}`);
return path.join(__dirname, `incremental ${name}`);
}

// Run tests rspack-test-tools/tests/hotCases in target web
describeByWalk(
v("hot web"),
(name, src, dist) => {
createHotNewIncrementalCase(name, src, dist, "web", false);
createHotIncrementalCase(name, src, dist, "web", false);
},
{
source: path.resolve(__dirname, "./hotCases"),
dist: path.resolve(__dirname, `./js/new-incremental/hot-web`)
dist: path.resolve(__dirname, `./js/incremental/hot-web`)
}
);

// Run tests webpack-test/hotCases in target web
describeByWalk(
v("hot web (webpack-test)"),
(name, src, dist) => {
createHotNewIncrementalCase(name, src, dist, "web", true);
createHotIncrementalCase(name, src, dist, "web", true);
},
{
source: path.resolve(__dirname, "../../../tests/webpack-test/hotCases"),
dist: path.resolve(__dirname, `./js/new-incremental/webpack-test/hot-web`),
dist: path.resolve(__dirname, `./js/incremental/webpack-test/hot-web`),
exclude: [
// there is a self reference module in this case causing the make phase didn't found the module is removed
/require-disposed-module-warning/
Expand Down
Loading
Loading