Skip to content
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

Webpack 4, react-error-overlay, react-loadable (major) #4639

Merged
merged 122 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
f9453bd
Upgrade dependencies
timneutkens Jun 16, 2018
3722ee2
Check if files exist and warn if they don’t
timneutkens Jun 16, 2018
e2b92c9
Initial implementation
timneutkens Jun 20, 2018
320958f
Fix test
timneutkens Jun 21, 2018
0d24bb2
Assets can be loaded using `async` in development too
timneutkens Jun 21, 2018
c38cd28
Fix chunk names
timneutkens Jun 21, 2018
9f29318
Remove uglify as it is automatically applied
timneutkens Jun 21, 2018
aad6d25
Add webpackbar
timneutkens Jun 21, 2018
6a6aa81
Remove plugins that automatically apply via `mode: ‘development’`
timneutkens Jun 21, 2018
9339e2a
Check if Object.values is available as node 6 doesn’t support it
timneutkens Jun 21, 2018
2ccd57c
Add comment explaining the check
timneutkens Jun 21, 2018
3771f5a
Make sure we only require webpackbar when it’s supported (node 7+)
timneutkens Jun 21, 2018
baa1a1b
Read from `global` as babel transforms Object.values
timneutkens Jun 21, 2018
eda13f2
Bring back HMR plugin
timneutkens Jun 26, 2018
a69aae6
Add react-loadable
timneutkens Jun 28, 2018
cfc4880
Fix chunk names and load react-loadable on the client side
timneutkens Jun 29, 2018
08904dc
Remove next/dynamic loading mechanism
timneutkens Jun 29, 2018
cff8ea6
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jun 29, 2018
efb3ece
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 2, 2018
7973747
Support old `dynamic` behavior
timneutkens Jul 2, 2018
84bcd00
Update readme to reflect removed parameter
timneutkens Jul 2, 2018
65a8fc6
Make tests pass
timneutkens Jul 2, 2018
f5c3905
Make sure react-loadable manifest only holds chunks that are needed
timneutkens Jul 2, 2018
2ba7bea
Fix cache header test
timneutkens Jul 2, 2018
8e9c75c
Strip out anything that isn’t .js
timneutkens Jul 2, 2018
8b32db8
Add 60 second timeout to check loop
timneutkens Jul 2, 2018
96d0297
Upgrade webpack deps
timneutkens Jul 3, 2018
4b6fa2e
Configure loglevel
timneutkens Jul 3, 2018
c93f05f
Remove touch as this bug was fixed in webpack 4
timneutkens Jul 3, 2018
f439bf9
Use new webpack plugin system
timneutkens Jul 5, 2018
e75334f
Return compilation errors instead of looping reasons
timneutkens Jul 5, 2018
a7e3ee7
Set name as per multicompiler docs in webpack-hot-middleware
timneutkens Jul 5, 2018
8196386
Move friendlyerrorwebpackplugin below webpackbar
timneutkens Jul 5, 2018
e34ff42
Read errors from origin as chunks are no longer bound to modules
timneutkens Jul 5, 2018
f8346bb
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 5, 2018
bdb68fc
Make sure / and /index are handled correctly
timneutkens Jul 5, 2018
bee84f8
Render error of page that was called
timneutkens Jul 5, 2018
527b7e2
Reload when error is resolved
timneutkens Jul 6, 2018
8d567bb
Add hot-middleware client
timneutkens Jul 6, 2018
ef0be4e
Close browser window when errors happen in error-recovery tests
timneutkens Jul 6, 2018
b52c447
Add react-error-overlay
timneutkens Jul 9, 2018
b3c397c
Remove comments
timneutkens Jul 9, 2018
b52058e
Remove check for client
timneutkens Jul 9, 2018
30885a2
Remove update-check
timneutkens Jul 9, 2018
7d05f1e
Fix test
timneutkens Jul 9, 2018
52feb80
Fix HMR tests
timneutkens Jul 9, 2018
2716db5
Fix error recovery tests
timneutkens Jul 9, 2018
c633db1
Fix linting
timneutkens Jul 9, 2018
2009612
Fix error-recovery tests
timneutkens Jul 10, 2018
03a6d82
Remove unused files
timneutkens Jul 10, 2018
7ce4a63
Fix flow types
timneutkens Jul 10, 2018
ff0974a
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 10, 2018
b57f960
Convert .plugin to .hooks for webpack 4
timneutkens Jul 10, 2018
c438fc8
Run tests on Node.js 8
timneutkens Jul 10, 2018
8387583
Fix runtime error tests
timneutkens Jul 10, 2018
1febba1
Remove unused files
timneutkens Jul 10, 2018
b058464
Add support for custom event handler (same as webpack-hot-middleware)
timneutkens Jul 10, 2018
99e9a7b
Handle custom events like reloading when there is a new page.
timneutkens Jul 10, 2018
92e6c15
Fix intermittent failure when removing pages
timneutkens Jul 12, 2018
9dc669a
Fix empty getInitialProps test
timneutkens Jul 12, 2018
93d90e8
Fix deleted page test, it works correctly now
timneutkens Jul 12, 2018
d229b80
Remove SSR check on stacktrace
timneutkens Jul 12, 2018
3fe75e2
Remove comment
timneutkens Jul 12, 2018
81a806e
Fix ‘false’ being rendered on non-error pages
timneutkens Jul 12, 2018
0017e67
Fix static dynamic import test
timneutkens Jul 12, 2018
dd083e1
Remove unused method now that Next uses react-loadable
timneutkens Jul 12, 2018
f90e437
Require these modules from `next` too
timneutkens Jul 12, 2018
addc9df
Remove tests for removed functionality that is now covered by react-l…
timneutkens Jul 12, 2018
7e1e576
Fix ondemand tests
timneutkens Jul 12, 2018
5b74b39
Fix deprecation warning coming from webpack
timneutkens Jul 12, 2018
c17f0aa
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 12, 2018
12e39c0
Fix linting
timneutkens Jul 12, 2018
5ff6c0d
Reload _app on self-accept
timneutkens Jul 12, 2018
0d5d5ac
_document.js reloading the right way
timneutkens Jul 12, 2018
eb2ad49
Fix production tests
timneutkens Jul 12, 2018
a534468
Add comment as to what the new plugin does
timneutkens Jul 12, 2018
cd9c7f3
Remove check for node 6 as node 8 is the minimum version now
timneutkens Jul 12, 2018
3e18bc1
Bring back previous generator
timneutkens Jul 12, 2018
e5b24ea
Disable next-css test
timneutkens Jul 13, 2018
c1a0b25
Disable default behavior
timneutkens Jul 13, 2018
5f320c2
Upgrade to latest webpack
timneutkens Jul 13, 2018
614b5b6
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 13, 2018
1597836
Fix 404 to page test
timneutkens Jul 13, 2018
4044864
Run tests on node 8
timneutkens Jul 13, 2018
b247aa2
Clean up hot-dev-client states
timneutkens Jul 16, 2018
e545fd5
Fix development issues
timneutkens Jul 16, 2018
92e2426
Remove splitChunk configuration for now
timneutkens Jul 16, 2018
c866fb2
Wait for iframe to become available
timneutkens Jul 17, 2018
48e8bf7
Fix error overlay on windows
timneutkens Jul 18, 2018
6134ed0
Fix _document HMR on windows
timneutkens Jul 18, 2018
2533d62
Backwards compat for main.js
timneutkens Jul 18, 2018
2e59d9c
Remove logs
timneutkens Jul 18, 2018
1138fc9
Upgrade webpack to latest
timneutkens Jul 19, 2018
28a2f89
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 19, 2018
c44b392
Remove special cased webpack routes
timneutkens Jul 19, 2018
4a6f220
Read files required for a page from buildManifest
timneutkens Jul 19, 2018
64bfc00
Log error to browser console in production
timneutkens Jul 20, 2018
849473a
Initial splitChunks configuration
timneutkens Jul 20, 2018
1031126
Add hash to runtime and main chunk
timneutkens Jul 21, 2018
4c77c8d
Close browser window after specific tests run
timneutkens Jul 21, 2018
6d51728
Remove commonschunk config
timneutkens Jul 21, 2018
a55e539
Only render .js files from the main.js chunk
timneutkens Jul 21, 2018
00f62f5
Share initialized modules between entrypoints
timneutkens Jul 21, 2018
2ab0fe3
Normalize the path to be a unix path
timneutkens Jul 21, 2018
44a42f3
Remove loading of chalk
timneutkens Jul 21, 2018
9cd7c2b
Reference what has been edited
timneutkens Jul 21, 2018
e0513d5
Clean up error-boundary.js after react-error-overlay changes
timneutkens Jul 21, 2018
9135955
Remove log, optimize 1 loc
timneutkens Jul 21, 2018
992134a
Revert update test to be the original test
timneutkens Jul 21, 2018
4bc9a13
Make sure dead code is eliminated
timneutkens Jul 21, 2018
282fc9f
Merge branch 'canary' of github.com:zeit/next.js into webpack
timneutkens Jul 22, 2018
1d2df8b
Add clearer names for plugins
timneutkens Jul 22, 2018
dc03c2c
Add recordsPath
timneutkens Jul 22, 2018
81322ce
Move require cache flusher into it’s own webpack plugin
timneutkens Jul 22, 2018
a17e8f1
Refactor references to `compiler` to `multiCompiler` to be clearer
timneutkens Jul 22, 2018
f02eac5
Remove unused method
timneutkens Jul 22, 2018
d2a44d4
If there’s no error send undefined so that it doesn’t end up in the r…
timneutkens Jul 22, 2018
ea8086a
Use `undefined` for `err` so that it’s not sent when there is no error
timneutkens Jul 22, 2018
94b0872
Make sure `nextExport` doesn’t end up in resulting HTML
timneutkens Jul 22, 2018
e0797d2
Send assetPrefix to the client only when it’s configured
timneutkens Jul 22, 2018
a78b7e0
Improve assetPrefix dataflow
timneutkens Jul 22, 2018
cd66c7a
Fix flow types
timneutkens Jul 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
},
language: "node_js",
node_js: ["6"],
node_js: ["8"],
cache: {
directories: ["node_modules"]
},
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"

# Install scripts. (runs after repo cloning)
install:
Expand Down
85 changes: 0 additions & 85 deletions build/babel/plugins/handle-import.js

This file was deleted.

125 changes: 125 additions & 0 deletions build/babel/plugins/react-loadable-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// This file is https://github.com/jamiebuilds/react-loadable/blob/master/src/babel.js
// Modified to also look for `next/dynamic`
// Modified to put `webpack` and `modules` under `loadableGenerated` to be backwards compatible with next/dynamic which has a `modules` key
// Modified to support `dynamic(import('something'))` and `dynamic(import('something'), options)
export default function ({ types: t, template }) {
return {
visitor: {
ImportDeclaration (path) {
let source = path.node.source.value
if (source !== 'next/dynamic' && source !== 'react-loadable') return

let defaultSpecifier = path.get('specifiers').find(specifier => {
return specifier.isImportDefaultSpecifier()
})

if (!defaultSpecifier) return

let bindingName = defaultSpecifier.node.local.name
let binding = path.scope.getBinding(bindingName)

binding.referencePaths.forEach(refPath => {
let callExpression = refPath.parentPath

if (
callExpression.isMemberExpression() &&
callExpression.node.computed === false &&
callExpression.get('property').isIdentifier({ name: 'Map' })
) {
callExpression = callExpression.parentPath
}

if (!callExpression.isCallExpression()) return

let args = callExpression.get('arguments')
if (args.length > 2) throw callExpression.error

let loader
let options

if (!args[0]) {
return
}

if (args[0].isCallExpression()) {
if (!args[1]) {
callExpression.pushContainer('arguments', t.objectExpression([]))
}
args = callExpression.get('arguments')
loader = args[0]
options = args[1]
} else {
options = args[0]
}

if (!options.isObjectExpression()) return

let properties = options.get('properties')
let propertiesMap = {}

properties.forEach(property => {
let key = property.get('key')
propertiesMap[key.node.name] = property
})

if (propertiesMap.loadableGenerated) {
return
}

if (propertiesMap.loader) {
loader = propertiesMap.loader.get('value')
}

if (propertiesMap.modules) {
loader = propertiesMap.modules.get('value')
}

let loaderMethod = loader
let dynamicImports = []

loaderMethod.traverse({
Import (path) {
dynamicImports.push(path.parentPath)
}
})

if (!dynamicImports.length) return

options.pushContainer(
'properties',
t.objectProperty(
t.identifier('loadableGenerated'),
t.objectExpression([
t.objectProperty(
t.identifier('webpack'),
t.arrowFunctionExpression(
[],
t.arrayExpression(
dynamicImports.map(dynamicImport => {
return t.callExpression(
t.memberExpression(
t.identifier('require'),
t.identifier('resolveWeak')
),
[dynamicImport.get('arguments')[0].node]
)
})
)
)
),
t.objectProperty(
t.identifier('modules'),
t.arrayExpression(
dynamicImports.map(dynamicImport => {
return dynamicImport.get('arguments')[0].node
})
)
)
])
)
)
})
}
}
}
}
3 changes: 2 additions & 1 deletion build/babel/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = (context, opts = {}) => ({
],
plugins: [
require('babel-plugin-react-require'),
require('./plugins/handle-import'),
require('@babel/plugin-syntax-dynamic-import'),
require('./plugins/react-loadable-plugin'),
[require('@babel/plugin-proposal-class-properties'), opts['class-properties'] || {}],
require('@babel/plugin-proposal-object-rest-spread'),
[require('@babel/plugin-transform-runtime'), opts['transform-runtime'] || {
Expand Down
2 changes: 1 addition & 1 deletion build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function runCompiler (compiler) {
return reject(error)
}

resolve(jsonStats)
resolve()
})
})
}
Expand Down
Loading