-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-react): allow to disable fast refresh (#3738)
- Loading branch information
1 parent
d635625
commit 897ba03
Showing
11 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
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,44 @@ | ||
import fs from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { dev, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
const cwd = __dirname; | ||
|
||
rspackOnlyTest( | ||
'HMR should work when Fast Refresh is disabled', | ||
async ({ page }) => { | ||
// HMR cases will fail in Windows | ||
if (process.platform === 'win32') { | ||
test.skip(); | ||
} | ||
|
||
await fs.promises.cp(join(cwd, 'src'), join(cwd, 'test-temp-src'), { | ||
recursive: true, | ||
}); | ||
|
||
const rsbuild = await dev({ | ||
cwd, | ||
page, | ||
rsbuildConfig: { | ||
source: { | ||
entry: { | ||
index: join(cwd, 'test-temp-src/index.ts'), | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const locator = page.locator('#test'); | ||
await expect(locator).toHaveText('Hello Rsbuild!'); | ||
await expect(locator).toHaveCSS('color', 'rgb(255, 0, 0)'); | ||
|
||
const appPath = join(cwd, 'test-temp-src/App.tsx'); | ||
await fs.promises.writeFile( | ||
appPath, | ||
fs.readFileSync(appPath, 'utf-8').replace('Hello Rsbuild', 'Hello Test'), | ||
); | ||
await expect(locator).toHaveText('Hello Test!'); | ||
await rsbuild.close(); | ||
}, | ||
); |
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,10 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginReact({ | ||
fastRefresh: false, | ||
}), | ||
], | ||
}); |
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 @@ | ||
#test { | ||
color: rgb(255, 0, 0); | ||
} |
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,4 @@ | ||
import './App.css'; | ||
|
||
const App = () => <div id="test">Hello Rsbuild!</div>; | ||
export default App; |
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,9 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
|
||
const container = document.getElementById('root'); | ||
if (container) { | ||
const root = createRoot(container); | ||
root.render(React.createElement(App)); | ||
} |
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,9 @@ | ||
{ | ||
"extends": "@rsbuild/config/tsconfig", | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"baseUrl": "./", | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
} |
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
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
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
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
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