tsdown 0.21.7 → 0.21.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { a as getPackageType, c as isGlobEntry, d as cleanOutDir, i as loadConfigFile, l as toObjectEntry, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as buildExe, t as mergeConfig, u as cleanChunks } from "./options-j2tUAf6W.mjs";
3
+ import { a as getPackageType, c as isGlobEntry, d as cleanOutDir, i as loadConfigFile, l as toObjectEntry, n as mergeUserOptions, o as writeExports, r as resolveUserConfig, s as buildExe, t as mergeConfig, u as cleanChunks } from "./options-8hmVMssn.mjs";
4
4
  import { r as fsRemove } from "./fs-Dd6Htx2P.mjs";
5
5
  import { a as pkgExists, l as slash, n as importWithError, o as promiseWithResolvers, t as debounce } from "./general-D3muxt2f.mjs";
6
6
  import { a as globalLogger, t as LogLevels } from "./logger-uV8l1UFa.mjs";
7
- import { a as getShimsInject, r as DepsPlugin } from "./format-_3CEX8E7.mjs";
8
- import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as copy, t as WatchPlugin } from "./watch-ZJbRq-K8.mjs";
9
- import { t as version } from "./package-CBgnLfjl.mjs";
7
+ import { i as getShimsInject, n as DepsPlugin } from "./format-CajNSstg.mjs";
8
+ import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, s as copy, t as WatchPlugin } from "./watch-D6EGzM6P.mjs";
9
+ import { t as version } from "./package-JOXUdJGa.mjs";
10
10
  import { mkdtemp, readFile, readdir, writeFile } from "node:fs/promises";
11
11
  import path from "node:path";
12
12
  import process from "node:process";
@@ -18,12 +18,12 @@ import { RE_CSS, RE_DTS, RE_JS, filename_js_to_dts } from "rolldown-plugin-dts/i
18
18
  import { tmpdir } from "node:os";
19
19
  const satisfies = __cjs_require("semver/functions/satisfies.js");
20
20
  import { exec, x } from "tinyexec";
21
+ import { formatWithOptions, inspect } from "node:util";
21
22
  import { clearRequireCache } from "import-without-cache";
22
23
  import { VERSION, build, watch } from "rolldown";
23
24
  const coerce = __cjs_require("semver/functions/coerce.js");
24
25
  import { Hookable } from "hookable";
25
26
  const treeKill = __cjs_require("tree-kill");
26
- import { formatWithOptions, inspect } from "node:util";
27
27
  import { importGlobPlugin } from "rolldown/experimental";
28
28
  //#region \0rolldown/runtime.js
29
29
  var __defProp = Object.defineProperty;
@@ -45,13 +45,14 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
45
45
  "**/test?(s)/**",
46
46
  "**/t?(e)mp/**"
47
47
  ];
48
- async function resolveWorkspace(config, inlineConfig) {
48
+ async function resolveWorkspace(config, inlineConfig, rootDeps) {
49
49
  const normalized = mergeConfig(config, inlineConfig);
50
50
  const rootCwd = normalized.cwd || process.cwd();
51
+ const deps = new Set(rootDeps);
51
52
  let { workspace } = normalized;
52
53
  if (!workspace) return {
53
54
  configs: [normalized],
54
- files: []
55
+ deps
55
56
  };
56
57
  if (workspace === true) workspace = {};
57
58
  else if (typeof workspace === "string" || Array.isArray(workspace)) workspace = { include: workspace };
@@ -69,22 +70,18 @@ async function resolveWorkspace(config, inlineConfig) {
69
70
  expandDirectories: false
70
71
  })).map((file) => slash(path.resolve(file)));
71
72
  if (packages.length === 0) throw new Error("No workspace packages found, please check your config");
72
- const files = [];
73
73
  return {
74
74
  configs: (await Promise.all(packages.map(async (cwd) => {
75
75
  debug$4("loading workspace config %s", cwd);
76
- const { configs, file } = await loadConfigFile({
76
+ const { configs, deps: workspaceDeps } = await loadConfigFile({
77
77
  ...inlineConfig,
78
78
  config: workspaceConfig,
79
79
  cwd
80
80
  }, cwd, normalized);
81
- if (file) {
82
- debug$4("loaded workspace config file %s", file);
83
- files.push(file);
84
- } else debug$4("no workspace config file found in %s", cwd);
81
+ workspaceDeps?.forEach((dep) => deps.add(dep));
85
82
  return configs.map((config) => mergeConfig(normalized, config));
86
83
  }))).flat(),
87
- files
84
+ deps
88
85
  };
89
86
  }
90
87
  //#endregion
@@ -93,24 +90,20 @@ const debug$3 = createDebug("tsdown:config");
93
90
  async function resolveConfig(inlineConfig) {
94
91
  debug$3("inline config %O", inlineConfig);
95
92
  if (inlineConfig.cwd) inlineConfig.cwd = path.resolve(inlineConfig.cwd);
96
- const { configs: rootConfigs, file } = await loadConfigFile(inlineConfig);
97
- const files = [];
98
- if (file) {
99
- files.push(file);
100
- debug$3("loaded root user config file %s", file);
101
- debug$3("root user configs %O", rootConfigs);
102
- } else debug$3("no root user config file found");
93
+ const { configs: rootConfigs, deps: rootDeps } = await loadConfigFile(inlineConfig);
94
+ const globalDeps = new Set(rootDeps);
103
95
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
104
- const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, inlineConfig);
96
+ const { configs: workspaceConfigs, deps: workspaceDeps } = await resolveWorkspace(rootConfig, inlineConfig, rootDeps);
105
97
  debug$3("workspace configs %O", workspaceConfigs);
106
- if (workspaceFiles) files.push(...workspaceFiles);
107
- return (await Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveUserConfig(config, inlineConfig)))).flat().filter((config) => !!config);
98
+ const configs = (await Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveUserConfig(config, inlineConfig, workspaceDeps)))).flat().filter((config) => !!config);
99
+ workspaceDeps.forEach((dep) => globalDeps.add(dep));
100
+ return configs;
108
101
  }))).flat();
109
102
  debug$3("resolved configs %O", configs);
110
103
  if (configs.length === 0) throw new Error("No valid configuration found.");
111
104
  return {
112
105
  configs,
113
- files
106
+ deps: globalDeps
114
107
  };
115
108
  }
116
109
  //#endregion
@@ -122,6 +115,23 @@ function warnLegacyCJS(config) {
122
115
  return version && satisfies(version, "^20.19.0 || >=22.12.0");
123
116
  })) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
124
117
  }
118
+ function CjsDtsReexportPlugin() {
119
+ return {
120
+ name: "tsdown:cjs-dts-reexport",
121
+ generateBundle(_options, bundle) {
122
+ for (const chunk of Object.values(bundle)) {
123
+ if (chunk.type !== "chunk" || !chunk.isEntry) continue;
124
+ if (!chunk.fileName.endsWith(".cjs") && !chunk.fileName.endsWith(".js")) continue;
125
+ const content = `export type * from './${path.basename(chunk.fileName.replace(RE_JS, ".d.mts"))}'\n`;
126
+ this.emitFile({
127
+ type: "prebuilt-chunk",
128
+ fileName: filename_js_to_dts(chunk.fileName),
129
+ code: content
130
+ });
131
+ }
132
+ }
133
+ };
134
+ }
125
135
  //#endregion
126
136
  //#region src/features/devtools.ts
127
137
  async function startDevtoolsUI(config) {
@@ -334,7 +344,7 @@ async function bundleDone(bundleByPkg, bundle) {
334
344
  async function packTarball(packageJsonPath) {
335
345
  const pkgDir = path.dirname(packageJsonPath);
336
346
  const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
337
- const { detect } = await import("./detect-h8ZFBH96.mjs");
347
+ const { detect } = await import("./detect-DN3DXXYt.mjs");
338
348
  try {
339
349
  const detected = await detect({ cwd: pkgDir });
340
350
  if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
@@ -457,8 +467,8 @@ function resolveChunkAddon(chunkAddon, format) {
457
467
  //#endregion
458
468
  //#region src/features/rolldown.ts
459
469
  const debug = createDebug("tsdown:rolldown");
460
- async function getBuildOptions(config, format, configFiles, bundle, cjsDts = false, isDualFormat) {
461
- const inputOptions = await resolveInputOptions(config, format, configFiles, bundle, cjsDts, isDualFormat);
470
+ async function getBuildOptions(config, format, configDeps, bundle, cjsDts = false, isDualFormat) {
471
+ const inputOptions = await resolveInputOptions(config, format, configDeps, bundle, cjsDts, isDualFormat);
462
472
  const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
463
473
  const rolldownConfig = {
464
474
  ...inputOptions,
@@ -468,7 +478,7 @@ async function getBuildOptions(config, format, configFiles, bundle, cjsDts = fal
468
478
  debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
469
479
  return rolldownConfig;
470
480
  }
471
- async function resolveInputOptions(config, format, configFiles, bundle, cjsDts, isDualFormat) {
481
+ async function resolveInputOptions(config, format, configDeps, bundle, cjsDts, isDualFormat) {
472
482
  const { alias, checks: { legacyCjs, ...checks } = {}, cjsDefault, cwd, deps: { neverBundle }, devtools, dts, entry, env, globImport, loader, logger, nameLabel, nodeProtocol, platform, plugins: userPlugins, report, shims, target, treeshake, tsconfig, unused, watch } = config;
473
483
  const plugins = [];
474
484
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
@@ -507,7 +517,7 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
507
517
  if (globImport) plugins.push(importGlobPlugin({ root: cwd }));
508
518
  }
509
519
  if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(config, cjsDts, isDualFormat));
510
- if (watch) plugins.push(WatchPlugin(configFiles, bundle));
520
+ if (watch) plugins.push(WatchPlugin(configDeps, bundle));
511
521
  if (!cjsDts) plugins.push(userPlugins);
512
522
  if (cssPostPlugins) plugins.push(...cssPostPlugins);
513
523
  const define = {
@@ -599,23 +609,6 @@ function handlePluginInspect(plugins) {
599
609
  else return `"rolldown plugin: ${plugins.name}"`;
600
610
  };
601
611
  }
602
- function CjsDtsReexportPlugin() {
603
- return {
604
- name: "tsdown:cjs-dts-reexport",
605
- generateBundle(_options, bundle) {
606
- for (const chunk of Object.values(bundle)) {
607
- if (chunk.type !== "chunk") continue;
608
- if (!chunk.fileName.endsWith(".cjs") && !chunk.fileName.endsWith(".js")) continue;
609
- const content = `export * from './${path.basename(chunk.fileName.replace(RE_JS, ".d.mts"))}'\n`;
610
- this.emitFile({
611
- type: "prebuilt-chunk",
612
- fileName: filename_js_to_dts(chunk.fileName),
613
- code: content
614
- });
615
- }
616
- }
617
- };
618
- }
619
612
  function CssGuardPlugin() {
620
613
  return {
621
614
  name: "tsdown:css-guard",
@@ -691,8 +684,8 @@ const asyncDispose = Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose");
691
684
  */
692
685
  async function build$1(inlineConfig = {}) {
693
686
  globalLogger.level = inlineConfig.logLevel || "info";
694
- const { configs, files: configFiles } = await resolveConfig(inlineConfig);
695
- return buildWithConfigs(configs, configFiles, () => build$1(inlineConfig));
687
+ const { configs, deps: configDeps } = await resolveConfig(inlineConfig);
688
+ return buildWithConfigs(configs, configDeps, () => build$1(inlineConfig));
696
689
  }
697
690
  /**
698
691
  * Build with `ResolvedConfigs`.
@@ -700,7 +693,7 @@ async function build$1(inlineConfig = {}) {
700
693
  * **Internal API, not for public use**
701
694
  * @private
702
695
  */
703
- async function buildWithConfigs(configs, configFiles, _restart) {
696
+ async function buildWithConfigs(configs, configDeps, _restart) {
704
697
  let cleanPromise;
705
698
  const clean = () => {
706
699
  if (cleanPromise) return cleanPromise;
@@ -721,7 +714,7 @@ async function buildWithConfigs(configs, configFiles, _restart) {
721
714
  }
722
715
  globalLogger.info("Build start");
723
716
  const bundles = await Promise.all(configs.map((options) => {
724
- return buildSingle(options, configFiles, options.pkg ? configChunksByPkg[options.pkg.packageJsonPath].formats.size > 1 : true, clean, restart, done);
717
+ return buildSingle(options, configDeps, options.pkg ? configChunksByPkg[options.pkg.packageJsonPath].formats.size > 1 : true, clean, restart, done);
725
718
  }));
726
719
  const firstDevtoolsConfig = configs.find((config) => config.devtools && config.devtools.ui);
727
720
  if (configs.some((config) => config.watch)) {
@@ -734,7 +727,7 @@ async function buildWithConfigs(configs, configFiles, _restart) {
734
727
  * Build a single configuration, without watch and shortcuts features.
735
728
  * @param config Resolved options
736
729
  */
737
- async function buildSingle(config, configFiles, isDualFormat, clean, restart, done) {
730
+ async function buildSingle(config, configDeps, isDualFormat, clean, restart, done) {
738
731
  const { format, dts, watch: watch$1, logger, outDir } = config;
739
732
  const { hooks, context } = await createHooks(config);
740
733
  warnLegacyCJS(config);
@@ -781,7 +774,7 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
781
774
  debouncedPostBuild.cancel();
782
775
  ab?.abort();
783
776
  }
784
- if (configFiles.includes(id) || endsWithConfig.test(id)) {
777
+ if (configDeps.has(id) || endsWithConfig.test(id)) {
785
778
  globalLogger.info(`Reload config: ${id}, restarting...`);
786
779
  restart();
787
780
  }
@@ -824,14 +817,14 @@ async function buildSingle(config, configFiles, isDualFormat, clean, restart, do
824
817
  });
825
818
  }
826
819
  async function initBuildOptions() {
827
- const buildOptions = await getBuildOptions(config, format, configFiles, bundle, false, isDualFormat);
820
+ const buildOptions = await getBuildOptions(config, format, configDeps, bundle, false, isDualFormat);
828
821
  await hooks.callHook("build:before", {
829
822
  ...context,
830
823
  buildOptions
831
824
  });
832
825
  if (debugRolldownConfigDir) await debugBuildOptions(debugRolldownConfigDir, config.name, format, buildOptions);
833
826
  const configs = [buildOptions];
834
- if (format === "cjs" && dts && (!isDualFormat || !dts.cjsReexport)) configs.push(await getBuildOptions(config, format, configFiles, bundle, true, isDualFormat));
827
+ if (format === "cjs" && dts && (!isDualFormat || !dts.cjsReexport)) configs.push(await getBuildOptions(config, format, configDeps, bundle, true, isDualFormat));
835
828
  return configs;
836
829
  }
837
830
  async function postBuild() {
@@ -1,4 +1,4 @@
1
- import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-DD-uKQPn.mjs";
1
+ import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-BZNNnDKc.mjs";
2
2
 
3
3
  //#region src/config/options.d.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as Resolve
7
7
  * **Internal API, not for public use**
8
8
  * @private
9
9
  */
10
- declare function resolveUserConfig(userConfig: UserConfig, inlineConfig: InlineConfig): Promise<ResolvedConfig[]>;
10
+ declare function resolveUserConfig(userConfig: UserConfig, inlineConfig: InlineConfig, configDeps: Set<string>): Promise<ResolvedConfig[]>;
11
11
  declare function mergeConfig(defaults: UserConfig, ...overrides: UserConfig[]): UserConfig;
12
12
  declare function mergeConfig(defaults: InlineConfig, ...overrides: InlineConfig[]): InlineConfig;
13
13
  //#endregion
package/dist/config.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./types-DD-uKQPn.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-BJiwtsMo.mjs";
1
+ import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./types-BZNNnDKc.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-CuK0i1Bc.mjs";
3
3
  export { UserConfig, UserConfigExport, UserConfigFn, defineConfig, mergeConfig };
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as mergeConfig } from "./options-j2tUAf6W.mjs";
1
+ import { t as mergeConfig } from "./options-8hmVMssn.mjs";
2
2
  //#region src/config.ts
3
3
  function defineConfig(options) {
4
4
  return options;
@@ -98,6 +98,7 @@ function DepsPlugin({ pkg, deps: { alwaysBundle, onlyBundle, skipNodeModulesBund
98
98
  for (const chunk of Object.values(bundle)) {
99
99
  if (chunk.type === "asset") continue;
100
100
  for (const id of chunk.moduleIds) {
101
+ if (id === shimFile) continue;
101
102
  const parsed = await readBundledDepInfo(id);
102
103
  if (!parsed) continue;
103
104
  deps.add(parsed.name);
@@ -211,15 +212,5 @@ function formatBytes(bytes) {
211
212
  if (bytes > 1e6) return `${(bytes / 1e6).toFixed(2)} MB`;
212
213
  return `${(bytes / 1e3).toFixed(2)} kB`;
213
214
  }
214
- function detectIndentation(jsonText) {
215
- const lines = jsonText.split(/\r?\n/);
216
- for (const line of lines) {
217
- const match = line.match(/^(\s+)\S/);
218
- if (!match) continue;
219
- if (match[1].includes(" ")) return " ";
220
- return match[1].length;
221
- }
222
- return 2;
223
- }
224
215
  //#endregion
225
- export { getShimsInject as a, resolveDepsConfig as i, formatBytes as n, DepsPlugin as r, detectIndentation as t };
216
+ export { getShimsInject as i, DepsPlugin as n, resolveDepsConfig as r, formatBytes as t };
@@ -0,0 +1,331 @@
1
+ import { InternalModuleFormat } from "rolldown";
2
+
3
+ //#region src/utils/types.d.ts
4
+ type Overwrite<T, U> = Omit<T, keyof U> & U;
5
+ type Awaitable<T> = T | Promise<T>;
6
+ type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
7
+ type Arrayable<T> = T | T[];
8
+ //#endregion
9
+ //#region src/utils/logger.d.ts
10
+ type LogType = "error" | "warn" | "info";
11
+ type LogLevel = LogType | "silent";
12
+ interface LoggerOptions {
13
+ allowClearScreen?: boolean;
14
+ customLogger?: Logger;
15
+ console?: Console;
16
+ failOnWarn?: boolean;
17
+ }
18
+ interface Logger {
19
+ level: LogLevel;
20
+ options?: LoggerOptions;
21
+ info: (...args: any[]) => void;
22
+ warn: (...args: any[]) => void;
23
+ warnOnce: (...args: any[]) => void;
24
+ error: (...args: any[]) => void;
25
+ success: (...args: any[]) => void;
26
+ clearScreen: (type: LogType) => void;
27
+ }
28
+ declare const globalLogger: Logger;
29
+ //#endregion
30
+ //#region node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
31
+ interface PackageJson {
32
+ /**
33
+ * The name is what your thing is called.
34
+ * Some rules:
35
+ * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
36
+ * - The name can’t start with a dot or an underscore.
37
+ * - New packages must not have uppercase letters in the name.
38
+ * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
39
+ */
40
+ name?: string;
41
+ /**
42
+ * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
43
+ */
44
+ version?: string;
45
+ /**
46
+ * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
47
+ */
48
+ description?: string;
49
+ /**
50
+ * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
51
+ */
52
+ keywords?: string[];
53
+ /**
54
+ * The url to the project homepage.
55
+ */
56
+ homepage?: string;
57
+ /**
58
+ * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
59
+ */
60
+ bugs?: string | {
61
+ url?: string;
62
+ email?: string;
63
+ };
64
+ /**
65
+ * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
66
+ */
67
+ license?: string;
68
+ /**
69
+ * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
70
+ * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
71
+ */
72
+ repository?: string | {
73
+ type: string;
74
+ url: string;
75
+ /**
76
+ * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
77
+ */
78
+ directory?: string;
79
+ };
80
+ /**
81
+ * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
82
+ */
83
+ scripts?: PackageJsonScripts;
84
+ /**
85
+ * If you set `"private": true` in your package.json, then npm will refuse to publish it.
86
+ */
87
+ private?: boolean;
88
+ /**
89
+ * The “author” is one person.
90
+ */
91
+ author?: PackageJsonPerson;
92
+ /**
93
+ * “contributors” is an array of people.
94
+ */
95
+ contributors?: PackageJsonPerson[];
96
+ /**
97
+ * An object containing a URL that provides up-to-date information
98
+ * about ways to help fund development of your package,
99
+ * a string URL, or an array of objects and string URLs
100
+ */
101
+ funding?: PackageJsonFunding | PackageJsonFunding[];
102
+ /**
103
+ * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
104
+ */
105
+ files?: string[];
106
+ /**
107
+ * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
108
+ * This should be a module ID relative to the root of your package folder.
109
+ * For most modules, it makes the most sense to have a main script and often not much else.
110
+ */
111
+ main?: string;
112
+ /**
113
+ * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
114
+ */
115
+ browser?: string | Record<string, string | false>;
116
+ /**
117
+ * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
118
+ */
119
+ unpkg?: string;
120
+ /**
121
+ * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
122
+ */
123
+ bin?: string | Record<string, string>;
124
+ /**
125
+ * Specify either a single file or an array of filenames to put in place for the `man` program to find.
126
+ */
127
+ man?: string | string[];
128
+ /**
129
+ * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
130
+ */
131
+ dependencies?: Record<string, string>;
132
+ /**
133
+ * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
134
+ * In this case, it’s best to map these additional items in a `devDependencies` object.
135
+ */
136
+ devDependencies?: Record<string, string>;
137
+ /**
138
+ * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
139
+ */
140
+ optionalDependencies?: Record<string, string>;
141
+ /**
142
+ * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
143
+ */
144
+ peerDependencies?: Record<string, string>;
145
+ /**
146
+ * TypeScript typings, typically ending by `.d.ts`.
147
+ */
148
+ types?: string;
149
+ /**
150
+ * This field is synonymous with `types`.
151
+ */
152
+ typings?: string;
153
+ /**
154
+ * Non-Standard Node.js alternate entry-point to main.
155
+ * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
156
+ */
157
+ module?: string;
158
+ /**
159
+ * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
160
+ *
161
+ * Docs:
162
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
163
+ *
164
+ * @default 'commonjs'
165
+ * @since Node.js v14
166
+ */
167
+ type?: "module" | "commonjs";
168
+ /**
169
+ * Alternate and extensible alternative to "main" entry point.
170
+ *
171
+ * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
172
+ *
173
+ * Docs:
174
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
175
+ *
176
+ * @since Node.js v12.7
177
+ */
178
+ exports?: PackageJsonExports;
179
+ /**
180
+ * Docs:
181
+ * - https://nodejs.org/api/packages.html#imports
182
+ */
183
+ imports?: Record<string, string | Record<string, string>>;
184
+ /**
185
+ * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
186
+ *
187
+ * This field is an array of glob patterns or an object with specific configurations for managing
188
+ * multiple packages in a single repository.
189
+ */
190
+ workspaces?: string[] | {
191
+ /**
192
+ * Workspace package paths. Glob patterns are supported.
193
+ */
194
+ packages?: string[];
195
+ /**
196
+ * Packages to block from hoisting to the workspace root.
197
+ * Uses glob patterns to match module paths in the dependency tree.
198
+ *
199
+ * Docs:
200
+ * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
201
+ */
202
+ nohoist?: string[];
203
+ };
204
+ /**
205
+ * The field is used to specify different TypeScript declaration files for
206
+ * different versions of TypeScript, allowing for version-specific type definitions.
207
+ */
208
+ typesVersions?: Record<string, Record<string, string[]>>;
209
+ /**
210
+ * You can specify which operating systems your module will run on:
211
+ * ```json
212
+ * {
213
+ * "os": ["darwin", "linux"]
214
+ * }
215
+ * ```
216
+ * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
217
+ * ```json
218
+ * {
219
+ * "os": ["!win32"]
220
+ * }
221
+ * ```
222
+ * The host operating system is determined by `process.platform`
223
+ * It is allowed to both block and allow an item, although there isn't any good reason to do this.
224
+ */
225
+ os?: string[];
226
+ /**
227
+ * If your code only runs on certain cpu architectures, you can specify which ones.
228
+ * ```json
229
+ * {
230
+ * "cpu": ["x64", "ia32"]
231
+ * }
232
+ * ```
233
+ * Like the `os` option, you can also block architectures:
234
+ * ```json
235
+ * {
236
+ * "cpu": ["!arm", "!mips"]
237
+ * }
238
+ * ```
239
+ * The host architecture is determined by `process.arch`
240
+ */
241
+ cpu?: string[];
242
+ /**
243
+ * This is a set of config values that will be used at publish-time.
244
+ */
245
+ publishConfig?: {
246
+ /**
247
+ * The registry that will be used if the package is published.
248
+ */
249
+ registry?: string;
250
+ /**
251
+ * The tag that will be used if the package is published.
252
+ */
253
+ tag?: string;
254
+ /**
255
+ * The access level that will be used if the package is published.
256
+ */
257
+ access?: "public" | "restricted";
258
+ /**
259
+ * **pnpm-only**
260
+ *
261
+ * By default, for portability reasons, no files except those listed in
262
+ * the bin field will be marked as executable in the resulting package
263
+ * archive. The executableFiles field lets you declare additional fields
264
+ * that must have the executable flag (+x) set even if
265
+ * they aren't directly accessible through the bin field.
266
+ */
267
+ executableFiles?: string[];
268
+ /**
269
+ * **pnpm-only**
270
+ *
271
+ * You also can use the field `publishConfig.directory` to customize
272
+ * the published subdirectory relative to the current `package.json`.
273
+ *
274
+ * It is expected to have a modified version of the current package in
275
+ * the specified directory (usually using third party build tools).
276
+ */
277
+ directory?: string;
278
+ /**
279
+ * **pnpm-only**
280
+ *
281
+ * When set to `true`, the project will be symlinked from the
282
+ * `publishConfig.directory` location during local development.
283
+ * @default true
284
+ */
285
+ linkDirectory?: boolean;
286
+ } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
287
+ /**
288
+ * See: https://nodejs.org/api/packages.html#packagemanager
289
+ * This field defines which package manager is expected to be used when working on the current project.
290
+ * Should be of the format: `<name>@<version>[#hash]`
291
+ */
292
+ packageManager?: string;
293
+ [key: string]: any;
294
+ }
295
+ /**
296
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
297
+ */
298
+ type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
299
+ /**
300
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
301
+ */
302
+ type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
303
+ /**
304
+ * See: https://pnpm.io/scripts#lifecycle-scripts
305
+ */
306
+ type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
307
+ type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
308
+ type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
309
+ type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
310
+ /**
311
+ * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
312
+ */
313
+ type PackageJsonPerson = string | {
314
+ name: string;
315
+ email?: string;
316
+ url?: string;
317
+ };
318
+ type PackageJsonFunding = string | {
319
+ url: string;
320
+ type?: string;
321
+ };
322
+ type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
323
+ type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
324
+ type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
325
+ /**
326
+ * Defines a PackageJson structure.
327
+ * @param pkg - The `package.json` content as an object. See {@link PackageJson}.
328
+ * @returns the same `package.json` object.
329
+ */
330
+ //#endregion
331
+ export { Arrayable as a, Overwrite as c, globalLogger as i, LogLevel as n, Awaitable as o, Logger as r, MarkPartial as s, PackageJson as t };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { i as Arrayable, n as Logger, r as globalLogger } from "./logger-DLaktdLm.mjs";
2
- import { A as RolldownContext, B as TsdownBundle, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject, F as DepsConfig, H as CopyOptions, L as NoExternalFn, M as ExeOptions, N as SeaConfig, O as PackageType, P as DevtoolsOptions, R as ResolvedDepsConfig, S as ChunkAddonFunction, T as OutExtensionFactory, U as CopyOptionsFn, V as CopyEntry, a as NormalizedFormat, b as AttwOptions, c as TreeshakingOptions, d as UserConfig, f as UserConfigExport, g as ReportOptions, h as Workspace, i as InlineConfig, j as TsdownHooks, k as BuildContext, l as TsdownInputOption, m as WithEnabled, n as DtsOptions, o as ResolvedConfig, p as UserConfigFn, r as Format, s as Sourcemap, t as CIOption, u as UnusedOptions, v as PublintOptions, w as OutExtensionContext, x as ChunkAddon, y as ExportsOptions, z as RolldownChunk } from "./types-DD-uKQPn.mjs";
3
- import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-BJiwtsMo.mjs";
1
+ import { a as Arrayable, i as globalLogger, r as Logger } from "./index-DraNj4FA.mjs";
2
+ import { A as PackageType, B as ResolvedDepsConfig, C as ChunkAddon, D as OutExtensionFactory, E as OutExtensionContext, F as SeaConfig, G as CopyOptionsFn, H as TsdownBundle, I as DevtoolsOptions, L as DepsConfig, M as RolldownContext, N as TsdownHooks, O as OutExtensionObject, P as ExeOptions, S as AttwOptions, T as ChunkAddonObject, U as CopyEntry, V as RolldownChunk, W as CopyOptions, a as NormalizedFormat, b as PublintOptions, c as TreeshakingOptions, d as UserConfig, f as UserConfigExport, g as ReportOptions, h as Workspace, i as InlineConfig, j as BuildContext, k as PackageJsonWithPath, l as TsdownInputOption, m as WithEnabled, n as DtsOptions, o as ResolvedConfig, p as UserConfigFn, r as Format, s as Sourcemap, t as CIOption, u as UnusedOptions, v as TsdownPlugin, w as ChunkAddonFunction, x as ExportsOptions, y as TsdownPluginOption, z as NoExternalFn } from "./types-BZNNnDKc.mjs";
3
+ import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-CuK0i1Bc.mjs";
4
4
  import * as Rolldown from "rolldown";
5
5
 
6
6
  //#region src/build.d.ts
@@ -14,9 +14,9 @@ declare function build(inlineConfig?: InlineConfig): Promise<TsdownBundle[]>;
14
14
  * **Internal API, not for public use**
15
15
  * @private
16
16
  */
17
- declare function buildWithConfigs(configs: ResolvedConfig[], configFiles: string[], _restart: () => void): Promise<TsdownBundle[]>;
17
+ declare function buildWithConfigs(configs: ResolvedConfig[], configDeps: Set<string>, _restart: () => void): Promise<TsdownBundle[]>;
18
18
  //#endregion
19
19
  //#region src/features/debug.d.ts
20
20
  declare function enableDebug(debug?: boolean | Arrayable<string>): void;
21
21
  //#endregion
22
- export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DepsConfig, DevtoolsOptions, DtsOptions, ExeOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, ResolvedDepsConfig, Rolldown, RolldownChunk, RolldownContext, SeaConfig, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
22
+ export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DepsConfig, DevtoolsOptions, DtsOptions, ExeOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, ResolvedDepsConfig, Rolldown, RolldownChunk, RolldownContext, SeaConfig, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, TsdownPlugin, TsdownPluginOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };