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.

Docs: Difference between esnext, es6, es2015 module targets

See original GitHub issue

Search Terms

esnext, es6, es2015, module, tsconfig, tsconfig.json, difference, document

Suggestion

It would be great if this can be documented. On the face of it, the output for all three seems to be identical.

Related: It would also be nice to document why targeting module: "none" when your code is a module (ie. uses ES2015 imports/exports) generates CommonJS-compatible code instead of exporting to globals as “none” seems to imply.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:207
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

53reactions
DanielRosenwassercommented, May 12, 2018

To just answer the question, the difference is that import() expressions are understood in esnext, but not in es2015 (and as of TypeScript 2.9, import.meta is only understood with esnext).

I guess you could possibly expect an es2019 module target for both.

45reactions
mhegazycommented, May 14, 2018

in addition to what @DanielRosenwasser mentioned, esNext is just a place holder for features that are on the standard track but is not in an official ES spec yet. e.g. import.meta and import() expressions. as TC39 adds these features to a versioned spec, we will add a new --module ES20** to reflect that.

Also es6 === es2015.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Compiler Option in TypeScript - tsmean
How the TypeScript docs describe the module compiler option ... Here's a comparison between CommonJS and ES6 / ES2015 / ESNext : ...
Read more >
TSConfig Option: target - TypeScript
The target setting changes which JS features are downleveled and which are left intact.
Read more >
Typescript: why so complicated?! (A list of my preferred options)
Here's a discussion about module, target, outDir, moduleResolution, lib, etc. ... None; CommonJS; AMD; System; UMD; ES6; ES2015; ESNext.
Read more >
Difference between module es2015 vs es2020 - Stack Overflow
If you are wondering about the difference between ES2015 (aka ES6) and ES2020, ES2020 adds support for dynamic imports, and import.meta.
Read more >
Which version of EcmaScript should I use in the TypeScript ...
TypeScript allows converting most of the ES next features to ES3, ES5, ES6, ES2016, ES2017. Of course, you can also target ES Next....
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