-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
Get rid of eval #1611
Closed
Closed
Get rid of eval #1611
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a0945c7
Introduce script tag based page loading system.
arunoda 8938843
Call ensurePage only in the dev mode.
arunoda c95d2b2
Implement router using the page-loader.
arunoda e3d68ff
Fix a typo and remove unwanted code.
arunoda 03209d8
Fix some issues related to rendering.
arunoda a1f11a4
Fix production tests.
arunoda 6f65a05
Fix ondemand test cases.
arunoda 57e3a67
Fix unit tests.
arunoda 822a99b
Get rid of eval completely.
arunoda 76bfc38
Remove all the inline code.
arunoda 5aa02d0
Remove the json-pages plugin.
arunoda 32cdf3f
Rename NEXT_PAGE_LOADER into __NEXT_PAGE_LOADER__
arunoda 65a2603
Rename NEXT_LOADED_PAGES into __NEXT_LOADED_PAGES__
arunoda f6f175d
Remove some unwanted code.
arunoda e46edc2
Load everything async.
arunoda 751d2e9
Remove lib/eval-script.js
arunoda 4f26e84
Move webpack idle wait code to the page-loader.
arunoda 866319c
Merge with master.
arunoda 6f9b51f
Remove pageNotFound key from the error.
arunoda b5bd0da
Remove unused error field 'buildError'
arunoda c077ebe
Add much better logic to normalize routes.
arunoda fb2f90b
Get rid of mitt.
arunoda 7997c1f
Introduce a better way to register pages.
arunoda 6e0e7b4
Came back to the mitt() based page-loader.
arunoda 95558ae
Add link rel=preload support.
arunoda 6f735ee
Fix a typo.
arunoda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import next from './' | ||
|
||
next() | ||
.catch((err) => { | ||
console.error(`${err.message}\n${err.stack}`) | ||
}) |
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 |
---|---|---|
@@ -1,48 +1,50 @@ | ||
import webpackHotMiddlewareClient from 'webpack-hot-middleware/client?overlay=false&reload=true' | ||
import Router from '../lib/router' | ||
|
||
const handlers = { | ||
reload (route) { | ||
if (route === '/_error') { | ||
for (const r of Object.keys(Router.components)) { | ||
const { err } = Router.components[r] | ||
if (err) { | ||
// reload all error routes | ||
// which are expected to be errors of '/_error' routes | ||
Router.reload(r) | ||
export default () => { | ||
const handlers = { | ||
reload (route) { | ||
if (route === '/_error') { | ||
for (const r of Object.keys(Router.components)) { | ||
const { err } = Router.components[r] | ||
if (err) { | ||
// reload all error routes | ||
// which are expected to be errors of '/_error' routes | ||
Router.reload(r) | ||
} | ||
} | ||
return | ||
} | ||
return | ||
} | ||
|
||
if (route === '/_document') { | ||
window.location.reload() | ||
return | ||
} | ||
if (route === '/_document') { | ||
window.location.reload() | ||
return | ||
} | ||
|
||
Router.reload(route) | ||
}, | ||
Router.reload(route) | ||
}, | ||
|
||
change (route) { | ||
if (route === '/_document') { | ||
window.location.reload() | ||
return | ||
} | ||
change (route) { | ||
if (route === '/_document') { | ||
window.location.reload() | ||
return | ||
} | ||
|
||
const { err } = Router.components[route] || {} | ||
if (err) { | ||
// reload to recover from runtime errors | ||
Router.reload(route) | ||
const { err } = Router.components[route] || {} | ||
if (err) { | ||
// reload to recover from runtime errors | ||
Router.reload(route) | ||
} | ||
} | ||
} | ||
} | ||
|
||
webpackHotMiddlewareClient.subscribe((obj) => { | ||
const fn = handlers[obj.action] | ||
if (fn) { | ||
const data = obj.data || [] | ||
fn(...data) | ||
} else { | ||
throw new Error('Unexpected action ' + obj.action) | ||
} | ||
}) | ||
webpackHotMiddlewareClient.subscribe((obj) => { | ||
const fn = handlers[obj.action] | ||
if (fn) { | ||
const data = obj.data || [] | ||
fn(...data) | ||
} else { | ||
throw new Error('Unexpected action ' + obj.action) | ||
} | ||
}) | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this matters anymore, but at some point it was considered "bad" to use
delete
since it is hard to optimize by V8 and other compilers. Whenever I seedelete
, usually I think there might be a better way via re-assignment. Obviously not a blocker, just an observationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, delete is not bad. You need to use it wisely. Delete is bad when used inside a constructor. Because that's de-optimization. That's also valid for when we are creating a lot of objects from that class.
We need to use it wisely. And we need to delete when needed. Anyway, it's not needed here and having it also not a problem :)