-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): sourcemap incorrect warning and classic runtime sourcemap (…
- Loading branch information
1 parent
da7c3ae
commit bdae7fa
Showing
9 changed files
with
104 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
console.log('App.jsx 1') // for sourcemap | ||
function App() { | ||
return <div>foo</div> | ||
} | ||
|
||
console.log('App.jsx 2') // for sourcemap | ||
|
||
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,7 @@ | ||
import { isBuild, serverLogs } from '~utils' | ||
|
||
test.runIf(isBuild)('should not output sourcemap warning', () => { | ||
serverLogs.forEach((log) => { | ||
expect(log).not.toMatch('Sourcemap is likely to be incorrect') | ||
}) | ||
}) |
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,2 @@ | ||
<div id="app"></div> | ||
<script type="module" src="main.jsx"></script> |
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 ReactDOM from 'react-dom/client' | ||
import App from './App.jsx' | ||
|
||
ReactDOM.createRoot(document.getElementById('app')).render( | ||
React.createElement(App) | ||
) | ||
|
||
console.log('main.jsx') // for sourcemap |
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,21 @@ | ||
{ | ||
"name": "test-react-sourcemap", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"dev:classic": "cross-env USE_CLASSIC=1 vite", | ||
"build": "vite build", | ||
"build:classic": "cross-env USE_CLASSIC=1 vite build", | ||
"debug": "node --inspect-brk ../../packages/vite/bin/vite", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-react": "workspace:*", | ||
"cross-env": "^7.0.3" | ||
} | ||
} |
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,15 @@ | ||
import react from '@vitejs/plugin-react' | ||
import type { UserConfig } from 'vite' | ||
|
||
const config: UserConfig = { | ||
plugins: [ | ||
react({ | ||
jsxRuntime: process.env.USE_CLASSIC === '1' ? 'classic' : 'automatic' | ||
}) | ||
], | ||
build: { | ||
sourcemap: true | ||
} | ||
} | ||
|
||
export default config |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Also thank you!