tsdown 0.21.7 → 0.21.8

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-CAjSicbD.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 { a as getShimsInject, r as DepsPlugin } from "./format-a5Q6w07o.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-C9ZHIctp.mjs";
9
+ import { t as version } from "./package-yVk5dXcU.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";
@@ -122,6 +122,23 @@ function warnLegacyCJS(config) {
122
122
  return version && satisfies(version, "^20.19.0 || >=22.12.0");
123
123
  })) 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
124
  }
125
+ function CjsDtsReexportPlugin() {
126
+ return {
127
+ name: "tsdown:cjs-dts-reexport",
128
+ generateBundle(_options, bundle) {
129
+ for (const chunk of Object.values(bundle)) {
130
+ if (chunk.type !== "chunk" || !chunk.isEntry) continue;
131
+ if (!chunk.fileName.endsWith(".cjs") && !chunk.fileName.endsWith(".js")) continue;
132
+ const content = `export type * from './${path.basename(chunk.fileName.replace(RE_JS, ".d.mts"))}'\n`;
133
+ this.emitFile({
134
+ type: "prebuilt-chunk",
135
+ fileName: filename_js_to_dts(chunk.fileName),
136
+ code: content
137
+ });
138
+ }
139
+ }
140
+ };
141
+ }
125
142
  //#endregion
126
143
  //#region src/features/devtools.ts
127
144
  async function startDevtoolsUI(config) {
@@ -334,7 +351,7 @@ async function bundleDone(bundleByPkg, bundle) {
334
351
  async function packTarball(packageJsonPath) {
335
352
  const pkgDir = path.dirname(packageJsonPath);
336
353
  const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
337
- const { detect } = await import("./detect-h8ZFBH96.mjs");
354
+ const { detect } = await import("./detect-DN3DXXYt.mjs");
338
355
  try {
339
356
  const detected = await detect({ cwd: pkgDir });
340
357
  if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
@@ -599,23 +616,6 @@ function handlePluginInspect(plugins) {
599
616
  else return `"rolldown plugin: ${plugins.name}"`;
600
617
  };
601
618
  }
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
619
  function CssGuardPlugin() {
620
620
  return {
621
621
  name: "tsdown:css-guard",
@@ -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-C7s2EXSK.mjs";
2
2
 
3
3
  //#region src/config/options.d.ts
4
4
  /**
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-C7s2EXSK.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-BjpbFAQr.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-CAjSicbD.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);
@@ -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 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-C7s2EXSK.mjs";
3
+ import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-BjpbFAQr.mjs";
4
4
  import * as Rolldown from "rolldown";
5
5
 
6
6
  //#region src/build.d.ts
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { n as buildWithConfigs, t as build } from "./build-DU-BFLB1.mjs";
2
- import { r as resolveUserConfig, t as mergeConfig } from "./options-j2tUAf6W.mjs";
1
+ import { n as buildWithConfigs, t as build } from "./build-y6nUUkVJ.mjs";
2
+ import { r as resolveUserConfig, t as mergeConfig } from "./options-CAjSicbD.mjs";
3
3
  import { a as globalLogger } from "./logger-uV8l1UFa.mjs";
4
4
  import { defineConfig } from "./config.mjs";
5
- import { t as enableDebug } from "./debug-BmAPbhgA.mjs";
5
+ import { t as enableDebug } from "./debug-CLlnG64L.mjs";
6
6
  import * as Rolldown from "rolldown";
7
7
  export { Rolldown, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
@@ -1,5 +1,8 @@
1
- import { n as Logger, o as MarkPartial, s as Overwrite } from "./logger-DLaktdLm.mjs";
1
+ import { c as Overwrite, r as Logger, s as MarkPartial } from "./index-DraNj4FA.mjs";
2
2
 
3
+ //#region src/features/target.d.ts
4
+ declare function expandBaselineTarget(targets: string[]): string[];
5
+ //#endregion
3
6
  //#region src/utils/fs.d.ts
4
7
  declare function fsExists(path: string): Promise<boolean>;
5
8
  declare function fsRemove(path: string): Promise<void>;
@@ -9,4 +12,4 @@ declare function toArray<T>(val: T | T[] | null | undefined, defaultValue?: T):
9
12
  declare function resolveComma<T extends string>(arr: T[]): T[];
10
13
  declare function importWithError<T>(moduleName: string): Promise<T>;
11
14
  //#endregion
12
- export { type Logger, type MarkPartial, type Overwrite, fsExists, fsRemove, importWithError, resolveComma, toArray };
15
+ export { type Logger, type MarkPartial, type Overwrite, expandBaselineTarget, fsExists, fsRemove, importWithError, resolveComma, toArray };
package/dist/internal.mjs CHANGED
@@ -1,3 +1,4 @@
1
1
  import { n as fsExists, r as fsRemove } from "./fs-Dd6Htx2P.mjs";
2
2
  import { n as importWithError, s as resolveComma, u as toArray } from "./general-D3muxt2f.mjs";
3
- export { fsExists, fsRemove, importWithError, resolveComma, toArray };
3
+ import { t as expandBaselineTarget } from "./target-s30wya8e.mjs";
4
+ export { expandBaselineTarget, fsExists, fsRemove, importWithError, resolveComma, toArray };
@@ -3,7 +3,8 @@ const __cjs_require = __cjs_createRequire(import.meta.url);
3
3
  import { a as lowestCommonAncestor, i as fsStat, n as fsExists, o as stripExtname, r as fsRemove } from "./fs-Dd6Htx2P.mjs";
4
4
  import { a as pkgExists, c as resolveRegex, l as slash, n as importWithError, r as matchPattern, s as resolveComma, u as toArray } from "./general-D3muxt2f.mjs";
5
5
  import { a as globalLogger, i as getNameLabel, n as createLogger, r as generateColor } from "./logger-uV8l1UFa.mjs";
6
- import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-_3CEX8E7.mjs";
6
+ import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-a5Q6w07o.mjs";
7
+ import { n as resolveTarget } from "./target-s30wya8e.mjs";
7
8
  import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
8
9
  import path from "node:path";
9
10
  import process, { env } from "node:process";
@@ -17,7 +18,6 @@ import { tmpdir } from "node:os";
17
18
  const satisfies = __cjs_require("semver/functions/satisfies.js");
18
19
  import { x } from "tinyexec";
19
20
  import { readFileSync, writeFileSync } from "node:fs";
20
- const minVersion = __cjs_require("semver/ranges/min-version.js");
21
21
  import { up } from "empathic/find";
22
22
  import { up as up$1 } from "empathic/package";
23
23
  import { pathToFileURL } from "node:url";
@@ -256,7 +256,7 @@ function shouldExclude(fileName, exclude) {
256
256
  return matchPattern(fileName, exclude);
257
257
  }
258
258
  async function generateExports(pkg, chunks, options, inlinedDeps) {
259
- let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy, inlinedDependencies: emitInlinedDeps = true, bin }, css, logger, cwd } = options;
259
+ let { exports: { devExports, all, packageJson = true, exclude, customExports, legacy, extensions, inlinedDependencies: emitInlinedDeps = true, bin }, css, logger, cwd } = options;
260
260
  const pkgRoot = path.dirname(pkg.packageJsonPath);
261
261
  let main, module, cjsTypes, esmTypes;
262
262
  const exportsMap = /* @__PURE__ */ new Map();
@@ -288,6 +288,7 @@ async function generateExports(pkg, chunks, options, inlinedDeps) {
288
288
  else module = distFile;
289
289
  } else if (name.endsWith("/index")) name = `./${name.slice(0, -6)}`;
290
290
  else name = `./${name}`;
291
+ if (extensions && name !== ".") name = `${name}.js`;
291
292
  let subExport = exportsMap.get(name);
292
293
  if (!subExport) {
293
294
  subExport = {};
@@ -447,28 +448,6 @@ function join(pkgRoot, outDir, fileName) {
447
448
  return `${outDirRelative ? `./${outDirRelative}` : "."}/${fileName}`;
448
449
  }
449
450
  //#endregion
450
- //#region src/features/target.ts
451
- function resolveTarget(logger, target, color, pkg, nameLabel) {
452
- if (target === false) return;
453
- if (target == null) {
454
- const pkgTarget = resolvePackageTarget(pkg);
455
- if (pkgTarget) target = pkgTarget;
456
- else return;
457
- }
458
- if (typeof target === "number") throw new TypeError(`Invalid target: ${target}`);
459
- const targets = resolveComma(toArray(target));
460
- if (targets.length) logger.info(nameLabel, `target${targets.length > 1 ? "s" : ""}: ${color(targets.join(", "))}`);
461
- return targets;
462
- }
463
- function resolvePackageTarget(pkg) {
464
- const nodeVersion = pkg?.engines?.node;
465
- if (!nodeVersion) return;
466
- const nodeMinVersion = minVersion(nodeVersion);
467
- if (!nodeMinVersion) return;
468
- if (nodeMinVersion.version === "0.0.0") return;
469
- return `node${nodeMinVersion.version}`;
470
- }
471
- //#endregion
472
451
  //#region src/features/tsconfig.ts
473
452
  function findTsconfig(cwd, name = "tsconfig.json") {
474
453
  return up(name, { cwd }) || false;
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.21.7";
2
+ var version = "0.21.8";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,5 +1,5 @@
1
- import { n as Logger } from "./logger-DLaktdLm.mjs";
2
- import { B as TsdownBundle, I as DepsPlugin, _ as ReportPlugin } from "./types-DD-uKQPn.mjs";
1
+ import { r as Logger } from "./index-DraNj4FA.mjs";
2
+ import { B as TsdownBundle, I as DepsPlugin, _ as ReportPlugin } from "./types-C7s2EXSK.mjs";
3
3
  import { Plugin } from "rolldown";
4
4
 
5
5
  //#region src/features/node-protocol.d.ts
package/dist/plugins.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { r as DepsPlugin } from "./format-_3CEX8E7.mjs";
2
- import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-ZJbRq-K8.mjs";
1
+ import { r as DepsPlugin } from "./format-a5Q6w07o.mjs";
2
+ import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-C9ZHIctp.mjs";
3
3
  export { DepsPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
package/dist/run.mjs CHANGED
@@ -2,8 +2,8 @@
2
2
  import { createRequire as __cjs_createRequire } from "node:module";
3
3
  const __cjs_require = __cjs_createRequire(import.meta.url);
4
4
  import { a as globalLogger } from "./logger-uV8l1UFa.mjs";
5
- import { t as version } from "./package-CBgnLfjl.mjs";
6
- import { t as enableDebug } from "./debug-BmAPbhgA.mjs";
5
+ import { t as version } from "./package-yVk5dXcU.mjs";
6
+ import { t as enableDebug } from "./debug-CLlnG64L.mjs";
7
7
  import module from "node:module";
8
8
  import process from "node:process";
9
9
  import { blue, hex, yellow } from "ansis";
@@ -20,7 +20,7 @@ cli.command("[...files]", "Bundle files", {
20
20
  }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
21
21
  globalLogger.level = flags.logLevel || "info";
22
22
  globalLogger.info(`${blue`tsdown v${version}`} powered by ${hex("#ff7e17")`rolldown v${VERSION}`}`);
23
- const { build } = await import("./build-DU-BFLB1.mjs").then((n) => n.r);
23
+ const { build } = await import("./build-y6nUUkVJ.mjs").then((n) => n.r);
24
24
  if (input.length > 0) flags.entry = input;
25
25
  await build(flags);
26
26
  });
@@ -0,0 +1,37 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+ const __cjs_require = __cjs_createRequire(import.meta.url);
3
+ import { s as resolveComma, u as toArray } from "./general-D3muxt2f.mjs";
4
+ const minVersion = __cjs_require("semver/ranges/min-version.js");
5
+ //#region src/features/target.ts
6
+ const BASELINE_WIDELY_AVAILABLE_TARGET = [
7
+ "chrome111",
8
+ "edge111",
9
+ "firefox114",
10
+ "safari16.4",
11
+ "ios16.4"
12
+ ];
13
+ function expandBaselineTarget(targets) {
14
+ return targets.flatMap((t) => t === "baseline-widely-available" ? BASELINE_WIDELY_AVAILABLE_TARGET : t);
15
+ }
16
+ function resolveTarget(logger, target, color, pkg, nameLabel) {
17
+ if (target === false) return;
18
+ if (target == null) {
19
+ const pkgTarget = resolvePackageTarget(pkg);
20
+ if (pkgTarget) target = pkgTarget;
21
+ else return;
22
+ }
23
+ if (typeof target === "number") throw new TypeError(`Invalid target: ${target}`);
24
+ const targets = expandBaselineTarget(resolveComma(toArray(target)));
25
+ if (targets.length) logger.info(nameLabel, `target${targets.length > 1 ? "s" : ""}: ${color(targets.join(", "))}`);
26
+ return targets;
27
+ }
28
+ function resolvePackageTarget(pkg) {
29
+ const nodeVersion = pkg?.engines?.node;
30
+ if (!nodeVersion) return;
31
+ const nodeMinVersion = minVersion(nodeVersion);
32
+ if (!nodeMinVersion) return;
33
+ if (nodeMinVersion.version === "0.0.0") return;
34
+ return `node${nodeMinVersion.version}`;
35
+ }
36
+ //#endregion
37
+ export { resolveTarget as n, expandBaselineTarget as t };
@@ -1,4 +1,4 @@
1
- import { a as Awaitable, i as Arrayable, n as Logger, o as MarkPartial, s as Overwrite, t as LogLevel } from "./logger-DLaktdLm.mjs";
1
+ import { a as Arrayable, c as Overwrite, n as LogLevel, o as Awaitable, r as Logger, s as MarkPartial, t as PackageJson } from "./index-DraNj4FA.mjs";
2
2
  import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, TreeshakingOptions } from "rolldown";
3
3
  import { Hookable } from "hookable";
4
4
  import { Buffer } from "node:buffer";
@@ -191,307 +191,6 @@ interface TsdownHooks {
191
191
  }) => void | Promise<void>;
192
192
  }
193
193
  //#endregion
194
- //#region node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
195
- interface PackageJson {
196
- /**
197
- * The name is what your thing is called.
198
- * Some rules:
199
- * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
200
- * - The name can’t start with a dot or an underscore.
201
- * - New packages must not have uppercase letters in the name.
202
- * - 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.
203
- */
204
- name?: string;
205
- /**
206
- * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
207
- */
208
- version?: string;
209
- /**
210
- * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
211
- */
212
- description?: string;
213
- /**
214
- * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
215
- */
216
- keywords?: string[];
217
- /**
218
- * The url to the project homepage.
219
- */
220
- homepage?: string;
221
- /**
222
- * 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.
223
- */
224
- bugs?: string | {
225
- url?: string;
226
- email?: string;
227
- };
228
- /**
229
- * 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.
230
- */
231
- license?: string;
232
- /**
233
- * 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.
234
- * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
235
- */
236
- repository?: string | {
237
- type: string;
238
- url: string;
239
- /**
240
- * 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:
241
- */
242
- directory?: string;
243
- };
244
- /**
245
- * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
246
- */
247
- scripts?: PackageJsonScripts;
248
- /**
249
- * If you set `"private": true` in your package.json, then npm will refuse to publish it.
250
- */
251
- private?: boolean;
252
- /**
253
- * The “author” is one person.
254
- */
255
- author?: PackageJsonPerson;
256
- /**
257
- * “contributors” is an array of people.
258
- */
259
- contributors?: PackageJsonPerson[];
260
- /**
261
- * An object containing a URL that provides up-to-date information
262
- * about ways to help fund development of your package,
263
- * a string URL, or an array of objects and string URLs
264
- */
265
- funding?: PackageJsonFunding | PackageJsonFunding[];
266
- /**
267
- * 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.
268
- */
269
- files?: string[];
270
- /**
271
- * 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.
272
- * This should be a module ID relative to the root of your package folder.
273
- * For most modules, it makes the most sense to have a main script and often not much else.
274
- */
275
- main?: string;
276
- /**
277
- * 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)
278
- */
279
- browser?: string | Record<string, string | false>;
280
- /**
281
- * 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.
282
- */
283
- unpkg?: string;
284
- /**
285
- * 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.
286
- */
287
- bin?: string | Record<string, string>;
288
- /**
289
- * Specify either a single file or an array of filenames to put in place for the `man` program to find.
290
- */
291
- man?: string | string[];
292
- /**
293
- * 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.
294
- */
295
- dependencies?: Record<string, string>;
296
- /**
297
- * 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.
298
- * In this case, it’s best to map these additional items in a `devDependencies` object.
299
- */
300
- devDependencies?: Record<string, string>;
301
- /**
302
- * 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.
303
- */
304
- optionalDependencies?: Record<string, string>;
305
- /**
306
- * 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.
307
- */
308
- peerDependencies?: Record<string, string>;
309
- /**
310
- * TypeScript typings, typically ending by `.d.ts`.
311
- */
312
- types?: string;
313
- /**
314
- * This field is synonymous with `types`.
315
- */
316
- typings?: string;
317
- /**
318
- * Non-Standard Node.js alternate entry-point to main.
319
- * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
320
- */
321
- module?: string;
322
- /**
323
- * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
324
- *
325
- * Docs:
326
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
327
- *
328
- * @default 'commonjs'
329
- * @since Node.js v14
330
- */
331
- type?: "module" | "commonjs";
332
- /**
333
- * Alternate and extensible alternative to "main" entry point.
334
- *
335
- * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
336
- *
337
- * Docs:
338
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
339
- *
340
- * @since Node.js v12.7
341
- */
342
- exports?: PackageJsonExports;
343
- /**
344
- * Docs:
345
- * - https://nodejs.org/api/packages.html#imports
346
- */
347
- imports?: Record<string, string | Record<string, string>>;
348
- /**
349
- * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
350
- *
351
- * This field is an array of glob patterns or an object with specific configurations for managing
352
- * multiple packages in a single repository.
353
- */
354
- workspaces?: string[] | {
355
- /**
356
- * Workspace package paths. Glob patterns are supported.
357
- */
358
- packages?: string[];
359
- /**
360
- * Packages to block from hoisting to the workspace root.
361
- * Uses glob patterns to match module paths in the dependency tree.
362
- *
363
- * Docs:
364
- * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
365
- */
366
- nohoist?: string[];
367
- };
368
- /**
369
- * The field is used to specify different TypeScript declaration files for
370
- * different versions of TypeScript, allowing for version-specific type definitions.
371
- */
372
- typesVersions?: Record<string, Record<string, string[]>>;
373
- /**
374
- * You can specify which operating systems your module will run on:
375
- * ```json
376
- * {
377
- * "os": ["darwin", "linux"]
378
- * }
379
- * ```
380
- * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
381
- * ```json
382
- * {
383
- * "os": ["!win32"]
384
- * }
385
- * ```
386
- * The host operating system is determined by `process.platform`
387
- * It is allowed to both block and allow an item, although there isn't any good reason to do this.
388
- */
389
- os?: string[];
390
- /**
391
- * If your code only runs on certain cpu architectures, you can specify which ones.
392
- * ```json
393
- * {
394
- * "cpu": ["x64", "ia32"]
395
- * }
396
- * ```
397
- * Like the `os` option, you can also block architectures:
398
- * ```json
399
- * {
400
- * "cpu": ["!arm", "!mips"]
401
- * }
402
- * ```
403
- * The host architecture is determined by `process.arch`
404
- */
405
- cpu?: string[];
406
- /**
407
- * This is a set of config values that will be used at publish-time.
408
- */
409
- publishConfig?: {
410
- /**
411
- * The registry that will be used if the package is published.
412
- */
413
- registry?: string;
414
- /**
415
- * The tag that will be used if the package is published.
416
- */
417
- tag?: string;
418
- /**
419
- * The access level that will be used if the package is published.
420
- */
421
- access?: "public" | "restricted";
422
- /**
423
- * **pnpm-only**
424
- *
425
- * By default, for portability reasons, no files except those listed in
426
- * the bin field will be marked as executable in the resulting package
427
- * archive. The executableFiles field lets you declare additional fields
428
- * that must have the executable flag (+x) set even if
429
- * they aren't directly accessible through the bin field.
430
- */
431
- executableFiles?: string[];
432
- /**
433
- * **pnpm-only**
434
- *
435
- * You also can use the field `publishConfig.directory` to customize
436
- * the published subdirectory relative to the current `package.json`.
437
- *
438
- * It is expected to have a modified version of the current package in
439
- * the specified directory (usually using third party build tools).
440
- */
441
- directory?: string;
442
- /**
443
- * **pnpm-only**
444
- *
445
- * When set to `true`, the project will be symlinked from the
446
- * `publishConfig.directory` location during local development.
447
- * @default true
448
- */
449
- linkDirectory?: boolean;
450
- } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
451
- /**
452
- * See: https://nodejs.org/api/packages.html#packagemanager
453
- * This field defines which package manager is expected to be used when working on the current project.
454
- * Should be of the format: `<name>@<version>[#hash]`
455
- */
456
- packageManager?: string;
457
- [key: string]: any;
458
- }
459
- /**
460
- * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
461
- */
462
- type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
463
- /**
464
- * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
465
- */
466
- type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
467
- /**
468
- * See: https://pnpm.io/scripts#lifecycle-scripts
469
- */
470
- type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
471
- type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
472
- type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
473
- type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
474
- /**
475
- * 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.
476
- */
477
- type PackageJsonPerson = string | {
478
- name: string;
479
- email?: string;
480
- url?: string;
481
- };
482
- type PackageJsonFunding = string | {
483
- url: string;
484
- type?: string;
485
- };
486
- type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
487
- type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
488
- type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
489
- /**
490
- * Defines a PackageJson structure.
491
- * @param pkg - The `package.json` content as an object. See {@link PackageJson}.
492
- * @returns the same `package.json` object.
493
- */
494
- //#endregion
495
194
  //#region src/utils/package.d.ts
496
195
  interface PackageJsonWithPath extends PackageJson {
497
196
  packageJsonPath: string;
@@ -568,7 +267,7 @@ interface AttwOptions extends CheckPackageOptions {
568
267
  * ignoreRules: ['no-resolution', 'false-cjs']
569
268
  * ```
570
269
  */
571
- ignoreRules?: string[];
270
+ ignoreRules?: ("no-resolution" | "untyped-resolution" | "false-cjs" | "false-esm" | "cjs-resolves-to-esm" | "fallback-condition" | "cjs-only-exports-default" | "named-exports" | "false-export-default" | "missing-export-equals" | "unexpected-module-syntax" | "internal-resolution-error" | (string & {}))[];
572
271
  }
573
272
  //#endregion
574
273
  //#region src/features/pkg/exports.d.ts
@@ -643,6 +342,18 @@ interface ExportsOptions {
643
342
  */
644
343
  inlinedDependencies?: boolean;
645
344
  /**
345
+ * Add file extensions to subpath export keys.
346
+ *
347
+ * When enabled, all subpath exports (except the root `"."`) will include
348
+ * a `.js` extension in the key (e.g., `"./utils.js"` instead of `"./utils"`).
349
+ *
350
+ * This follows the Node.js recommendation for subpath exports:
351
+ * @see {@link https://nodejs.org/api/packages.html#extensions-in-subpaths}
352
+ *
353
+ * @default false
354
+ */
355
+ extensions?: boolean;
356
+ /**
646
357
  * Auto-generate the `bin` field in package.json.
647
358
  *
648
359
  * - `true`: Auto-detect entry chunks with shebangs. Uses package name (without scope) as bin name.
@@ -807,7 +518,7 @@ interface UserConfig {
807
518
  * If not set, defaults to the value of `engines.node` in your project's `package.json`.
808
519
  * If no `engines.node` field exists, no syntax transformations are applied.
809
520
  *
810
- * Accepts a single target (e.g., `'es2020'`, `'node18'`), an array of targets, or `false` to disable all transformations.
521
+ * Accepts a single target (e.g., `'es2020'`, `'node18'`, `'baseline-widely-available'`), an array of targets, or `false` to disable all transformations.
811
522
  *
812
523
  * @see {@link https://tsdown.dev/options/target#supported-targets} for a list of valid targets and more details.
813
524
  *
@@ -1,7 +1,7 @@
1
1
  import { n as fsExists, t as fsCopy } from "./fs-Dd6Htx2P.mjs";
2
2
  import { i as noop, s as resolveComma, u as toArray } from "./general-D3muxt2f.mjs";
3
3
  import { o as prettyFormat } from "./logger-uV8l1UFa.mjs";
4
- import { n as formatBytes } from "./format-_3CEX8E7.mjs";
4
+ import { n as formatBytes } from "./format-a5Q6w07o.mjs";
5
5
  import { builtinModules } from "node:module";
6
6
  import { chmod } from "node:fs/promises";
7
7
  import path from "node:path";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsdown",
3
3
  "type": "module",
4
- "version": "0.21.7",
4
+ "version": "0.21.8",
5
5
  "description": "The Elegant Bundler for Libraries",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -52,8 +52,8 @@
52
52
  "publint": "^0.3.0",
53
53
  "typescript": "^5.0.0 || ^6.0.0",
54
54
  "unplugin-unused": "^0.5.0",
55
- "@tsdown/css": "0.21.7",
56
- "@tsdown/exe": "0.21.7"
55
+ "@tsdown/css": "0.21.8",
56
+ "@tsdown/exe": "0.21.8"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@arethetypeswrong/core": {
@@ -81,17 +81,17 @@
81
81
  "dependencies": {
82
82
  "ansis": "^4.2.0",
83
83
  "cac": "^7.0.0",
84
- "defu": "^6.1.4",
84
+ "defu": "^6.1.7",
85
85
  "empathic": "^2.0.0",
86
86
  "hookable": "^6.1.0",
87
87
  "import-without-cache": "^0.2.5",
88
88
  "obug": "^2.1.1",
89
89
  "picomatch": "^4.0.4",
90
- "rolldown": "1.0.0-rc.12",
90
+ "rolldown": "1.0.0-rc.15",
91
91
  "rolldown-plugin-dts": "^0.23.2",
92
92
  "semver": "^7.7.4",
93
- "tinyexec": "^1.0.4",
94
- "tinyglobby": "^0.2.15",
93
+ "tinyexec": "^1.1.1",
94
+ "tinyglobby": "^0.2.16",
95
95
  "tree-kill": "^1.2.2",
96
96
  "unconfig-core": "^7.5.0",
97
97
  "unrun": "^0.2.34"
@@ -106,40 +106,41 @@
106
106
  "@sxzz/eslint-config": "^7.8.4",
107
107
  "@sxzz/prettier-config": "^2.3.1",
108
108
  "@sxzz/test-utils": "^0.5.16",
109
- "@types/node": "^25.5.0",
110
- "@types/picomatch": "^4.0.2",
109
+ "@types/node": "^25.6.0",
110
+ "@types/picomatch": "^4.0.3",
111
111
  "@types/semver": "^7.7.1",
112
- "@typescript/native-preview": "7.0.0-dev.20260328.1",
113
- "@unocss/eslint-plugin": "^66.6.7",
114
- "@vitejs/devtools": "^0.1.11",
115
- "@vitest/coverage-v8": "^4.1.2",
116
- "@vitest/ui": "^4.1.2",
112
+ "@typescript/native-preview": "7.0.0-dev.20260413.1",
113
+ "@unocss/eslint-plugin": "^66.6.8",
114
+ "@vitejs/devtools": "^0.1.13",
115
+ "@vitest/coverage-v8": "^4.1.4",
116
+ "@vitest/ui": "^4.1.4",
117
117
  "@vueuse/core": "^14.2.1",
118
+ "baseline-browser-mapping": "^2.10.18",
118
119
  "bumpp": "^11.0.1",
119
120
  "dedent": "^1.7.2",
120
- "eslint": "^10.1.0",
121
+ "eslint": "^10.2.0",
121
122
  "is-in-ci": "^2.0.0",
122
123
  "memfs": "^4.57.1",
123
124
  "package-manager-detector": "^1.6.0",
124
125
  "pkg-types": "^2.3.0",
125
- "postcss": "^8.5.8",
126
+ "postcss": "^8.5.9",
126
127
  "postcss-import": "^16.1.1",
127
- "prettier": "^3.8.1",
128
+ "prettier": "^3.8.2",
128
129
  "publint": "^0.3.18",
129
- "rolldown-plugin-dts-snapshot": "^0.4.0",
130
130
  "rolldown-plugin-require-cjs": "^0.4.0",
131
- "sass": "^1.98.0",
131
+ "sass": "^1.99.0",
132
+ "tsnapi": "^0.1.2",
132
133
  "typescript": "~6.0.2",
133
- "unocss": "^66.6.7",
134
+ "unocss": "^66.6.8",
134
135
  "unplugin-ast": "^0.16.0",
135
- "unplugin-raw": "^0.6.4",
136
+ "unplugin-raw": "^0.7.0",
136
137
  "unplugin-unused": "^0.5.7",
137
138
  "unplugin-vue": "^7.1.1",
138
- "vite": "^8.0.3",
139
- "vitest": "^4.1.2",
140
- "vue": "^3.5.31",
141
- "@tsdown/css": "0.21.7",
142
- "@tsdown/exe": "0.21.7"
139
+ "vite": "^8.0.8",
140
+ "vitest": "^4.1.4",
141
+ "vue": "^3.5.32",
142
+ "@tsdown/exe": "0.21.8",
143
+ "@tsdown/css": "0.21.8"
143
144
  },
144
145
  "prettier": "@sxzz/prettier-config",
145
146
  "scripts": {
@@ -1,30 +0,0 @@
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
- export { Awaitable as a, Arrayable as i, Logger as n, MarkPartial as o, globalLogger as r, Overwrite as s, LogLevel as t };
File without changes