我们必须更新一些依赖项才能切换到 Webpack 4,并且在尝试在同一项目中进行import混合时,我们在 webpack 中收到警告,在浏览器中收到错误。require
我们有一个非常大的项目(300多个文件),其中一些文件使用var Pkg = require('./fileName');和 ,module.exports = MyComponent而其他文件使用import Pkg from './fileName'和export default MyComponent,并且希望不必使用 require/module.exports 遍历每个文件并更新它们。
网页包警告:
WARNING in ./index.js 15:17-20
"export 'default' (imported as 'App') was not found in './App.jsx'
Run Code Online (Sandbox Code Playgroud)
浏览器错误:
App.jsx:20 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
at Module.eval (App.jsx:20)
at eval (App.jsx:21)
at Module../App.jsx (bootstrap:83)
at __webpack_require__ (bootstrap:19)
at eval (index.js:2)
at Module../index.js (bootstrap:83)
at …Run Code Online (Sandbox Code Playgroud)