question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected keyword 'const'. Const declarations are not supported in strict mode

See original GitHub issue

Current Behavior

When running a new app using haul with Typescript I get Unexpected keyword 'const'. Const declarations are not supported in strict mode.. This appears to have happened previously in https://github.com/callstack/haul/issues/159, but according to that ticket it was solved several versions ago by excluding pretty-format in 58c17ff. I’m on the latest version of haul and am seeing it happen.

Expected Behavior

The error doesn’t occur.

Haul Configuration (webpack.haul.js)

I followed the Typescript setup instructions:

webpack.haul.js:

module.exports = ({ platform }, { module, resolve }) => ({
  entry: `./index.js`,
  module: {
    ...module,
    rules: [
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
          },
          {
            loader: 'ts-loader'
          },
        ],
      },
      ...module.rules
    ]
  },
  resolve: {
    ...resolve,
    extensions: [
      '.ts',
      '.tsx',
      `.${platform}.ts`,
      '.native.ts',
      `.${platform}.tsx`,
      '.native.tsx',
      ...resolve.extensions],
  },
});

tsconfig.json:

{
  "compilerOptions": {
    "declaration": false,
    "lib": ["es2015"],
    "module": "es6",
    "moduleResolution": "node",
    "jsx": "react",
    "target": "es2015",
    "allowSyntheticDefaultImports": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "baseUrl": "."
  },
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false
}

.babelrc:

{
  "presets": ["react-native"]
}

Your Environment

software version
Haul 1.0.0-beta.13
react-native 0.55.1
node both 9.11.1 and 8.11.1
yarn 1.3.2

Thanks for any help!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
mortada-codescommented, Jul 24, 2018

I am still facing this error when running android release?

1reaction
deepsweetcommented, Apr 6, 2018

Happens to me as well since RN 0.54, and I found the problematic file: node_modules/metro/src/lib/bundle-modules/MetroClient.js, so now we have an additional lib to traspile explicitly.

Added metro to node_modules/haul/src/utils/makeReactNativeConfig.js and it works:

test: /\.js$/,
exclude: /node_modules\/(?!react|@expo|pretty-format|haul|metro)/,
Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected keyword 'const'. Const declarations ...
SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. Issue #9712 · babel/babel · GitHub.
Read more >
bundle.js:1 SyntaxError: Unexpected keyword 'const'. Const ...
js:1 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. My webpack.config.json has this rule: rules: ...
Read more >
Vue-cli and iOS 9 SyntaxError: Unexpected keyword 'const ...
Const declarations are not supported in strict mode. The const keyword comes from the email-regex lib wich is not tranformed by babel.
Read more >
React native unexpected keyword const const declarations ...
536,965 react native unexpected keyword const const declarations are not supported in strict mode jobs found, pricing in USD.
Read more >
Const Keyword Is Not Allowded In The Strict Mode In React ...
When running a new app using haul with Typescript I get Unexpected keyword 'const'. Const declarations are not supported in strict mode. Hello...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found