vercel / vercel/ncc

Not transpiling nullish coalesce with typescript

Open
#889 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Description

We are attempting to use ncc to transpile some typescript code into a single js file, and some of the dependencies include code that includes a nullish coalesce operator and it seems to simply ignore them and outputs it in the outputted js file which gives the following error when you attempt and run via node dist/index.js:

const d = options.lastModified ?? Date.now()
                                    ^

SyntaxError: Unexpected token '?'

I have the target defined both in the command: ncc build -a -e typescript --target es2015 src/main.ts

and in the tsconfig file:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node"
  }
}

Node version: 14

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with ncc build -a -e typescript --target es2015 src/main.ts, using the shown tsconfig and Node 14. Inspect src/main.ts and the generated dist/index.js; done means the nullish coalesce operator is transpiled so the bundled file runs on the stated Node version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.