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
10 changes: 2 additions & 8 deletions e2e/watch/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ describe.skipIf(process.platform === 'win32')('watch', () => {

await cli.waitForStdout('Duration');
expect(cli.stdout).toMatch('Tests 2 passed');
// Updated as the shared module `src/index.ts` is extracted into another chunk.
expect(cli.stdout).toMatch(
/Test files to re-run.*:\n.*bar\.test\.ts\n.*index\.test\.ts\n\n/,
);
expect(cli.stdout).toMatch(/Test files to re-run.*:\n.*bar\.test\.ts\n\n/);

// update
cli.resetStd();
Expand All @@ -70,11 +67,8 @@ describe.skipIf(process.platform === 'win32')('watch', () => {
cli.resetStd();
fs.delete('./fixtures-test-0/bar.test.ts');
await cli.waitForStdout('Duration');
expect(cli.stdout).toMatch('No test files need re-run.');
expect(cli.stdout).toMatch('Test Files 1 passed');
// Updated as extracting the shared module `src/index.ts` is into another chunk in reverted.
expect(cli.stdout).toMatch(
/Test files to re-run.*:\n.*index\.test\.ts\n\n/,
);

cli.exec.kill();
});
Expand Down
21 changes: 19 additions & 2 deletions packages/core/src/core/plugins/mockRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,26 @@ class MockRuntimeRspackPlugin {
}
}

compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation) => {
compiler.hooks.compilation.tap('RstestMockPlugin', (compilation) => {
compilation.hooks.runtimeModule.tap(
'RstestMockChunkLoadingRuntimePlugin',
(module) => {
if (module.name === 'require_chunk_loading') {
const finalSource = module.source!.source.toString('utf-8').replace(
// Hard coded in EJS template https://github.com/web-infra-dev/rspack/blob/5b89b0b9810f15c6bd6494b9a3389db3071d93d1/crates/rspack_plugin_runtime/src/runtime_module/runtime/require_chunk_loading.ejs.
'for (var moduleId in moreModules) {',
'for (var moduleId in moreModules) {\n' +
'\t\tif (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;',
);
module.source!.source = Buffer.from(finalSource);
}
},
);
});

compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation) => {
compilation.hooks.additionalTreeRuntimeRequirements.tap(
'CustomPlugin',
'RstestAddMockRuntimePlugin',
(chunk) => {
compilation.addRuntimeModule(chunk, new RetestImportRuntimeModule());
},
Expand Down
19 changes: 11 additions & 8 deletions packages/core/src/core/plugins/moduleCacheControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
}
}

compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation) => {
compilation.hooks.additionalTreeRuntimeRequirements.tap(
'CustomPlugin',
(chunk) => {
compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
},
);
});
compiler.hooks.thisCompilation.tap(
'RstestCacheControlPlugin',
(compilation) => {
compilation.hooks.additionalTreeRuntimeRequirements.tap(
'RstestAddCacheControlRuntimePlugin',
(chunk) => {
compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
},
);
},
);
}
}

Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/core/rsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
logger as RsbuildLogger,
type RsbuildPlugin,
type Rspack,
rspack,
} from '@rsbuild/core';
import path from 'pathe';
import type {
Expand Down Expand Up @@ -284,10 +283,6 @@ export const createRsbuildServer = async ({
name: 'rstest:compiler',
setup: (api) => {
api.modifyBundlerChain((chain) => {
chain
.plugin('RemoveDuplicateModulesPlugin')
.use(rspack.experiments.RemoveDuplicateModulesPlugin);

// add mock-loader to this rule
chain.module
.rule('rstest-mock-module-doppelgangers')
Expand Down
Loading