Skip to content

Commit 01d0c5c

Browse files
authored
feat(pack): align CLI arguments with tsdown upstream (#672)
- Rename `--external` to `--deps.never-bundle` to match tsdown's flag - Update `--exe` description from experimental SEA to just 'Bundle as executable' - Reorder `--exe` before `--workspace` to match upstream ordering - Add snap test for `--deps.never-bundle` and legacy `--external` backward compat
1 parent 6b76588 commit 01d0c5c

7 files changed

Lines changed: 110 additions & 78 deletions

File tree

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,44 @@ For more info, run any command with the `--help` flag:
3535
$ vp pack --help
3636

3737
Options:
38-
--config-loader <loader> Config loader to use: auto, native, unrun (default: auto)
39-
--no-config Disable config file (default: true)
40-
-f, --format <format> Bundle format: esm, cjs, iife, umd (default: esm)
41-
--clean Clean output directory, --no-clean to disable
42-
--external <module> Mark dependencies as external
43-
--minify Minify output
44-
--devtools Enable devtools integration
45-
--debug [feat] Show debug logs
46-
--target <target> Bundle target, e.g "es2015", "esnext"
47-
-l, --logLevel <level> Set log level: info, warn, error, silent
48-
--fail-on-warn Fail on warnings (default: true)
49-
--no-write Disable writing files to disk, incompatible with watch mode (default: true)
50-
-d, --out-dir <dir> Output directory (default: dist)
51-
--treeshake Tree-shake bundle (default: true)
52-
--sourcemap Generate source map (default: false)
53-
--shims Enable cjs and esm shims (default: false)
54-
--platform <platform> Target platform (default: node)
55-
--dts Generate dts files
56-
--publint Enable publint (default: false)
57-
--attw Enable Are the types wrong integration (default: false)
58-
--unused Enable unused dependencies check (default: false)
59-
-w, --watch [path] Watch mode
60-
--ignore-watch <path> Ignore custom paths in watch mode
61-
--from-vite [vitest] Reuse config from Vite or Vitest
62-
--report Size report (default: true)
63-
--env.* <value> Define compile-time env variables
64-
--env-file <file> Load environment variables from a file, when used together with --env, variables in --env take precedence
65-
--env-prefix <prefix> Prefix for env variables to inject into the bundle (default: VITE_PACK_,TSDOWN_)
66-
--on-success <command> Command to run on success
67-
--copy <dir> Copy files to output dir
68-
--public-dir <dir> Alias for --copy, deprecated
69-
--tsconfig <tsconfig> Set tsconfig path
70-
--unbundle Unbundle mode
71-
-W, --workspace [dir] Enable workspace mode
72-
-F, --filter <pattern> Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name
73-
--exports Generate export-related metadata for package.json (experimental)
74-
--exe Bundle as executable using Node.js SEA (experimental)
75-
-h, --help Display this message
38+
--config-loader <loader> Config loader to use: auto, native, unrun (default: auto)
39+
--no-config Disable config file (default: true)
40+
-f, --format <format> Bundle format: esm, cjs, iife, umd (default: esm)
41+
--clean Clean output directory, --no-clean to disable
42+
--deps.never-bundle <module> Mark dependencies as external
43+
--minify Minify output
44+
--devtools Enable devtools integration
45+
--debug [feat] Show debug logs
46+
--target <target> Bundle target, e.g "es2015", "esnext"
47+
-l, --logLevel <level> Set log level: info, warn, error, silent
48+
--fail-on-warn Fail on warnings (default: true)
49+
--no-write Disable writing files to disk, incompatible with watch mode (default: true)
50+
-d, --out-dir <dir> Output directory (default: dist)
51+
--treeshake Tree-shake bundle (default: true)
52+
--sourcemap Generate source map (default: false)
53+
--shims Enable cjs and esm shims (default: false)
54+
--platform <platform> Target platform (default: node)
55+
--dts Generate dts files
56+
--publint Enable publint (default: false)
57+
--attw Enable Are the types wrong integration (default: false)
58+
--unused Enable unused dependencies check (default: false)
59+
-w, --watch [path] Watch mode
60+
--ignore-watch <path> Ignore custom paths in watch mode
61+
--from-vite [vitest] Reuse config from Vite or Vitest
62+
--report Size report (default: true)
63+
--env.* <value> Define compile-time env variables
64+
--env-file <file> Load environment variables from a file, when used together with --env, variables in --env take precedence
65+
--env-prefix <prefix> Prefix for env variables to inject into the bundle (default: VITE_PACK_,TSDOWN_)
66+
--on-success <command> Command to run on success
67+
--copy <dir> Copy files to output dir
68+
--public-dir <dir> Alias for --copy, deprecated
69+
--tsconfig <tsconfig> Set tsconfig path
70+
--unbundle Unbundle mode
71+
--exe Bundle as executable
72+
-W, --workspace [dir] Enable workspace mode
73+
-F, --filter <pattern> Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name
74+
--exports Generate export-related metadata for package.json (experimental)
75+
-h, --help Display this message
7676

7777
> vp fmt -h # fmt help message
7878
Usage: [-c=PATH] [PATH]...
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "command-pack-external",
3+
"version": "1.0.0",
4+
"type": "module"
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
> vp pack --deps.never-bundle node:path src/index.ts # should bundle with deps.never-bundle flag
2+
ℹ entry: src/index.ts
3+
ℹ Build start
4+
ℹ dist/index.mjs <variable> kB │ gzip: <variable> kB
5+
ℹ 1 files, total: <variable> kB
6+
✔ Build complete in <variable>ms
7+
8+
> vp pack --external node:path src/index.ts # should bundle with legacy external flag
9+
ℹ entry: src/index.ts
10+
11+
WARN `external` is deprecated. Use `deps.neverBundle` instead.
12+
13+
ℹ Build start
14+
ℹ Cleaning 1 files
15+
ℹ dist/index.mjs <variable> kB │ gzip: <variable> kB
16+
ℹ 1 files, total: <variable> kB
17+
✔ Build complete in <variable>ms
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import path from 'node:path';
2+
3+
console.log(path.join('a', 'b'));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignoredPlatforms": ["win32"],
3+
"commands": [
4+
"vp pack --deps.never-bundle node:path src/index.ts # should bundle with deps.never-bundle flag",
5+
"vp pack --external node:path src/index.ts # should bundle with legacy external flag"
6+
]
7+
}

packages/cli/snap-tests/command-pack/snap.txt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,44 @@ For more info, run any command with the `--help` flag:
1111
$ vp pack --help
1212

1313
Options:
14-
--config-loader <loader> Config loader to use: auto, native, unrun (default: auto)
15-
--no-config Disable config file (default: true)
16-
-f, --format <format> Bundle format: esm, cjs, iife, umd (default: esm)
17-
--clean Clean output directory, --no-clean to disable
18-
--external <module> Mark dependencies as external
19-
--minify Minify output
20-
--devtools Enable devtools integration
21-
--debug [feat] Show debug logs
22-
--target <target> Bundle target, e.g "es2015", "esnext"
23-
-l, --logLevel <level> Set log level: info, warn, error, silent
24-
--fail-on-warn Fail on warnings (default: true)
25-
--no-write Disable writing files to disk, incompatible with watch mode (default: true)
26-
-d, --out-dir <dir> Output directory (default: dist)
27-
--treeshake Tree-shake bundle (default: true)
28-
--sourcemap Generate source map (default: false)
29-
--shims Enable cjs and esm shims (default: false)
30-
--platform <platform> Target platform (default: node)
31-
--dts Generate dts files
32-
--publint Enable publint (default: false)
33-
--attw Enable Are the types wrong integration (default: false)
34-
--unused Enable unused dependencies check (default: false)
35-
-w, --watch [path] Watch mode
36-
--ignore-watch <path> Ignore custom paths in watch mode
37-
--from-vite [vitest] Reuse config from Vite or Vitest
38-
--report Size report (default: true)
39-
--env.* <value> Define compile-time env variables
40-
--env-file <file> Load environment variables from a file, when used together with --env, variables in --env take precedence
41-
--env-prefix <prefix> Prefix for env variables to inject into the bundle (default: VITE_PACK_,TSDOWN_)
42-
--on-success <command> Command to run on success
43-
--copy <dir> Copy files to output dir
44-
--public-dir <dir> Alias for --copy, deprecated
45-
--tsconfig <tsconfig> Set tsconfig path
46-
--unbundle Unbundle mode
47-
-W, --workspace [dir] Enable workspace mode
48-
-F, --filter <pattern> Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name
49-
--exports Generate export-related metadata for package.json (experimental)
50-
--exe Bundle as executable using Node.js SEA (experimental)
51-
-h, --help Display this message
14+
--config-loader <loader> Config loader to use: auto, native, unrun (default: auto)
15+
--no-config Disable config file (default: true)
16+
-f, --format <format> Bundle format: esm, cjs, iife, umd (default: esm)
17+
--clean Clean output directory, --no-clean to disable
18+
--deps.never-bundle <module> Mark dependencies as external
19+
--minify Minify output
20+
--devtools Enable devtools integration
21+
--debug [feat] Show debug logs
22+
--target <target> Bundle target, e.g "es2015", "esnext"
23+
-l, --logLevel <level> Set log level: info, warn, error, silent
24+
--fail-on-warn Fail on warnings (default: true)
25+
--no-write Disable writing files to disk, incompatible with watch mode (default: true)
26+
-d, --out-dir <dir> Output directory (default: dist)
27+
--treeshake Tree-shake bundle (default: true)
28+
--sourcemap Generate source map (default: false)
29+
--shims Enable cjs and esm shims (default: false)
30+
--platform <platform> Target platform (default: node)
31+
--dts Generate dts files
32+
--publint Enable publint (default: false)
33+
--attw Enable Are the types wrong integration (default: false)
34+
--unused Enable unused dependencies check (default: false)
35+
-w, --watch [path] Watch mode
36+
--ignore-watch <path> Ignore custom paths in watch mode
37+
--from-vite [vitest] Reuse config from Vite or Vitest
38+
--report Size report (default: true)
39+
--env.* <value> Define compile-time env variables
40+
--env-file <file> Load environment variables from a file, when used together with --env, variables in --env take precedence
41+
--env-prefix <prefix> Prefix for env variables to inject into the bundle (default: VITE_PACK_,TSDOWN_)
42+
--on-success <command> Command to run on success
43+
--copy <dir> Copy files to output dir
44+
--public-dir <dir> Alias for --copy, deprecated
45+
--tsconfig <tsconfig> Set tsconfig path
46+
--unbundle Unbundle mode
47+
--exe Bundle as executable
48+
-W, --workspace [dir] Enable workspace mode
49+
-F, --filter <pattern> Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name
50+
--exports Generate export-related metadata for package.json (experimental)
51+
-h, --help Display this message
5252

5353
> vp run pack # should build the library
5454
$ vp pack src/index.ts

packages/cli/src/pack-bin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cli
3333
default: 'esm',
3434
})
3535
.option('--clean', 'Clean output directory, --no-clean to disable')
36-
.option('--external <module>', 'Mark dependencies as external')
36+
.option('--deps.never-bundle <module>', 'Mark dependencies as external')
3737
.option('--minify', 'Minify output')
3838
.option('--devtools', 'Enable devtools integration')
3939
.option('--debug [feat]', 'Show debug logs')
@@ -71,10 +71,10 @@ cli
7171
.option('--public-dir <dir>', 'Alias for --copy, deprecated')
7272
.option('--tsconfig <tsconfig>', 'Set tsconfig path')
7373
.option('--unbundle', 'Unbundle mode')
74+
.option('--exe', 'Bundle as executable')
7475
.option('-W, --workspace [dir]', 'Enable workspace mode')
7576
.option('-F, --filter <pattern>', 'Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name')
7677
.option('--exports', 'Generate export-related metadata for package.json (experimental)')
77-
.option('--exe', 'Bundle as executable using Node.js SEA (experimental)')
7878
.action(async (input: string[], flags: InlineConfig) => {
7979
if (input.length > 0) {
8080
flags.entry = input;

0 commit comments

Comments
 (0)