-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: hmr failed when adding initial chunk (#2743)
- Loading branch information
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
e2e/cases/lazy-compilation/add-initial-chunk/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { dev, gotoPage, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect } from '@playwright/test'; | ||
|
||
// https://github.com/web-infra-dev/rspack/issues/6633 | ||
rspackOnlyTest( | ||
'should render pages correctly when using lazy compilation and add new initial chunk', | ||
async ({ page }) => { | ||
const rsbuild = await dev({ | ||
cwd: __dirname, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
await expect(page.locator('#test')).toHaveText('Hello World!'); | ||
|
||
rsbuild.close(); | ||
}, | ||
); |
41 changes: 41 additions & 0 deletions
41
e2e/cases/lazy-compilation/add-initial-chunk/rsbuild.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginReact()], | ||
source: { | ||
entry: { | ||
index: './src/index.js', | ||
}, | ||
}, | ||
tools: { | ||
rspack(config) { | ||
config.output ??= {}; | ||
config.output.asyncChunks = false; | ||
}, | ||
}, | ||
performance: { | ||
chunkSplit: { | ||
strategy: 'custom', | ||
override: { | ||
chunks: 'all', | ||
cacheGroups: { | ||
lib: { | ||
enforce: true, | ||
test: /(initial\.js|core-js)/, | ||
name: 'lib', | ||
chunks: 'all', | ||
}, | ||
default: false, | ||
defaultVendors: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
dev: { | ||
lazyCompilation: true, | ||
}, | ||
output: { | ||
polyfill: 'usage', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import x from './initial'; | ||
import 'core-js'; | ||
|
||
const ele = document.createElement('div'); | ||
ele.innerHTML = `Hello ${x}`; | ||
ele.setAttribute('id', 'test'); | ||
document.body.append(ele); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'core-js/package.json'; | ||
|
||
export default 'World!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters