tsdown 0.18.1 → 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 { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./index-CxBVIi0h.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
 
@@ -1,9 +1,8 @@
1
1
  import "ansis";
2
- import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, TreeshakingOptions } from "rolldown";
2
+ import { BuildOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, TreeshakingOptions } from "rolldown";
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
@@ -170,13 +495,13 @@ interface ExportsOptions {
170
495
  */
171
496
  all?: boolean;
172
497
  /**
173
- * Define filenames or RegExp patterns to exclude files from exports.
498
+ * Define globs or RegExp patterns to exclude files from exports.
174
499
  * This is useful for excluding files that should not be part of the package exports,
175
500
  * such as bin files or internal utilities.
176
501
  *
177
502
  * @example
178
503
  * ```js
179
- * exclude: ['foo.ts', /\.spec\.ts$/, /internal/]
504
+ * exclude: ['**\/*.test.ts', '**\/*.spec.ts', /internal/]
180
505
  * ```
181
506
  */
182
507
  exclude?: (RegExp | string)[];
@@ -228,6 +553,24 @@ declare function ReportPlugin(userOptions: ReportOptions, logger: Logger, cwd: s
228
553
  type Sourcemap = boolean | "inline" | "hidden";
229
554
  type Format = ModuleFormat;
230
555
  type NormalizedFormat = InternalModuleFormat;
556
+ /**
557
+ * Extended input option that supports glob negation patterns.
558
+ *
559
+ * When using object form, values can be:
560
+ * - A single glob pattern string
561
+ * - An array of glob patterns, including negation patterns (prefixed with `!`)
562
+ *
563
+ * @example
564
+ * ```ts
565
+ * entry: {
566
+ * // Single pattern
567
+ * "utils/*": "./src/utils/*.ts",
568
+ * // Array with negation pattern to exclude files
569
+ * "hooks/*": ["./src/hooks/*.ts", "!./src/hooks/index.ts"],
570
+ * }
571
+ * ```
572
+ */
573
+ type TsdownInputOption = string | string[] | Record<string, string | string[]>;
231
574
  interface Workspace {
232
575
  /**
233
576
  * Workspace directories. Glob patterns are supported.
@@ -257,8 +600,16 @@ type WithEnabled<T> = boolean | undefined | CIOption | (T & {
257
600
  interface UserConfig {
258
601
  /**
259
602
  * Defaults to `'src/index.ts'` if it exists.
603
+ *
604
+ * Supports glob patterns with negation to exclude files:
605
+ * @example
606
+ * ```ts
607
+ * entry: {
608
+ * "hooks/*": ["./src/hooks/*.ts", "!./src/hooks/index.ts"],
609
+ * }
610
+ * ```
260
611
  */
261
- entry?: InputOption;
612
+ entry?: TsdownInputOption;
262
613
  external?: ExternalOption;
263
614
  noExternal?: Arrayable<string | RegExp> | NoExternalFn;
264
615
  /**
@@ -317,7 +668,7 @@ interface UserConfig {
317
668
  */
318
669
  target?: string | string[] | false;
319
670
  /**
320
- * Compile-time env variables.
671
+ * Compile-time env variables, which can be accessed via `import.meta.env` or `process.env`.
321
672
  * @example
322
673
  * ```json
323
674
  * {
@@ -327,6 +678,17 @@ interface UserConfig {
327
678
  * ```
328
679
  */
329
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[];
330
692
  define?: Record<string, string>;
331
693
  /** @default false */
332
694
  shims?: boolean;
@@ -602,7 +964,9 @@ type UserConfigFn = (inlineConfig: InlineConfig, context: {
602
964
  ci: boolean;
603
965
  }) => Awaitable<Arrayable<UserConfig>>;
604
966
  type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
605
- 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">, {
968
+ /** Resolved entry map (after glob expansion) */
969
+ entry: Record<string, string>;
606
970
  nameLabel: string | undefined;
607
971
  format: NormalizedFormat;
608
972
  target?: string[];
@@ -623,4 +987,4 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
623
987
  unused: false | UnusedOptions;
624
988
  }>;
625
989
  //#endregion
626
- export { OutExtensionObject as A, TsdownBundle as C, ChunkAddonObject as D, ChunkAddonFunction as E, TsdownHooks as F, DebugOptions as I, CopyEntry as L, PackageType as M, BuildContext as N, OutExtensionContext as O, RolldownContext as P, CopyOptions as R, RolldownChunk as S, ChunkAddon as T, ReportOptions as _, NoExternalFn as a, globalLogger as b, ResolvedConfig as c, UnusedOptions as d, UserConfig as f, Workspace as g, WithEnabled as h, InlineConfig as i, PackageJsonWithPath as j, OutExtensionFactory as k, Sourcemap as l, UserConfigFn as m, DtsOptions as n, NormalizedFormat as o, UserConfigExport as p, Format as r, PublintOptions as s, CIOption as t, TreeshakingOptions as u, ReportPlugin as v, AttwOptions as w, ExportsOptions as x, Logger as y, CopyOptionsFn as z };
990
+ export { OutExtensionFactory as A, CopyOptionsFn as B, RolldownChunk as C, ChunkAddonFunction as D, ChunkAddon as E, RolldownContext as F, TsdownHooks as I, DebugOptions as L, PackageJsonWithPath as M, PackageType as N, ChunkAddonObject as O, BuildContext as P, CopyEntry as R, ExportsOptions as S, AttwOptions as T, Workspace as _, NoExternalFn as a, Logger as b, ResolvedConfig as c, TsdownInputOption as d, UnusedOptions as f, WithEnabled as g, UserConfigFn as h, InlineConfig as i, OutExtensionObject as j, OutExtensionContext as k, Sourcemap as l, UserConfigExport as m, DtsOptions as n, NormalizedFormat as o, UserConfig as p, Format as r, PublintOptions as s, CIOption as t, TreeshakingOptions as u, ReportOptions as v, TsdownBundle as w, globalLogger as x, ReportPlugin as y, CopyOptions as z };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as OutExtensionObject, C as TsdownBundle, D as ChunkAddonObject, E as ChunkAddonFunction, F as TsdownHooks, I as DebugOptions, L as CopyEntry, M as PackageType, N as BuildContext, O as OutExtensionContext, P as RolldownContext, R as CopyOptions, S as RolldownChunk, T as ChunkAddon, _ as ReportOptions, a as NoExternalFn, b as globalLogger, c as ResolvedConfig, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as PackageJsonWithPath, k as OutExtensionFactory, l as Sourcemap, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as PublintOptions, t as CIOption, u as TreeshakingOptions, w as AttwOptions, x as ExportsOptions, y as Logger, z as CopyOptionsFn } from "./index-CxBVIi0h.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, 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-Bln7Ytss.mjs";
3
- import { o as globalLogger } from "./package-Db0DU5Ct.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 };
@@ -1,5 +1,8 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+ const __cjs_require = __cjs_createRequire(import.meta.url);
1
3
  import { bgRed, bgYellow, blue, green, rgb, yellow } from "ansis";
2
4
  import process from "node:process";
5
+ const picomatch = __cjs_require("picomatch");
3
6
 
4
7
  //#region src/utils/general.ts
5
8
  function toArray(val, defaultValue) {
@@ -26,7 +29,7 @@ function matchPattern(id, patterns) {
26
29
  pattern.lastIndex = 0;
27
30
  return pattern.test(id);
28
31
  }
29
- return id === pattern;
32
+ return id === pattern || picomatch(pattern)(id);
30
33
  });
31
34
  }
32
35
  function pkgExists(moduleName) {
@@ -161,7 +164,7 @@ function hue2rgb(p, q, t) {
161
164
 
162
165
  //#endregion
163
166
  //#region package.json
164
- var version = "0.18.1";
167
+ var version = "0.18.3";
165
168
 
166
169
  //#endregion
167
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 { C as TsdownBundle, c as ResolvedConfig, v as ReportPlugin, y as Logger } from "./index-CxBVIi0h.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-Bln7Ytss.mjs";
2
- import "./package-Db0DU5Ct.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-Db0DU5Ct.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-Db0DU5Ct.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";
@@ -12,19 +12,19 @@ import { createDebug } from "obug";
12
12
  import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
13
13
  import process, { env } from "node:process";
14
14
  import { createConfigCoreLoader } from "unconfig-core";
15
+ const picomatch = __cjs_require("picomatch");
16
+ import util, { formatWithOptions, parseEnv, promisify } from "node:util";
15
17
  import { createDefu } from "defu";
16
18
  import { glob, isDynamicPattern } from "tinyglobby";
17
- const picomatch = __cjs_require("picomatch");
18
19
  import { RE_CSS, RE_DTS, RE_JS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
19
20
  const minVersion = __cjs_require("semver/ranges/min-version.js");
20
21
  import { up } from "empathic/find";
21
22
  import { up as up$1 } from "empathic/package";
22
23
  const coerce = __cjs_require("semver/functions/coerce.js");
23
24
  const satisfies = __cjs_require("semver/functions/satisfies.js");
24
- import { createHooks } from "hookable";
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";
@@ -201,7 +201,7 @@ async function nativeImport(id) {
201
201
  const importAttributes = Object.create(null);
202
202
  if (isSupported) {
203
203
  importAttributes.cache = "no";
204
- init();
204
+ init({ skipNodeModules: true });
205
205
  } else if (!isBun) url.searchParams.set("no-cache", crypto.randomUUID());
206
206
  const mod = await import(url.href, { with: importAttributes }).catch((error) => {
207
207
  if (error?.message?.includes?.("Cannot find module")) throw new Error(`Failed to load the config file. Try setting the --config-loader CLI flag to \`unrun\`.\n\n${error.message}`, { cause: error });
@@ -227,7 +227,8 @@ async function cleanOutDir(configs) {
227
227
  const files = await glob(config.clean, {
228
228
  cwd: config.cwd,
229
229
  absolute: true,
230
- onlyFiles: false
230
+ onlyFiles: false,
231
+ dot: true
231
232
  });
232
233
  const normalizedOutDir = config.outDir.replace(RE_LAST_SLASH, "");
233
234
  for (const file of files) if (file.replace(RE_LAST_SLASH, "") !== normalizedOutDir) removes.add(file);
@@ -271,9 +272,16 @@ async function resolveEntry(logger, entry, cwd, color, nameLabel) {
271
272
  async function toObjectEntry(entry, cwd) {
272
273
  if (typeof entry === "string") entry = [entry];
273
274
  if (!Array.isArray(entry)) return Object.fromEntries((await Promise.all(Object.entries(entry).map(async ([key, value]) => {
274
- if (!key.includes("*")) return [[key, value]];
275
- const valueGlob = picomatch.scan(value);
276
- return (await glob(value, {
275
+ if (!key.includes("*")) {
276
+ if (Array.isArray(value)) throw new TypeError(`Object entry "${key}" cannot have an array value when the key is not a glob pattern.`);
277
+ return [[key, value]];
278
+ }
279
+ const patterns = toArray(value);
280
+ const positivePatterns = patterns.filter((p) => !p.startsWith("!"));
281
+ if (positivePatterns.length === 0) throw new TypeError(`Object entry "${key}" has no positive pattern. At least one positive pattern is required.`);
282
+ if (positivePatterns.length > 1) throw new TypeError(`Object entry "${key}" has multiple positive patterns: ${positivePatterns.join(", ")}. Only one positive pattern is allowed. Use negation patterns (prefixed with "!") to exclude files.`);
283
+ const valueGlob = picomatch.scan(positivePatterns[0]);
284
+ return (await glob(patterns, {
277
285
  cwd,
278
286
  expandDirectories: false
279
287
  })).map((file) => [slash(key.replaceAll("*", stripExtname(path.relative(valueGlob.base, file)))), path.resolve(cwd, file)]);
@@ -512,7 +520,7 @@ function normalizeFormat(format) {
512
520
  //#region src/config/options.ts
513
521
  const debugLog = createDebug("tsdown:config:options");
514
522
  async function resolveUserConfig(userConfig, inlineConfig) {
515
- 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;
516
524
  const pkg = await readPackageJson(cwd);
517
525
  if (workspace) name ||= pkg?.name;
518
526
  const color = generateColor(name);
@@ -530,7 +538,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
530
538
  nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
531
539
  outDir = path.resolve(cwd, outDir);
532
540
  clean = resolveClean(clean, outDir, cwd);
533
- entry = await resolveEntry(logger, entry, cwd, color, nameLabel);
541
+ const resolvedEntry = await resolveEntry(logger, entry, cwd, color, nameLabel);
534
542
  if (dts == null) dts = !!(pkg?.types || pkg?.typings || hasExportsTypes(pkg));
535
543
  target = resolveTarget(logger, target, color, pkg, nameLabel);
536
544
  tsconfig = await resolveTsconfig(logger, tsconfig, cwd, color, nameLabel);
@@ -549,6 +557,22 @@ async function resolveUserConfig(userConfig, inlineConfig) {
549
557
  }
550
558
  if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
551
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);
552
576
  if (fromVite) {
553
577
  const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd, inlineConfig.configLoader);
554
578
  if (viteUserConfig) {
@@ -586,7 +610,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
586
610
  cwd,
587
611
  debug: debug$10,
588
612
  dts,
589
- entry,
613
+ entry: resolvedEntry,
590
614
  env: env$1,
591
615
  exports,
592
616
  external,
@@ -630,6 +654,12 @@ async function resolveUserConfig(userConfig, inlineConfig) {
630
654
  };
631
655
  });
632
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
+ }
633
663
  const defu = createDefu((obj, key, value) => {
634
664
  if (Array.isArray(obj[key]) && Array.isArray(value)) {
635
665
  obj[key] = value;
@@ -805,8 +835,8 @@ function renameTarget(target, rename, src) {
805
835
 
806
836
  //#endregion
807
837
  //#region src/features/hooks.ts
808
- async function createHooks$1(options) {
809
- const hooks = createHooks();
838
+ async function createHooks(options) {
839
+ const hooks = new Hookable();
810
840
  if (typeof options.hooks === "object") hooks.addHooks(options.hooks);
811
841
  else if (typeof options.hooks === "function") await options.hooks(hooks);
812
842
  return {
@@ -839,6 +869,20 @@ function executeOnSuccess(config) {
839
869
  //#region src/features/pkg/attw.ts
840
870
  const debug$4 = createDebug("tsdown:attw");
841
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
+ };
842
886
  /**
843
887
  * ATTW profiles.
844
888
  * Defines the resolution modes to ignore for each profile.
@@ -856,7 +900,9 @@ async function attw(options) {
856
900
  options.logger.warn("attw is enabled but package.json is not found");
857
901
  return;
858
902
  }
859
- 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(", ")}'.`);
860
906
  const t = performance.now();
861
907
  debug$4("Running attw check");
862
908
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
@@ -883,10 +929,11 @@ async function attw(options) {
883
929
  let errorMessage;
884
930
  if (checkResult.types) {
885
931
  const problems = checkResult.problems.filter((problem) => {
932
+ if (ignoreRules.includes(problemFlags[problem.kind])) return false;
886
933
  if ("resolutionKind" in problem) return !profiles[profile]?.includes(problem.resolutionKind);
887
934
  return true;
888
935
  });
889
- if (problems.length) errorMessage = `problems found:\n${problems.map(formatProblem).join("\n")}`;
936
+ if (problems.length) errorMessage = `problems found:\n${problems.map((problem) => formatProblem(checkResult.packageName, problem)).join("\n")}`;
890
937
  } else errorMessage = `Package has no types`;
891
938
  if (errorMessage) options.logger[level](options.nameLabel, label$1, errorMessage);
892
939
  else options.logger.success(options.nameLabel, label$1, "No problems found", dim`(${Math.round(performance.now() - t)}ms)`);
@@ -894,9 +941,9 @@ async function attw(options) {
894
941
  /**
895
942
  * Format an ATTW problem for display
896
943
  */
897
- function formatProblem(problem) {
944
+ function formatProblem(packageName, problem) {
898
945
  const resolutionKind = "resolutionKind" in problem ? ` (${problem.resolutionKind})` : "";
899
- const entrypoint = "entrypoint" in problem ? ` at ${problem.entrypoint}` : "";
946
+ const entrypoint = "entrypoint" in problem ? ` at ${slash(path.join(packageName, problem.entrypoint))}` : "";
900
947
  switch (problem.kind) {
901
948
  case "NoResolution": return ` ❌ No resolution${resolutionKind}${entrypoint}`;
902
949
  case "UntypedResolution": return ` ⚠️ Untyped resolution${resolutionKind}${entrypoint}`;
@@ -1051,10 +1098,9 @@ Imported by ${underline(importer)}`);
1051
1098
  if (noExternal?.(id, importer)) return "no-external";
1052
1099
  if (skipNodeModulesBundle) {
1053
1100
  const resolved = await context.resolve(id, importer, extraOptions);
1054
- if (!resolved) return false;
1055
- return resolved.external || RE_NODE_MODULES.test(resolved.id);
1101
+ if (resolved && (resolved.external || RE_NODE_MODULES.test(resolved.id))) return true;
1056
1102
  }
1057
- if (deps) return deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
1103
+ if (deps && deps.some((dep) => id === dep || id.startsWith(`${dep}/`))) return true;
1058
1104
  return false;
1059
1105
  }
1060
1106
  }
@@ -1578,12 +1624,12 @@ async function build$1(userOptions = {}) {
1578
1624
  *
1579
1625
  * Internal API, not for public use
1580
1626
  *
1581
- * @private
1627
+ * @internal
1582
1628
  * @param config Resolved options
1583
1629
  */
1584
1630
  async function buildSingle(config, configFiles, isDualFormat, clean, restart, done) {
1585
1631
  const { format, dts, watch: watch$1, logger, outDir } = config;
1586
- const { hooks, context } = await createHooks$1(config);
1632
+ const { hooks, context } = await createHooks(config);
1587
1633
  warnLegacyCJS(config);
1588
1634
  const startTime = performance.now();
1589
1635
  await hooks.callHook("build:prepare", context);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsdown",
3
3
  "type": "module",
4
- "version": "0.18.1",
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",
@@ -80,30 +80,30 @@
80
80
  "cac": "^6.7.14",
81
81
  "defu": "^6.1.4",
82
82
  "empathic": "^2.0.0",
83
- "hookable": "^5.5.3",
84
- "import-without-cache": "^0.2.4",
83
+ "hookable": "^6.0.1",
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.20251217.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",