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

feat: add webpack 5 support #123

Merged
merged 25 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
374713f
test: explicitly disable devtools to speed up tests
pmmmwh Jun 20, 2020
18d46b9
fix: get exports from Webpack cache for more deterministic behaviour
pmmmwh Jun 20, 2020
9593fca
fix: use webpack cache global instead of require.cache for hot accept
pmmmwh Jun 20, 2020
3f157b1
refactor: rename plugin helpers to utils
pmmmwh Jun 20, 2020
cb2a555
feat: implement webpack version detection and plugin globals
pmmmwh Jun 20, 2020
7dd0b8d
feat: implement template generator for webpack-bound global runtime
pmmmwh Jun 20, 2020
4833c36
feat: add runtime module to inject global runtime
pmmmwh Jun 20, 2020
cf6f1c2
feat: add utils to get parser helpers and inject loader
pmmmwh Jun 20, 2020
b9c1b60
docs: add JSDoc for getRefreshGlobal
pmmmwh Jun 20, 2020
f69eed6
feat: implement webpack 5 compilation hooks in plugin
pmmmwh Jun 20, 2020
013fd59
test: update ESM-related tests with a proxy root to stop tree-shaking
pmmmwh Jun 20, 2020
c1accce
feat: update package.json to allow usage with Webpack 5
pmmmwh Jun 20, 2020
614dbc0
fix: make runtime module only called when using webpack 5
pmmmwh Jun 20, 2020
55a407d
test: implement webpack-cli@next testing for Webpack 5
pmmmwh Jun 20, 2020
3a7dc14
ci: use parallel testing to test with webpack 4 and 5
pmmmwh Jun 20, 2020
8d80ef6
ci: use tagged versions of webpack and webpack-cli
pmmmwh Jun 21, 2020
a8429a0
ci: split tests as tasks instead of parallel runs
pmmmwh Jun 21, 2020
c68dba1
test: revert unneeded changes to conformance tests
pmmmwh Jun 21, 2020
74fec42
refactor: cleanup JSDoc and simplify loader injection logic
pmmmwh Jun 21, 2020
14e91f7
refactor: update type definition generation
pmmmwh Jun 21, 2020
5d71a51
feat: add entry injection support for entry descriptors
pmmmwh Jun 21, 2020
94b3be3
test: re-add needed changes to conformance test
pmmmwh Jun 22, 2020
6c70470
test: move webpack version detection into test environment
pmmmwh Jun 22, 2020
fc202c8
test: remove it.only
pmmmwh Jun 22, 2020
4ef7561
refactor: ocd alignment of switch case syntax
pmmmwh Jun 22, 2020
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
51 changes: 46 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ jobs:
parameters:
node-version:
default: '13.14'
type: string
enum:
- '10.21'
- '12.18'
- '13.14'
- '14.4'
type: enum
webpack-version:
default: latest
enum:
- latest
- next
type: enum
setup:
default: []
type: steps
Expand All @@ -58,6 +69,16 @@ jobs:
app-dir: ~/project
pkg-manager: yarn
with-cache: false
- run:
name: Install Webpack-related dependencies
command: |
if [[ << parameters.webpack-version >> == "next" ]]; then
WEBPACK_CLI_VERSION="beta"
else
WEBPACK_CLI_VERSION="latest"
fi

yarn add -D "webpack@<< parameters.webpack-version >>" "webpack-cli@$WEBPACK_CLI_VERSION"
- run:
name: Run Tests
command: |
Expand All @@ -76,14 +97,34 @@ workflows:
jobs:
- lint-and-format
- test:
name: test/node:10
name: test/node:10/webpack:4
node-version: '10.21'
webpack-version: latest
- test:
name: test/node:12/webpack:4
node-version: '12.18'
webpack-version: latest
- test:
name: test/node:13/webpack:4
node-version: '13.14'
webpack-version: latest
- test:
name: test/node:14/webpack:4
node-version: '14.4'
webpack-version: latest
- test:
name: test/node:10/webpack:5
node-version: '10.21'
webpack-version: next
- test:
name: test/node:12
name: test/node:12/webpack:5
node-version: '12.18'
webpack-version: next
- test:
name: test/node:13
name: test/node:13/webpack:5
node-version: '13.14'
webpack-version: next
- test:
name: test/node:14
name: test/node:14/webpack:5
node-version: '14.4'
webpack-version: next
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"globals": {
"__DEBUG__": true,
"WEBPACK_VERSION": true,
"browser": true
}
},
Expand Down
11 changes: 7 additions & 4 deletions client/ErrorOverlayEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ function compileMessageHandler(message) {
switch (message.type) {
case 'ok':
case 'still-ok':
case 'warnings':
case 'warnings': {
// TODO: Implement handling for warnings
handleCompileSuccess();
break;
case 'errors':
}
case 'errors': {
handleCompileErrors(message.data);
break;
default:
// Do nothing.
}
default: {
// Do nothing.
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions lib/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { version } = require('webpack');

// Parse Webpack's major version: x.y.z => x
const webpackVersion = parseInt(version || '', 10);

let webpackGlobals = {};
if (webpackVersion === 5) {
webpackGlobals = require('webpack/lib/RuntimeGlobals');
}

module.exports.refreshGlobal = `${webpackGlobals.require || '__webpack_require__'}.$Refresh$`;
module.exports.webpackVersion = webpackVersion;
Loading