webpack: Fails to parse BigInteger Literal

Bug report

What is the current behavior?

const bigInteger = 0n;

Causes the following error:

Module parse failed: Identifier directly after number (0:20)
You may need an appropriate loader to handle this file type.

Compiling from typescript to esnext.

Repro Repo

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

const bigInteger = 0n;

A script with the above contents should be parsed and emitted without error.

Other relevant information: webpack version: 4.30.0 Node.js version: 8.11.3 Operating System: Windows 10 Additional tools: typescript, awesome-typescript-loader

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@evilebottnawi gotcha. Here’s a repro https://github.com/chrisui/bigint-literal-webpack-issue

$ npm install
$ npm run build

Hash: e61d89767dc3ddcef2e7
Version: webpack 4.30.0
Time: 76ms
Built at: 04/30/2019 2:39:14 PM
 1 asset
Entrypoint main = main.js
[0] ./src/index.js 168 bytes {0} [built] [failed] [1 error]

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

ERROR in ./src/index.js 1:20
Module parse failed: Identifier directly after number (1:20)
You may need an appropriate loader to handle this file type.
> const bigInteger = 0n;

@azizj1 I didn’t find any last month, I ended up changing the code to use BigInt(1) instead of 1n

Sometimes proposals on stage 3 were declined, so i don’t think it is good idea support this out of box