Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "migration-from-tsdown",
"scripts": {
"build": "tsdown",
"build": "tsdown --public-dir public",
"build:watch": "tsdown --watch",
"build:dts": "tsdown --dts"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default defineConfig({
outDir: 'dist',
format: ['esm', 'cjs'],
dts: true,
unbundle: true,
copy: 'public',
deps: { resolveDepSubpath: true, onlyBundle: false },
});
```

Expand Down Expand Up @@ -56,7 +59,7 @@ check package.json
{
"name": "migration-from-tsdown",
"scripts": {
"build": "vp pack",
"build": "vp pack --copy public",
"build:watch": "vp pack --watch",
"build:dts": "vp pack --dts",
"prepare": "vp config"
Expand Down Expand Up @@ -114,6 +117,9 @@ export default defineConfig({
outDir: 'dist',
format: ['esm', 'cjs'],
dts: true,
unbundle: true,
copy: 'public',
deps: { resolveDepSubpath: true, onlyBundle: false },
});
```

Expand Down Expand Up @@ -144,7 +150,7 @@ check package.json
{
"name": "migration-from-tsdown",
"scripts": {
"build": "vp pack",
"build": "vp pack --copy public",
"build:watch": "vp pack --watch",
"build:dts": "vp pack --dts",
"prepare": "vp config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default defineConfig({
outDir: 'dist',
format: ['esm', 'cjs'],
dts: { generator: 'tsgo' },
unbundle: true,
copy: 'public',
deps: { resolveDepSubpath: true, onlyBundle: false },
});
```

Expand All @@ -52,5 +55,8 @@ export default defineConfig({
outDir: 'dist',
format: ['esm', 'cjs'],
dts: { generator: 'tsgo' },
unbundle: true,
copy: 'public',
deps: { resolveDepSubpath: true, onlyBundle: false },
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export default defineConfig({
outDir: 'dist',
format: ['esm', 'cjs'],
dts: true,
bundle: false,
publicDir: 'public',
deps: { onlyAllowBundle: false },
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ VITE+ - The Unified Toolchain for the Web

◇ Migrated . to Vite+ <version>
• Node <version> pnpm <version>
• 2 config updates applied
• 2 config updates applied, 1 file had imports rewritten
```

## `vpt stat-file tsdown.config.json --assert-not file`
Expand All @@ -35,7 +35,11 @@ export default defineConfig({
"entry": "src/index.ts",
"outDir": "dist",
"format": ["esm", "cjs"],
"dts": true,
"dts": { generator: 'oxc', },
unbundle: true,
copy: "public",
css: { inject: true },
"deps": { resolveDepSubpath: true, onlyBundle: false },
"inputOptions": {
"cwd": "./src"
}
Expand Down Expand Up @@ -117,7 +121,11 @@ export default defineConfig({
"entry": "src/index.ts",
"outDir": "dist",
"format": ["esm", "cjs"],
"dts": true,
"dts": { generator: 'oxc', },
unbundle: true,
copy: "public",
css: { inject: true },
"deps": { resolveDepSubpath: true, onlyBundle: false },
"inputOptions": {
"cwd": "./src"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"entry": "src/index.ts",
"outDir": "dist",
"format": ["esm", "cjs"],
"dts": true,
"dts": { "oxc": true, "cjsReexport": false },
"bundle": false,
"publicDir": "public",
"injectStyle": true,
"deps": { "onlyAllowBundle": false },
"inputOptions": {
"cwd": "./src"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ the converted config uses vite-plus pack
```
import { defineConfig } from 'vite-plus/pack';

export default defineConfig({
export default defineConfig({ deps: { resolveDepSubpath: true },
entry: ['src/index.ts'],
dts: true,
format: ['esm', 'cjs'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package a gets a converted config
```
import { defineConfig } from 'vite-plus/pack';

export default defineConfig({
export default defineConfig({ deps: { resolveDepSubpath: true },
entry: ['src/index.ts'],
dts: true,
format: 'cjs',
Expand Down Expand Up @@ -74,7 +74,7 @@ package b gets a converted config
```
import { defineConfig } from 'vite-plus/pack';

export default defineConfig({
export default defineConfig({ deps: { resolveDepSubpath: true },
entry: ['src/index.ts'],
dts: true,
format: 'cjs',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
method copy asset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { helper } from './helper.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'tsdown';

export default defineConfig(() => ({
entry: 'src/index.ts',
bundle: false,
dts: { oxc: true },
outExtension() { return { js: '.custom.js' }; },
publicDir() { return ['assets']; },
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const externalOptions = ['foo'];

export default {
pack: [
{
external: externalOptions,
skipNodeModulesBundle: true,
inputOptions(options) { return { external: options.external }; },
bundle: false,
dts: { tsgo: true },
},
{
external: externalOptions,
deps: { skipNodeModulesBundle: true, dts: { neverBundle: ['types'] } },
bundle: false,
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const externalOptions = ['foo'];

export default {
pack: [
{ external: externalOptions, skipNodeModulesBundle: true, bundle: false, dts: { tsgo: true } },
{ external: externalOptions, deps: { skipNodeModulesBundle: true }, bundle: false },
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { foo } from 'foo';
export { externalValue } from './external.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const externalOptions = ['foo', './external.js'];
const externalAlias = externalOptions;

export default {
pack: [
{
entry: 'src/index.ts',
outDir: 'dist/top',
dts: false,
external: ['foo', './external.js'],
skipNodeModulesBundle: true,
},
{
entry: 'src/index.ts',
outDir: 'dist/nested',
dts: false,
external: ['foo', './external.js'],
deps: { skipNodeModulesBundle: true },
},
{
entry: 'src/index.ts',
outDir: 'dist/constant',
dts: false,
external: externalOptions,
skipNodeModulesBundle: true,
},
{
entry: 'src/index.ts',
outDir: 'dist/alias',
dts: false,
external: externalAlias,
deps: { skipNodeModulesBundle: true },
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const helper: number = 42;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { bundledValue } from '@fixture/pack-bundled';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from 'vite-plus';

const bundlePatterns = ['@fixture/pack-bundled'];

export default defineConfig({
pack: [
{
entry: 'src/index.ts', outDir: 'dist/literal', dts: false,
noExternal: ['@fixture/pack-bundled'],
},
{
entry: 'src/index.ts', outDir: 'dist/reference', dts: false,
noExternal: bundlePatterns,
},
{
entry: 'src/index.ts', outDir: 'dist/callback', dts: false,
noExternal: (id) => bundlePatterns.includes(id),
},
{
entry: 'src/index.ts', outDir: 'dist/method', dts: false,
noExternal(id) { return bundlePatterns.includes(id); },
deps: { onlyBundle: bundlePatterns },
},
{
entry: 'src/index.ts', outDir: 'dist/control', dts: false,
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const bundledValue = 42;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@fixture/pack-bundled",
"version": "1.0.0",
"type": "module",
"exports": "./index.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "migration-pack-tsdown-023",
"type": "module",
"private": true,
"scripts": {
"build": "vp pack --public-dir public"
},
"devDependencies": {
"vite-plus": "0.2.0"
},
"devEngines": {
"packageManager": {
"name": "npm",
"version": "11.16.0",
"onFail": "download"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copied asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[[case]]
name = "migration_pack_tsdown_023"
vp = "global"
comment = "Upgrade an existing Vite+ pack config without --full and preserve it on a second migration."
steps = [
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vpt", "print-file", "package.json"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
]

[[case]]
name = "migration_pack_tsdown_023_build"
vp = "global"
comment = "Build a migrated library and check that static assets and declarations are emitted."
steps = [
{ argv = ["vpt", "write-file", "vite.config.ts", "export default { pack: { entry: 'src/index.ts', bundle: false, publicDir: 'public', removeNodeProtocol: true, dts: { oxc: true, cjsReexport: false } } };"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vp", "run", "build"] },
{ argv = ["vpt", "stat-file", "dist/index.mjs", "--assert", "file"] },
{ argv = ["vpt", "stat-file", "dist/index.d.mts", "--assert", "file"] },
{ argv = ["vpt", "print-file", "dist/public/asset.txt"] },
]

[[case]]
name = "migration_pack_tsdown_023_external"
vp = "global"
comment = "Preserve external matchers when either skipNodeModulesBundle form becomes deps.neverBundle."
steps = [
{ argv = ["vpt", "cp", "external.config.txt", "vite.config.ts"], snapshot = false },
{ argv = ["vpt", "cp", "external-entry.txt", "src/index.ts"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "pack"], snapshot = false },
{ argv = ["vpt", "print-file", "dist/top/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/nested/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/constant/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/alias/index.mjs"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
]

[[case]]
name = "migration_pack_tsdown_023_concise_methods"
vp = "global"
comment = "Migrate a standalone concise arrow and method options, then check unbundled files and copied assets."
steps = [
{ argv = ["vpt", "cp", "concise.config.txt", "tsdown.config.ts"], snapshot = false },
{ argv = ["vpt", "write-file", "vite.config.ts", "import packConfig from './tsdown.config.js';\nexport default { pack: packConfig({}) };\n"], snapshot = false },
{ argv = ["vpt", "cp", "concise-entry.txt", "src/index.ts"], snapshot = false },
{ argv = ["vpt", "cp", "helper.txt", "src/helper.ts"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "tsdown.config.ts"] },
{ argv = ["vp", "pack"] },
{ argv = ["vpt", "stat-file", "dist/index.custom.js", "--assert", "file"] },
{ argv = ["vpt", "stat-file", "dist/helper.custom.js", "--assert", "file"] },
{ argv = ["vpt", "print-file", "dist/assets/asset.txt"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "tsdown.config.ts"] },
]

[[case]]
name = "migration_pack_tsdown_023_external_constants"
vp = "global"
comment = "Migrate constant external references with both skip forms without a manual-migration warning."
steps = [
{ argv = ["vpt", "cp", "external-constants.config.txt", "vite.config.ts"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
]

[[case]]
name = "migration_pack_tsdown_023_external_conflicts"
vp = "global"
comment = "Report conflicting dependency rules while preserving the pack options."
steps = [
{ argv = ["vpt", "cp", "external-conflicts.config.txt", "vite.config.ts"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
]

[[case]]
name = "migration_pack_tsdown_023_no_external"
vp = "global"
comment = "Migrate noExternal patterns, references, and callbacks and confirm the dependency remains bundled."
steps = [
{ argv = ["vpt", "cp", "no-external.config.txt", "vite.config.ts"], snapshot = false },
{ argv = ["vpt", "cp", "no-external-entry.txt", "src/index.ts"], snapshot = false },
{ argv = ["vpt", "json-edit", "package.json", "dependencies", '{"@fixture/pack-bundled":"file:./pack-dependency"}'], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "install"], snapshot = false, timeout = 120000 },
{ argv = ["vpt", "stat-file", "node_modules/@fixture/pack-bundled/index.js", "--assert", "file"] },
{ argv = ["vp", "pack", "--fail-on-warn"], snapshot = false },
{ argv = ["vpt", "print-file", "dist/literal/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/reference/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/callback/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/method/index.mjs"] },
{ argv = ["vpt", "print-file", "dist/control/index.mjs"] },
]
Loading
Loading