Skip to content

Commit bd76b45

Browse files
[DevTools] Fix ReactDevToolsBackend module for AMD (#35891)
## Summary For apps that use AMD, we need to actually `require()` the ReactDevToolsBackend and load it from the AMD module cache. This adds a check for the case where the `ReactDevToolsBackend` isn't defined globally, and so we load it with `require()`. ## How did you test this change? Tested through #35886
1 parent b354bbd commit bd76b45

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

packages/react-devtools-core/src/standalone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ function startServer(
361361
response.end(
362362
backendFile.toString() +
363363
'\n;' +
364+
`var ReactDevToolsBackend = typeof ReactDevToolsBackend !== "undefined" ? ReactDevToolsBackend : require("ReactDevToolsBackend");\n` +
364365
`ReactDevToolsBackend.initialize(undefined, undefined, undefined, ${componentFiltersString});` +
365366
'\n' +
366367
`ReactDevToolsBackend.connectToDevTools({port: ${port}, host: '${host}', useHttps: ${

packages/react-devtools-core/webpack.backend.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = {
4444
// This name is important; standalone references it in order to connect.
4545
library: 'ReactDevToolsBackend',
4646
libraryTarget: 'umd',
47+
umdNamedDefine: true,
4748
},
4849
resolve: {
4950
alias: {

0 commit comments

Comments
 (0)