模块未找到:错误:无法解析“进口”使用时,@通天塔/填充工具或@通天/运行

Vis*_*hnu 2 webpack babeljs

在Webpack中使用@babel 7.0.0-beta.36。当我包括无论是填充工具或运行时库,我碰到一个编译错误。

请参阅附件https://gist.github.com/pathsny/af270f61390380c8d948973ed9e09787 我的.babelrc,package.json,package-lock.json和webpack.config.js

在上述要点中,对文件“违规文件”中的async函数取消注释行或对webpack.config.js中的条目@ babel / polyfill进行注释,然后编译代码将导致错误

ERROR in ./node_modules/@babel/polyfill/node_modules/regenerator-runtime/runtime.js Module not found: Error: Can't resolve 'imports' in '/project_path/node_modules/@babel/polyfill/node_modules/regenerator-runtime' BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders. You need to specify 'imports-loader' instead of 'imports', see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed webpack: Failed to compile.

我将不胜感激,以帮助您找出我在这里缺少的内容。

Mor*_*sen 5

我认为是由于

new webpack.ProvidePlugin({
      Promise: 'imports?this=>global!exports?global.Promise!es6-promise',
      fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
Run Code Online (Sandbox Code Playgroud)

在中Webpack.config.js,应将其更改为

new webpack.ProvidePlugin({
          Promise: 'imports-loader?this=>global!exports-loader?global.Promise!es6-promise',
          fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
Run Code Online (Sandbox Code Playgroud)

由于webpack不会自动添加加载程序后缀