Skip to content

Commit

Permalink
Use esnext target with TypeScript and scope hoist (#1781)
Browse files Browse the repository at this point in the history
Should bring a noticeable size improvement on big TypeScript apps
  • Loading branch information
fathyb authored and DeMoorJasper committed Jul 23, 2018
1 parent c0a84ae commit 3e9b086
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/assets/TypeScriptAsset.js
Expand Up @@ -12,7 +12,9 @@ class TypeScriptAsset extends Asset {
let typescript = await localRequire('typescript', this.name);
let transpilerOptions = {
compilerOptions: {
module: typescript.ModuleKind.CommonJS,
module: this.options.scopeHoist
? typescript.ModuleKind.ESNext
: typescript.ModuleKind.CommonJS,
jsx: typescript.JsxEmit.Preserve,

// it brings the generated output from TypeScript closer to that generated by Babel
Expand Down

3 comments on commit 3e9b086

@mihailik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about async/await - does parcel unroll those for ES5 browsers?

@fathyb
Copy link
Contributor Author

@fathyb fathyb commented on 3e9b086 Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about the module options (not to confuse with target), anything else than import/export is unchanged.
Use target: esnext and this workaround to build pure ES6 apps.

@qwabra
Copy link

@qwabra qwabra commented on 3e9b086 Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use target: esnext and this workaround to build pure ES6 apps

it doesn't work just try:

class Test_1 {
	#q = 'Q'
}
class Test_2 {
	w = 'W'
}
// tsconfig.json
{
  "compilerOptions": {
    "useDefineForClassFields": true,
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "experimentalDecorators": true
  }
}

Please sign in to comment.