customize-cra
customize-cra copied to clipboard
addWebpackExternals: react is not defined
Problem:
when i use addWebpackExternals(deps):
addWebpackExternals({
react: "React",
"react-dom": "ReactDom"
});
browser occur following error:
external "react":1 Uncaught ReferenceError: react is not defined
at Object.react (external "react":1:1)
at __webpack_require__ (bootstrap:789:1)
at fn (bootstrap:150:1)
at Module../src/index.tsx (index.less?1e97:45:1)
at __webpack_require__ (bootstrap:789:1)
at fn (bootstrap:150:1)
at Object.1 (web3.js:67:1)
at __webpack_require__ (bootstrap:789:1)
at checkDeferredModules (bootstrap:45:1)
at Array.webpackJsonpCallback [as push] (bootstrap:32:1)
at main~._e.chunk.js:1:69
how to solve this problem?
Any solution to this problem? Only temporary solution I found was to add this 2 lines at the top of index.js
import React from 'react';
window.React = React;
Fixes webpack transpile when using custom loader like esbuild-loader, alterative for webpack plugin ProvidePlugin({React: 'react'})
You should introduce React in a CDN manner, otherwise there will be no React during construction