-
Notifications
You must be signed in to change notification settings - Fork 48.9k
Webpack 5 Upgrade #22267
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 5 Upgrade #22267
Changes from all commits
d4126d7
22813af
f79e01d
1c2da66
b1b7622
5770b68
97686ff
d50af18
13f3bd6
3ab20d4
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 |
---|---|---|
|
@@ -62,10 +62,10 @@ | |
"source-map-js": "^0.6.2", | ||
"sourcemap-codec": "^1.4.8", | ||
"style-loader": "^0.23.1", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.10.3", | ||
"workerize-loader": "^1.3.0" | ||
"webpack": "^5", | ||
"webpack-cli": "^4", | ||
"webpack-dev-server": "^4", | ||
"workerize-loader-5": "^1.4.0" | ||
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. Something about this change causes the following error to be thrown in the extension process:
Looking at the code in question, I see: (0, _utils.default)("ArrayExpression", {
fields: {
elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))),
default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined
}
},
visitor: ["elements"],
aliases: ["Expression"]
}); Seems like this is coming from an imported module? Seems like the result of this error is that the named hooks feature does not work. (Clicking the little "🪄" button for an inspected element eventually times out whereas it used to work.) To reproduce this problem, build the extension as described here and then open a website like Code Sandbox and try to inspect a component with hooks. (You can see the error thrown when the extension is initializing actually, by undocking the DevTools and opening a second level of DevTools to inspect the extension.) 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. will look into this further 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. 🙇🏼♂️ Thanks! |
||
}, | ||
"dependencies": { | ||
"web-ext": "^4" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('./dist/backend'); | ||
module.exports = require('./dist/backend').backend; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('./dist/frontend'); | ||
module.exports = require('./dist/frontend').frontend; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,11 @@ | |
"babel-loader": "^8.0.4", | ||
"cross-env": "^3.1.4", | ||
"css-loader": "^1.0.1", | ||
"html-webpack-plugin": "^5", | ||
"raw-loader": "^3.1.0", | ||
"style-loader": "^0.23.1", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.10.3" | ||
"webpack": "^5", | ||
"webpack-cli": "^4", | ||
"webpack-dev-server": "^4" | ||
} | ||
} | ||
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 Looks like the page is trying to request Editing the I see the following error in the console:
I also see a few (related?) warnings in the console when running the test shell:
Inspecting the imported module, it looks like there's an extra // module:
{
backend: {
activate: (...),
initialize: (...)
}
} Whereas before it was: // module:
{
activate: (...),
initialize: (...)
} This behavior can be reproduced by following the steps here: Then loading localhost:8080. 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. I think we could work around this by updating the entrypoint files like so: react-devtools-inline/backend.jsmodule.exports = require('./dist/backend').backend; react-devtools-inline/frontend.jsmodule.exports = require('./dist/frontend').frontend; But I don't know why this is necessary or (more importantly) what other places it might cause trouble. Anyway, in the spirit of testing, I've made this change locally to see if things works otherwise– and it looks like the DevTools UI is not visible in the test shell (so something is still broken) and I see the following two errors in the console:
Here's my local changes when testing this (in case it helps you any): diff --git a/packages/react-devtools-inline/backend.js b/packages/react-devtools-inline/backend.js
index 2c2a32d45..dbfbf7b34 100644
--- a/packages/react-devtools-inline/backend.js
+++ b/packages/react-devtools-inline/backend.js
@@ -1 +1 @@
-module.exports = require('./dist/backend');
+module.exports = require('./dist/backend').backend;
diff --git a/packages/react-devtools-inline/frontend.js b/packages/react-devtools-inline/frontend.js
index a86be2237..4700af89e 100644
--- a/packages/react-devtools-inline/frontend.js
+++ b/packages/react-devtools-inline/frontend.js
@@ -1 +1 @@
-module.exports = require('./dist/frontend');
+module.exports = require('./dist/frontend').frontend;
\ No newline at end of file
diff --git a/packages/react-devtools-shell/src/app/index.js b/packages/react-devtools-shell/src/app/index.js
index 805cd0a2a..4278daaf0 100644
--- a/packages/react-devtools-shell/src/app/index.js
+++ b/packages/react-devtools-shell/src/app/index.js
@@ -12,7 +12,7 @@ import Iframe from './Iframe';
import EditableProps from './EditableProps';
import ElementTypes from './ElementTypes';
import Hydration from './Hydration';
-import InlineWarnings from './InlineWarnings';
+// import InlineWarnings from './InlineWarnings';
import InspectableElements from './InspectableElements';
import ReactNativeWeb from './ReactNativeWeb';
import ToDoList from './ToDoList';
@@ -53,7 +53,7 @@ function mountTestApp() {
mountHelper(Hydration);
mountHelper(ElementTypes);
mountHelper(EditableProps);
- mountHelper(InlineWarnings);
+ // mountHelper(InlineWarnings);
mountHelper(ReactNativeWeb);
mountHelper(Toggle);
mountHelper(ErrorBoundaries); 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. Looks like I can fix the GET failures by modifying the following files: diff --git a/packages/react-devtools-shell/index.html b/packages/react-devtools-shell/index.html
index 410dc5bdc..732ba5db6 100644
--- a/packages/react-devtools-shell/index.html
+++ b/packages/react-devtools-shell/index.html
@@ -64,6 +64,6 @@
<!-- This script installs the hook, injects the backend, and renders the DevTools UI -->
<!-- In DEV mode, this file is served by the Webpack dev server -->
<!-- For production builds, it's built by Webpack and uploaded from the local file system -->
- <script src="dist/devtools.js"></script>
+ <script src="devtools.js"></script>
</body>
</html>
\ No newline at end of file
diff --git a/packages/react-devtools-shell/src/devtools.js b/packages/react-devtools-shell/src/devtools.js
index fda4c91b7..c7fbd3a1c 100644
--- a/packages/react-devtools-shell/src/devtools.js
+++ b/packages/react-devtools-shell/src/devtools.js
@@ -50,7 +50,7 @@ mountButton.addEventListener('click', function() {
}
});
-inject('dist/app.js', () => {
+inject('app.js', () => {
initDevTools({
connect(cb) {
const root = createRoot(container); But now for some reason the test app code loads 3 times in the page (so there's 3 duplicate copies) and DevTools UI is still not visible at all (though it's loading). It looks like the CSS/styles are weird somehow, because the DevTools UI is loading in the background (behind the duplicate copies of the app). Digging in a little more, I see a lot of 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. Possibly related to the "3 copies of the app are on the page" thing I mentioned above– the console also shows 3 copies of these logs:
Spaces added by me to highlight the fact that– although the content of the logs is the same, the file locations are different. I think this suggests that Webpack is bundling things oddly? |
Uh oh!
There was an error while loading. Please reload this page.