Safari / Babel / Webpack Const creatives are not supported in strict mode

Safari does not load the React application with this line:

Const declarations are not supported in strict mode.

When I look at a line that fails, I see:

const Crypto = __webpack_require__(624)

This is not something in my application, so you need to enter it using Webpack or another dependency.

Shouldn't Babel be replaced constby var?

Babel dependencies

"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"

Babel bootloader configuration

{
  test: /\.js|\.jsx$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  query: {
    cacheDirectory: true,
    plugins: ['transform-runtime'],
    presets: ['es2015', 'react', 'stage-0']
  }
}

NOTE My application works in Chrome.

+4
source share
1 answer

You excluded "node_modules" in the babel-loader settings, so it does not handle your external dependencies. This package is probably not tested for use in the browser.

, btw, babel , transform-es2015-block-scoping.

http://babeljs.io/docs/plugins/transform-es2015-block-scoping/

"es2015". "check-es2015-constants", const.

, consts vars, "transform-es2015-block-scoping" "es2015".

+5

Source: https://habr.com/ru/post/1617122/


All Articles