File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @codama/cli ' : patch
3+ ' @codama/dynamic-codecs ' : patch
4+ ' @codama/dynamic-parsers ' : patch
5+ ' @codama/errors ' : patch
6+ ' codama ' : patch
7+ ' @codama/node-types ' : patch
8+ ' @codama/nodes ' : patch
9+ ' @codama/nodes-from-anchor ' : patch
10+ ' @codama/renderers-core ' : patch
11+ ' @codama/validators ' : patch
12+ ' @codama/visitors ' : patch
13+ ' @codama/visitors-core ' : patch
14+ ---
15+
16+ Enable Rollup treeshaking pass by default, disable only for CLI builds
Original file line number Diff line number Diff line change 1- import { defineConfig } from 'tsup' ;
1+ import { defineConfig , Options as TsupConfig } from 'tsup' ;
22
33import { getBuildConfig , getCliBuildConfig } from '../../tsup.config.base' ;
44
55export default defineConfig ( [
6- getBuildConfig ( { format : 'cjs' , platform : 'node' } ) ,
7- getBuildConfig ( { format : 'esm' , platform : 'node' } ) ,
8- getCliBuildConfig ( ) ,
6+ removeAdditionalTreeShaking ( getBuildConfig ( { format : 'cjs' , platform : 'node' } ) ) ,
7+ removeAdditionalTreeShaking ( getBuildConfig ( { format : 'esm' , platform : 'node' } ) ) ,
8+ removeAdditionalTreeShaking ( getCliBuildConfig ( ) ) ,
99] ) ;
10+
11+ function removeAdditionalTreeShaking ( config : TsupConfig ) : TsupConfig {
12+ return {
13+ ...config ,
14+
15+ // Treeshaking already happens with esbuild but tsup offers this options
16+ // for "better" treeshaking strategies using Rollup as an additional step.
17+ // The issue is Rollup now uses the deprecated "assert" import keyword by default
18+ // And tsup doesn't offer a way to change this behavior. Since the CLI package
19+ // relies on using the "with" keyword to dynamically import JSON files,
20+ // we can't use Rollup for treeshaking.
21+ treeshake : false ,
22+ } ;
23+ }
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export function getBuildConfig(options: BuildOptions): TsupConfig {
5454 publicDir : true ,
5555 pure : [ 'process' ] ,
5656 sourcemap : format !== 'iife' ,
57+ treeshake : true ,
5758 } ;
5859}
5960
You can’t perform that action at this time.
0 commit comments