tsdown 0.18.2 → 0.18.3

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.
package/dist/config.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { h as UserConfigFn, m as UserConfigExport, p as UserConfig } from "./index-BJCpuL9t.mjs";
1
+ import { h as UserConfigFn, m as UserConfigExport, p as UserConfig } from "./index-BuAkqPeD.mjs";
2
2
 
3
3
  //#region src/config.d.ts
4
4
 
@@ -3,7 +3,6 @@ import { BuildOptions, ExternalOption, InputOptions, InternalModuleFormat, Minif
3
3
  import { Hookable } from "hookable";
4
4
  import { Options as DtsOptions } from "rolldown-plugin-dts";
5
5
  import { StartOptions } from "@vitejs/devtools/cli-commands";
6
- import { PackageJson } from "pkg-types";
7
6
  import { CheckPackageOptions } from "@arethetypeswrong/core";
8
7
  import { Options as PublintOptions } from "publint";
9
8
  import { Options as UnusedOptions } from "unplugin-unused";
@@ -11,7 +10,7 @@ import { Options as UnusedOptions } from "unplugin-unused";
11
10
  //#region src/utils/types.d.ts
12
11
  type Overwrite<T, U> = Omit<T, keyof U> & U;
13
12
  type Awaitable<T> = T | Promise<T>;
14
- type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
13
+ type MarkPartial<T, K$1 extends keyof T> = Omit<Required<T>, K$1> & Partial<Pick<T, K$1>>;
15
14
  type Arrayable<T> = T | T[];
16
15
  //#endregion
17
16
  //#region src/features/copy.d.ts
@@ -92,6 +91,309 @@ interface TsdownHooks {
92
91
  }) => void | Promise<void>;
93
92
  }
94
93
  //#endregion
94
+ //#region node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
95
+
96
+ interface PackageJson {
97
+ /**
98
+ * The name is what your thing is called.
99
+ * Some rules:
100
+ * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
101
+ * - The name can’t start with a dot or an underscore.
102
+ * - New packages must not have uppercase letters in the name.
103
+ * - 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.
104
+ */
105
+ name?: string;
106
+ /**
107
+ * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
108
+ */
109
+ version?: string;
110
+ /**
111
+ * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
112
+ */
113
+ description?: string;
114
+ /**
115
+ * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
116
+ */
117
+ keywords?: string[];
118
+ /**
119
+ * The url to the project homepage.
120
+ */
121
+ homepage?: string;
122
+ /**
123
+ * 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.
124
+ */
125
+ bugs?: string | {
126
+ url?: string;
127
+ email?: string;
128
+ };
129
+ /**
130
+ * 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.
131
+ */
132
+ license?: string;
133
+ /**
134
+ * 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.
135
+ * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
136
+ */
137
+ repository?: string | {
138
+ type: string;
139
+ url: string;
140
+ /**
141
+ * 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:
142
+ */
143
+ directory?: string;
144
+ };
145
+ /**
146
+ * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
147
+ */
148
+ scripts?: PackageJsonScripts;
149
+ /**
150
+ * If you set `"private": true` in your package.json, then npm will refuse to publish it.
151
+ */
152
+ private?: boolean;
153
+ /**
154
+ * The “author” is one person.
155
+ */
156
+ author?: PackageJsonPerson;
157
+ /**
158
+ * “contributors” is an array of people.
159
+ */
160
+ contributors?: PackageJsonPerson[];
161
+ /**
162
+ * An object containing a URL that provides up-to-date information
163
+ * about ways to help fund development of your package,
164
+ * a string URL, or an array of objects and string URLs
165
+ */
166
+ funding?: PackageJsonFunding | PackageJsonFunding[];
167
+ /**
168
+ * 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.
169
+ */
170
+ files?: string[];
171
+ /**
172
+ * 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.
173
+ * This should be a module ID relative to the root of your package folder.
174
+ * For most modules, it makes the most sense to have a main script and often not much else.
175
+ */
176
+ main?: string;
177
+ /**
178
+ * 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)
179
+ */
180
+ browser?: string | Record<string, string | false>;
181
+ /**
182
+ * 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.
183
+ */
184
+ unpkg?: string;
185
+ /**
186
+ * 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.
187
+ */
188
+ bin?: string | Record<string, string>;
189
+ /**
190
+ * Specify either a single file or an array of filenames to put in place for the `man` program to find.
191
+ */
192
+ man?: string | string[];
193
+ /**
194
+ * 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.
195
+ */
196
+ dependencies?: Record<string, string>;
197
+ /**
198
+ * 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.
199
+ * In this case, it’s best to map these additional items in a `devDependencies` object.
200
+ */
201
+ devDependencies?: Record<string, string>;
202
+ /**
203
+ * 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.
204
+ */
205
+ optionalDependencies?: Record<string, string>;
206
+ /**
207
+ * 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.
208
+ */
209
+ peerDependencies?: Record<string, string>;
210
+ /**
211
+ * TypeScript typings, typically ending by `.d.ts`.
212
+ */
213
+ types?: string;
214
+ /**
215
+ * This field is synonymous with `types`.
216
+ */
217
+ typings?: string;
218
+ /**
219
+ * Non-Standard Node.js alternate entry-point to main.
220
+ * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
221
+ */
222
+ module?: string;
223
+ /**
224
+ * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
225
+ *
226
+ * Docs:
227
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
228
+ *
229
+ * @default 'commonjs'
230
+ * @since Node.js v14
231
+ */
232
+ type?: "module" | "commonjs";
233
+ /**
234
+ * Alternate and extensible alternative to "main" entry point.
235
+ *
236
+ * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
237
+ *
238
+ * Docs:
239
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
240
+ *
241
+ * @since Node.js v12.7
242
+ */
243
+ exports?: PackageJsonExports;
244
+ /**
245
+ * Docs:
246
+ * - https://nodejs.org/api/packages.html#imports
247
+ */
248
+ imports?: Record<string, string | Record<string, string>>;
249
+ /**
250
+ * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
251
+ *
252
+ * This field is an array of glob patterns or an object with specific configurations for managing
253
+ * multiple packages in a single repository.
254
+ */
255
+ workspaces?: string[] | {
256
+ /**
257
+ * Workspace package paths. Glob patterns are supported.
258
+ */
259
+ packages?: string[];
260
+ /**
261
+ * Packages to block from hoisting to the workspace root.
262
+ * Uses glob patterns to match module paths in the dependency tree.
263
+ *
264
+ * Docs:
265
+ * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
266
+ */
267
+ nohoist?: string[];
268
+ };
269
+ /**
270
+ * The field is used to specify different TypeScript declaration files for
271
+ * different versions of TypeScript, allowing for version-specific type definitions.
272
+ */
273
+ typesVersions?: Record<string, Record<string, string[]>>;
274
+ /**
275
+ * You can specify which operating systems your module will run on:
276
+ * ```json
277
+ * {
278
+ * "os": ["darwin", "linux"]
279
+ * }
280
+ * ```
281
+ * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
282
+ * ```json
283
+ * {
284
+ * "os": ["!win32"]
285
+ * }
286
+ * ```
287
+ * The host operating system is determined by `process.platform`
288
+ * It is allowed to both block and allow an item, although there isn't any good reason to do this.
289
+ */
290
+ os?: string[];
291
+ /**
292
+ * If your code only runs on certain cpu architectures, you can specify which ones.
293
+ * ```json
294
+ * {
295
+ * "cpu": ["x64", "ia32"]
296
+ * }
297
+ * ```
298
+ * Like the `os` option, you can also block architectures:
299
+ * ```json
300
+ * {
301
+ * "cpu": ["!arm", "!mips"]
302
+ * }
303
+ * ```
304
+ * The host architecture is determined by `process.arch`
305
+ */
306
+ cpu?: string[];
307
+ /**
308
+ * This is a set of config values that will be used at publish-time.
309
+ */
310
+ publishConfig?: {
311
+ /**
312
+ * The registry that will be used if the package is published.
313
+ */
314
+ registry?: string;
315
+ /**
316
+ * The tag that will be used if the package is published.
317
+ */
318
+ tag?: string;
319
+ /**
320
+ * The access level that will be used if the package is published.
321
+ */
322
+ access?: "public" | "restricted";
323
+ /**
324
+ * **pnpm-only**
325
+ *
326
+ * By default, for portability reasons, no files except those listed in
327
+ * the bin field will be marked as executable in the resulting package
328
+ * archive. The executableFiles field lets you declare additional fields
329
+ * that must have the executable flag (+x) set even if
330
+ * they aren't directly accessible through the bin field.
331
+ */
332
+ executableFiles?: string[];
333
+ /**
334
+ * **pnpm-only**
335
+ *
336
+ * You also can use the field `publishConfig.directory` to customize
337
+ * the published subdirectory relative to the current `package.json`.
338
+ *
339
+ * It is expected to have a modified version of the current package in
340
+ * the specified directory (usually using third party build tools).
341
+ */
342
+ directory?: string;
343
+ /**
344
+ * **pnpm-only**
345
+ *
346
+ * When set to `true`, the project will be symlinked from the
347
+ * `publishConfig.directory` location during local development.
348
+ * @default true
349
+ */
350
+ linkDirectory?: boolean;
351
+ } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
352
+ /**
353
+ * See: https://nodejs.org/api/packages.html#packagemanager
354
+ * This field defines which package manager is expected to be used when working on the current project.
355
+ * Should be of the format: `<name>@<version>[#hash]`
356
+ */
357
+ packageManager?: string;
358
+ [key: string]: any;
359
+ }
360
+ /**
361
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
362
+ */
363
+ type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
364
+ /**
365
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
366
+ */
367
+ type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
368
+ /**
369
+ * See: https://pnpm.io/scripts#lifecycle-scripts
370
+ */
371
+ type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
372
+ type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
373
+ type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
374
+ type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
375
+ /**
376
+ * 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.
377
+ */
378
+ type PackageJsonPerson = string | {
379
+ name: string;
380
+ email?: string;
381
+ url?: string;
382
+ };
383
+ type PackageJsonFunding = string | {
384
+ url: string;
385
+ type?: string;
386
+ };
387
+ type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
388
+ type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
389
+ type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
390
+
391
+ /**
392
+ * Defines a PackageJson structure.
393
+ * @param pkg - The `package.json` content as an object. See {@link PackageJson}.
394
+ * @returns the same `package.json` object.
395
+ */
396
+ //#endregion
95
397
  //#region src/utils/package.d.ts
96
398
  interface PackageJsonWithPath extends PackageJson {
97
399
  packageJsonPath: string;
@@ -145,6 +447,29 @@ interface AttwOptions extends CheckPackageOptions {
145
447
  * @default 'warn'
146
448
  */
147
449
  level?: "error" | "warn";
450
+ /**
451
+ * List of problem types to ignore by rule name.
452
+ *
453
+ * The available values are:
454
+ * - `no-resolution`
455
+ * - `untyped-resolution`
456
+ * - `false-cjs`
457
+ * - `false-esm`
458
+ * - `cjs-resolves-to-esm`
459
+ * - `fallback-condition`
460
+ * - `cjs-only-exports-default`
461
+ * - `named-exports`
462
+ * - `false-export-default`
463
+ * - `missing-export-equals`
464
+ * - `unexpected-module-syntax`
465
+ * - `internal-resolution-error`
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * ignoreRules: ['no-resolution', 'false-cjs']
470
+ * ```
471
+ */
472
+ ignoreRules?: string[];
148
473
  }
149
474
  //#endregion
150
475
  //#region src/utils/chunks.d.ts
@@ -343,7 +668,7 @@ interface UserConfig {
343
668
  */
344
669
  target?: string | string[] | false;
345
670
  /**
346
- * Compile-time env variables.
671
+ * Compile-time env variables, which can be accessed via `import.meta.env` or `process.env`.
347
672
  * @example
348
673
  * ```json
349
674
  * {
@@ -353,6 +678,17 @@ interface UserConfig {
353
678
  * ```
354
679
  */
355
680
  env?: Record<string, any>;
681
+ /**
682
+ * Path to env file providing compile-time env variables.
683
+ * @example
684
+ * `.env`, `.env.production`, etc.
685
+ */
686
+ envFile?: string;
687
+ /**
688
+ * When loading env variables from `envFile`, only include variables with these prefixes.
689
+ * @default 'TSDOWN_'
690
+ */
691
+ envPrefix?: string | string[];
356
692
  define?: Record<string, string>;
357
693
  /** @default false */
358
694
  shims?: boolean;
@@ -628,7 +964,7 @@ type UserConfigFn = (inlineConfig: InlineConfig, context: {
628
964
  ci: boolean;
629
965
  }) => Awaitable<Arrayable<UserConfig>>;
630
966
  type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
631
- type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "silent" | "bundle" | "removeNodeProtocol" | "logLevel" | "failOnWarn" | "customLogger">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer">, {
967
+ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "silent" | "bundle" | "removeNodeProtocol" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer">, {
632
968
  /** Resolved entry map (after glob expansion) */
633
969
  entry: Record<string, string>;
634
970
  nameLabel: string | undefined;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as OutExtensionFactory, B as CopyOptionsFn, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, I as TsdownHooks, L as DebugOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CopyEntry, S as ExportsOptions, T as AttwOptions, _ as Workspace, a as NoExternalFn, b as Logger, c as ResolvedConfig, d as TsdownInputOption, f as UnusedOptions, g as WithEnabled, h as UserConfigFn, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as Sourcemap, m as UserConfigExport, n as DtsOptions, o as NormalizedFormat, p as UserConfig, r as Format, s as PublintOptions, t as CIOption, u as TreeshakingOptions, v as ReportOptions, w as TsdownBundle, x as globalLogger, z as CopyOptions } from "./index-BJCpuL9t.mjs";
1
+ import { A as OutExtensionFactory, B as CopyOptionsFn, C as RolldownChunk, D as ChunkAddonFunction, E as ChunkAddon, F as RolldownContext, I as TsdownHooks, L as DebugOptions, M as PackageJsonWithPath, N as PackageType, O as ChunkAddonObject, P as BuildContext, R as CopyEntry, S as ExportsOptions, T as AttwOptions, _ as Workspace, a as NoExternalFn, b as Logger, c as ResolvedConfig, d as TsdownInputOption, f as UnusedOptions, g as WithEnabled, h as UserConfigFn, i as InlineConfig, j as OutExtensionObject, k as OutExtensionContext, l as Sourcemap, m as UserConfigExport, n as DtsOptions, o as NormalizedFormat, p as UserConfig, r as Format, s as PublintOptions, t as CIOption, u as TreeshakingOptions, v as ReportOptions, w as TsdownBundle, x as globalLogger, z as CopyOptions } from "./index-BuAkqPeD.mjs";
2
2
  import { defineConfig } from "./config.mjs";
3
3
  import * as Rolldown from "rolldown";
4
4
 
@@ -7,16 +7,5 @@ import * as Rolldown from "rolldown";
7
7
  * Build with tsdown.
8
8
  */
9
9
  declare function build(userOptions?: InlineConfig): Promise<TsdownBundle[]>;
10
- /**
11
- * Build a single configuration, without watch and shortcuts features.
12
- *
13
- * Internal API, not for public use
14
- *
15
- * @private
16
- * @param config Resolved options
17
- */
18
- declare function buildSingle(config: ResolvedConfig, configFiles: string[], isDualFormat: boolean, clean: () => Promise<void>, restart: () => void, done: (bundle: TsdownBundle) => Promise<void>): Promise<TsdownBundle>;
19
- /** @internal */
20
- declare const shimFile: string;
21
10
  //#endregion
22
- export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DebugOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, Rolldown, RolldownChunk, RolldownContext, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildSingle, defineConfig, globalLogger, shimFile };
11
+ export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DebugOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, Rolldown, RolldownChunk, RolldownContext, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, defineConfig, globalLogger };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as defineConfig } from "./config-DLSWqKoz.mjs";
2
- import { i as shimFile, n as build, r as buildSingle, t as Rolldown } from "./src-aipTTo-5.mjs";
3
- import { o as globalLogger } from "./package-CpLZpKe2.mjs";
2
+ import { i as shimFile, n as build, r as buildSingle, t as Rolldown } from "./src-D06o_Qq1.mjs";
3
+ import { o as globalLogger } from "./package-deaowsxO.mjs";
4
4
 
5
5
  export { Rolldown, build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -164,7 +164,7 @@ function hue2rgb(p, q, t) {
164
164
 
165
165
  //#endregion
166
166
  //#region package.json
167
- var version = "0.18.2";
167
+ var version = "0.18.3";
168
168
 
169
169
  //#endregion
170
170
  export { getNameLabel as a, importWithError as c, pkgExists as d, promiseWithResolvers as f, toArray as g, slash as h, generateColor as i, matchPattern as l, resolveRegex as m, LogLevels as n, globalLogger as o, resolveComma as p, createLogger as r, prettyFormat as s, version as t, noop as u };
@@ -1,4 +1,4 @@
1
- import { b as Logger, c as ResolvedConfig, w as TsdownBundle, y as ReportPlugin } from "./index-BJCpuL9t.mjs";
1
+ import { b as Logger, c as ResolvedConfig, w as TsdownBundle, y as ReportPlugin } from "./index-BuAkqPeD.mjs";
2
2
  import { Plugin } from "rolldown";
3
3
 
4
4
  //#region src/features/external.d.ts
package/dist/plugins.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as WatchPlugin, c as NodeProtocolPlugin, l as ExternalPlugin, o as ShebangPlugin, s as ReportPlugin } from "./src-aipTTo-5.mjs";
2
- import "./package-CpLZpKe2.mjs";
1
+ import { a as WatchPlugin, c as NodeProtocolPlugin, l as ExternalPlugin, o as ShebangPlugin, s as ReportPlugin } from "./src-D06o_Qq1.mjs";
2
+ import "./package-deaowsxO.mjs";
3
3
 
4
4
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, WatchPlugin };
package/dist/run.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { g as toArray, o as globalLogger, p as resolveComma, t as version } from "./package-CpLZpKe2.mjs";
2
+ import { g as toArray, o as globalLogger, p as resolveComma, t as version } from "./package-deaowsxO.mjs";
3
3
  import module from "node:module";
4
4
  import { dim } from "ansis";
5
5
  import { VERSION } from "rolldown";
@@ -29,7 +29,7 @@ cli.help().version(version);
29
29
  cli.command("[...files]", "Bundle files", {
30
30
  ignoreOptionDefaultValue: true,
31
31
  allowUnknownOptions: true
32
- }).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("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug", "Enable debug mode").option("--debug-logs [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("--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("-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) => {
32
+ }).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("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug", "Enable debug mode").option("--debug-logs [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("-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) => {
33
33
  globalLogger.level = flags.logLevel || (flags.silent ? "error" : "info");
34
34
  globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
35
35
  const { build: build$1 } = await import("./index.mjs");
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { a as getNameLabel, c as importWithError, d as pkgExists, f as promiseWithResolvers, g as toArray, h as slash, i as generateColor, l as matchPattern, m as resolveRegex, n as LogLevels, o as globalLogger, p as resolveComma, r as createLogger, s as prettyFormat, t as version, u as noop } from "./package-CpLZpKe2.mjs";
3
+ import { a as getNameLabel, c as importWithError, d as pkgExists, f as promiseWithResolvers, g as toArray, h as slash, i as generateColor, l as matchPattern, m as resolveRegex, n as LogLevels, o as globalLogger, p as resolveComma, r as createLogger, s as prettyFormat, t as version, u as noop } from "./package-deaowsxO.mjs";
4
4
  import { builtinModules, isBuiltin } from "node:module";
5
5
  import path, { dirname, extname, join, normalize, sep } from "node:path";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -13,6 +13,7 @@ import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:
13
13
  import process, { env } from "node:process";
14
14
  import { createConfigCoreLoader } from "unconfig-core";
15
15
  const picomatch = __cjs_require("picomatch");
16
+ import util, { formatWithOptions, parseEnv, promisify } from "node:util";
16
17
  import { createDefu } from "defu";
17
18
  import { glob, isDynamicPattern } from "tinyglobby";
18
19
  import { RE_CSS, RE_DTS, RE_JS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
@@ -24,7 +25,6 @@ const satisfies = __cjs_require("semver/functions/satisfies.js");
24
25
  import { Hookable } from "hookable";
25
26
  import { exec } from "tinyexec";
26
27
  const treeKill = __cjs_require("tree-kill");
27
- import util, { formatWithOptions, promisify } from "node:util";
28
28
  import { tmpdir } from "node:os";
29
29
  import { importGlobPlugin } from "rolldown/experimental";
30
30
  import { Buffer } from "node:buffer";
@@ -520,7 +520,7 @@ function normalizeFormat(format) {
520
520
  //#region src/config/options.ts
521
521
  const debugLog = createDebug("tsdown:config:options");
522
522
  async function resolveUserConfig(userConfig, inlineConfig) {
523
- let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = "ci-only", customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch: watch$1 = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env: env$1 = {}, copy: copy$1, publicDir, hash = true, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$10 = false, write = true } = userConfig;
523
+ let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = "ci-only", customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch: watch$1 = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env: env$1 = {}, envFile, envPrefix = "TSDOWN_", copy: copy$1, publicDir, hash = true, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$10 = false, write = true } = userConfig;
524
524
  const pkg = await readPackageJson(cwd);
525
525
  if (workspace) name ||= pkg?.name;
526
526
  const color = generateColor(name);
@@ -557,6 +557,22 @@ async function resolveUserConfig(userConfig, inlineConfig) {
557
557
  }
558
558
  if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
559
559
  else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
560
+ envPrefix = toArray(envPrefix);
561
+ if (envPrefix.includes("")) logger.warn("`envPrefix` includes an empty string; filtering is disabled. All environment variables from the env file and process.env will be injected into the build. Ensure this is intended to avoid accidental leakage of sensitive information.");
562
+ const envFromProcess = filterEnv(process.env, envPrefix);
563
+ if (envFile) {
564
+ const resolvedPath = path.resolve(cwd, envFile);
565
+ logger.info(nameLabel, `env file: ${color(resolvedPath)}`);
566
+ env$1 = {
567
+ ...filterEnv(parseEnv(await readFile(resolvedPath, "utf8")), envPrefix),
568
+ ...envFromProcess,
569
+ ...env$1
570
+ };
571
+ } else env$1 = {
572
+ ...envFromProcess,
573
+ ...env$1
574
+ };
575
+ debugLog(`Environment variables: %O`, env$1);
560
576
  if (fromVite) {
561
577
  const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd, inlineConfig.configLoader);
562
578
  if (viteUserConfig) {
@@ -638,6 +654,12 @@ async function resolveUserConfig(userConfig, inlineConfig) {
638
654
  };
639
655
  });
640
656
  }
657
+ /** filter env variables by prefixes */
658
+ function filterEnv(envDict, envPrefixes) {
659
+ const env$1 = {};
660
+ for (const [key, value] of Object.entries(envDict)) if (envPrefixes.some((prefix) => key.startsWith(prefix)) && value !== void 0) env$1[key] = value;
661
+ return env$1;
662
+ }
641
663
  const defu = createDefu((obj, key, value) => {
642
664
  if (Array.isArray(obj[key]) && Array.isArray(value)) {
643
665
  obj[key] = value;
@@ -847,6 +869,20 @@ function executeOnSuccess(config) {
847
869
  //#region src/features/pkg/attw.ts
848
870
  const debug$4 = createDebug("tsdown:attw");
849
871
  const label$1 = dim`[attw]`;
872
+ const problemFlags = {
873
+ NoResolution: "no-resolution",
874
+ UntypedResolution: "untyped-resolution",
875
+ FalseCJS: "false-cjs",
876
+ FalseESM: "false-esm",
877
+ CJSResolvesToESM: "cjs-resolves-to-esm",
878
+ FallbackCondition: "fallback-condition",
879
+ CJSOnlyExportsDefault: "cjs-only-exports-default",
880
+ NamedExports: "named-exports",
881
+ FalseExportDefault: "false-export-default",
882
+ MissingExportEquals: "missing-export-equals",
883
+ UnexpectedModuleSyntax: "unexpected-module-syntax",
884
+ InternalResolutionError: "internal-resolution-error"
885
+ };
850
886
  /**
851
887
  * ATTW profiles.
852
888
  * Defines the resolution modes to ignore for each profile.
@@ -864,7 +900,9 @@ async function attw(options) {
864
900
  options.logger.warn("attw is enabled but package.json is not found");
865
901
  return;
866
902
  }
867
- const { profile = "strict", level = "warn", ...attwOptions } = options.attw;
903
+ const { profile = "strict", level = "warn", ignoreRules = [], ...attwOptions } = options.attw;
904
+ const invalidRules = ignoreRules.filter((rule) => !Object.values(problemFlags).includes(rule));
905
+ if (invalidRules.length) options.logger.warn(`attw config option 'ignoreRules' contains invalid value '${invalidRules.join(", ")}'.`);
868
906
  const t = performance.now();
869
907
  debug$4("Running attw check");
870
908
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
@@ -891,6 +929,7 @@ async function attw(options) {
891
929
  let errorMessage;
892
930
  if (checkResult.types) {
893
931
  const problems = checkResult.problems.filter((problem) => {
932
+ if (ignoreRules.includes(problemFlags[problem.kind])) return false;
894
933
  if ("resolutionKind" in problem) return !profiles[profile]?.includes(problem.resolutionKind);
895
934
  return true;
896
935
  });
@@ -1585,7 +1624,7 @@ async function build$1(userOptions = {}) {
1585
1624
  *
1586
1625
  * Internal API, not for public use
1587
1626
  *
1588
- * @private
1627
+ * @internal
1589
1628
  * @param config Resolved options
1590
1629
  */
1591
1630
  async function buildSingle(config, configFiles, isDualFormat, clean, restart, done) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsdown",
3
3
  "type": "module",
4
- "version": "0.18.2",
4
+ "version": "0.18.3",
5
5
  "description": "The Elegant Bundler for Libraries",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -84,26 +84,26 @@
84
84
  "import-without-cache": "^0.2.5",
85
85
  "obug": "^2.1.1",
86
86
  "picomatch": "^4.0.3",
87
- "rolldown": "1.0.0-beta.55",
88
- "rolldown-plugin-dts": "^0.19.1",
87
+ "rolldown": "1.0.0-beta.57",
88
+ "rolldown-plugin-dts": "^0.20.0",
89
89
  "semver": "^7.7.3",
90
90
  "tinyexec": "^1.0.2",
91
91
  "tinyglobby": "^0.2.15",
92
92
  "tree-kill": "^1.2.2",
93
93
  "unconfig-core": "^7.4.2",
94
- "unrun": "^0.2.20"
94
+ "unrun": "^0.2.21"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@arethetypeswrong/core": "^0.18.2",
98
- "@sxzz/eslint-config": "^7.4.3",
98
+ "@sxzz/eslint-config": "^7.4.4",
99
99
  "@sxzz/prettier-config": "^2.2.6",
100
100
  "@sxzz/test-utils": "^0.5.15",
101
101
  "@types/node": "^25.0.3",
102
102
  "@types/picomatch": "^4.0.2",
103
103
  "@types/semver": "^7.7.1",
104
- "@typescript/native-preview": "7.0.0-dev.20251221.1",
104
+ "@typescript/native-preview": "7.0.0-dev.20251223.1",
105
105
  "@unocss/eslint-plugin": "^66.5.10",
106
- "@vitejs/devtools": "^0.0.0-alpha.20",
106
+ "@vitejs/devtools": "^0.0.0-alpha.22",
107
107
  "@vitest/coverage-v8": "4.0.16",
108
108
  "@vitest/ui": "^4.0.16",
109
109
  "@vueuse/core": "^14.1.0",
@@ -116,12 +116,13 @@
116
116
  "pkg-types": "^2.3.0",
117
117
  "prettier": "^3.7.4",
118
118
  "publint": "^0.3.16",
119
+ "rolldown-plugin-dts-snapshot": "^0.3.0",
119
120
  "rolldown-plugin-require-cjs": "^0.3.3",
120
121
  "typescript": "~5.9.3",
121
122
  "unocss": "^66.5.10",
122
- "unplugin-lightningcss": "^0.4.3",
123
+ "unplugin-lightningcss": "^0.4.4",
123
124
  "unplugin-unused": "^0.5.6",
124
- "vite": "^8.0.0-beta.2",
125
+ "vite": "^8.0.0-beta.4",
125
126
  "vitest": "^4.0.16"
126
127
  },
127
128
  "prettier": "@sxzz/prettier-config",