From 917f1eb71e0229445a5e75e8ee7fe1ba3243399b Mon Sep 17 00:00:00 2001 From: Stephan Schreiber Date: Mon, 16 Sep 2024 20:06:34 +0200 Subject: [PATCH] feat(esbuild): Enable esbuild's per-file tree shaking Set `treeShaking: true` and `ignoreAnnotation: false` in `transformOptions`. --- .vscode/settings.json | 5 ++++- source/index.ts | 2 -- source/transformers/esbuild.ts | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a29b249..feec51e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,8 @@ "overrides": "esbuild" } ], - "typescript.tsdk": "node_modules\\typescript\\lib" + "typescript.tsdk": "node_modules\\typescript\\lib", + "conventionalCommits.scopes": [ + "esbuild" + ] } diff --git a/source/index.ts b/source/index.ts index b40fc30..2794e00 100644 --- a/source/index.ts +++ b/source/index.ts @@ -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) @@ -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) diff --git a/source/transformers/esbuild.ts b/source/transformers/esbuild.ts index 4c5e2f4..2167006 100644 --- a/source/transformers/esbuild.ts +++ b/source/transformers/esbuild.ts @@ -65,8 +65,8 @@ export default { jsxImportSource: compilerOptions.jsxImportSource, jsxSideEffects: true, minify: false, - treeShaking: false, - ignoreAnnotations: true, + treeShaking: true, + ignoreAnnotations: false, logLevel: 'silent', tsconfigRaw: {