严格模式下不支持Safari/Babel/Webpack常量声明

严格模式下不支持Safari/Babel/Webpack常量声明,safari,webpack,babeljs,Safari,Webpack,Babeljs,Safari无法使用以下行加载我的React应用程序: Const declarations are not supported in strict mode. 当我看到失败的线路时,我看到: const Crypto = __webpack_require__(624) 这不是我的应用程序中的内容,所以它必须由Webpack或其他依赖项注入 巴贝尔不应该用var取代const 巴别塔依赖关系 "babel": "~6.1.0", "babel-core": "~6.2.0", "babel

Safari无法使用以下行加载我的React应用程序:

Const declarations are not supported in strict mode.
当我看到失败的线路时,我看到:

const Crypto = __webpack_require__(624)
这不是我的应用程序中的内容,所以它必须由Webpack或其他依赖项注入

巴贝尔不应该用
var
取代
const

巴别塔依赖关系

"babel": "~6.1.0",
"babel-core": "~6.2.0",
"babel-loader": "~6.2.0",
"babel-plugin-transform-runtime": "~6.1.0",
"babel-polyfill": "~6.2.0",
"babel-preset-es2015": "~6.1.0",
"babel-preset-react": "~6.1.0",
"babel-preset-stage-0": "~6.1.0",
"babel-runtime": "~6.2.0"
巴别塔装载机配置

{
  test: /\.js|\.jsx$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  query: {
    cacheDirectory: true,
    plugins: ['transform-runtime'],
    presets: ['es2015', 'react', 'stage-0']
  }
}
注意我的应用程序在Chrome中也能工作。

您在babel loader设置中排除了“节点\u模块”,因此它不会处理您的外部依赖项。您所依赖的此软件包可能未在浏览器中进行使用测试

顺便说一句,除非你使用“transform-es2015-block-scoping”插件,否则babel不会取代你的const

它不包括在“es2015”预设中。这里只有“check-es2015-constants”插件,它只检查和验证const声明


将常量转换为变量的插件称为“transform-es2015-block-scoping”,它包含在“es2015”预设中。

根据transform-es2015-block-scoping,插件包含在es2015预设中。有人可以为2018解决方案更新此插件吗?我认为这是一个类似的情况,但它似乎不是最新的参考
es2015
预设?哦,我的上帝。从昨天开始,我一直在努力让巴贝尔编译成es5。多亏了您关于删除排除节点模块设置的回答,我终于解决了这个问题。