Skip to content

Commit

Permalink
feat(esbuild): Enable esbuild's per-file tree shaking
Browse files Browse the repository at this point in the history
Set `treeShaking: true` and `ignoreAnnotation: false` in `transformOptions`.
  • Loading branch information
Septh committed Sep 16, 2024
1 parent 47f0bbc commit 917f1eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"overrides": "esbuild"
}
],
"typescript.tsdk": "node_modules\\typescript\\lib"
"typescript.tsdk": "node_modules\\typescript\\lib",
"conventionalCommits.scopes": [
"esbuild"
]
}
2 changes: 0 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function fastTypescript(
// Resolve the tsconfig option.
if (typeof tsConfig === 'function')
tsConfig = await tsConfig()

if (tsConfig === true)
tsConfig = './tsconfig.json'
else if (!tsConfig)
Expand All @@ -78,7 +77,6 @@ export function fastTypescript(
let tsConfigBasePath: string,
tsConfigParsed: ts.ParsedCommandLine,
tsDiagnostics: ts.Diagnostic[] = []

if (typeof tsConfig === 'string') {
tsConfig = path.resolve(tsConfig)
tsConfigBasePath = path.dirname(tsConfig)
Expand Down
4 changes: 2 additions & 2 deletions source/transformers/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default {
jsxImportSource: compilerOptions.jsxImportSource,
jsxSideEffects: true,
minify: false,
treeShaking: false,
ignoreAnnotations: true,
treeShaking: true,
ignoreAnnotations: false,
logLevel: 'silent',

tsconfigRaw: {
Expand Down

0 comments on commit 917f1eb

Please sign in to comment.