-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Speed up TypeScript projects #5903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
14ac5f5
8fb9047
4cc09f4
b8bb7c6
174a81a
75400fd
3c85b80
775555f
5dd25e4
7a41d2b
29ca550
68e2f50
0488228
06d769f
117f142
91c76ad
9a8fc4d
321d960
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -106,7 +106,7 @@ function handleSuccess() { | |||||||
tryApplyUpdates(function onHotUpdateSuccess() { | ||||||||
// Only dismiss it when we're sure it's a hot update. | ||||||||
// Otherwise it would flicker right before the reload. | ||||||||
ErrorOverlay.dismissBuildError(); | ||||||||
tryDismissErrorOverlay(); | ||||||||
}); | ||||||||
} | ||||||||
} | ||||||||
|
@@ -140,19 +140,15 @@ function handleWarnings(warnings) { | |||||||
} | ||||||||
} | ||||||||
|
||||||||
printWarnings(); | ||||||||
|
||||||||
// Attempt to apply hot updates or reload. | ||||||||
if (isHotUpdate) { | ||||||||
tryApplyUpdates(function onSuccessfulHotUpdate() { | ||||||||
// Only print warnings if we aren't refreshing the page. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only thing I'm on the fence about, what's the reason for this change? Can you please add the reasoning in the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that we need to print warnings even when there is not update in code. create-react-app/packages/react-dev-utils/webpackHotDevClient.js Lines 235 to 237 in 68e2f50
__webpack_hash__ didn't change.
So, the idea is that we want to print warnings every time they occur. Yes, we can figure out a different way, but this change tries to keep it as simple as possible. |
||||||||
// Otherwise they'll disappear right away anyway. | ||||||||
printWarnings(); | ||||||||
// Only dismiss it when we're sure it's a hot update. | ||||||||
// Otherwise it would flicker right before the reload. | ||||||||
ErrorOverlay.dismissBuildError(); | ||||||||
tryDismissErrorOverlay(); | ||||||||
}); | ||||||||
} else { | ||||||||
// Print initial warnings immediately. | ||||||||
printWarnings(); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
|
@@ -183,6 +179,12 @@ function handleErrors(errors) { | |||||||
// We will reload on next success instead. | ||||||||
} | ||||||||
|
||||||||
function tryDismissErrorOverlay() { | ||||||||
if (!hasCompileErrors) { | ||||||||
ErrorOverlay.dismissBuildError(); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// There is a newer version of the code available. | ||||||||
function handleAvailableHash(hash) { | ||||||||
// Update last known compilation hash. | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const testSetup = require('../__shared__/test-setup'); | ||
const puppeteer = require('puppeteer'); | ||
|
||
const expectedErrorMsg = `Argument of type '123' is not assignable to parameter of type 'string'`; | ||
|
||
test('shows error overlay in browser', async () => { | ||
const { port, done } = await testSetup.scripts.start(); | ||
|
||
const browser = await puppeteer.launch({ headless: true }); | ||
try { | ||
const page = await browser.newPage(); | ||
await page.goto(`http://localhost:${port}/`); | ||
await page.waitForSelector('iframe', { timeout: 5000 }); | ||
const overlayMsg = await page.evaluate(() => { | ||
const overlay = document.querySelector('iframe').contentWindow; | ||
return overlay.document.body.innerHTML; | ||
}); | ||
expect(overlayMsg).toContain(expectedErrorMsg); | ||
} finally { | ||
browser.close(); | ||
done(); | ||
} | ||
}); | ||
|
||
test('shows error in console (dev mode)', async () => { | ||
const { stderr } = await testSetup.scripts.start({ smoke: true }); | ||
expect(stderr).toContain(expectedErrorMsg); | ||
}); | ||
|
||
test('shows error in console (prod mode)', async () => { | ||
const { stderr } = await testSetup.scripts.build(); | ||
expect(stderr).toContain(expectedErrorMsg); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"@types/react": "*", | ||
"@types/react-dom": "*", | ||
"react": "*", | ||
"react-dom": "*", | ||
"typescript": "3.1.3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as React from 'react'; | ||
|
||
class App extends React.Component { | ||
render() { | ||
return <div>{format(123)}</div>; | ||
} | ||
} | ||
|
||
function format(value: string) { | ||
return value; | ||
} | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
Uh oh!
There was an error while loading. Please reload this page.