tsdown 0.21.0 → 0.21.1

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/client.d.ts CHANGED
@@ -56,3 +56,8 @@ interface ImportGlobFunction {
56
56
  interface ImportMeta {
57
57
  glob: ImportGlobFunction
58
58
  }
59
+
60
+ declare module '*?inline' {
61
+ const src: string
62
+ export default src
63
+ }
@@ -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 { l as slash, n as importWithError, o as promiseWithResolvers, t as debounce, u as toArray } from "./general-CRszZCrY.mjs";
4
- 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, u as cleanChunks } from "./options-DpJJmGDp.mjs";
5
- import { a as getShimsInject, c as fsRemove, o as fsCopy, r as DepPlugin, u as lowestCommonAncestor } from "./format-CM79ZE77.mjs";
3
+ import { a as pkgExists, l as slash, n as importWithError, o as promiseWithResolvers, t as debounce, u as toArray } from "./general-CRszZCrY.mjs";
4
+ 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, u as cleanChunks } from "./options-CQzuh3xe.mjs";
5
+ import { a as lowestCommonAncestor, r as fsRemove, t as fsCopy } from "./fs-Dd6Htx2P.mjs";
6
6
  import { a as globalLogger, t as LogLevels } from "./logger-BU0v7CAk.mjs";
7
- import { t as CssPlugin } from "./plugin-BQv869Ce.mjs";
8
- import { t as version } from "./package-BzvC5Wbf.mjs";
9
- import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, t as WatchPlugin } from "./watch-BAbxxJcJ.mjs";
7
+ import { a as getShimsInject, r as DepPlugin } from "./format-CEIo9KZy.mjs";
8
+ import { t as version } from "./package-9LGtt4SC.mjs";
9
+ import { a as ReportPlugin, i as ShebangPlugin, n as endsWithConfig, o as NodeProtocolPlugin, r as addOutDirToChunks, t as WatchPlugin } from "./watch-yZCV-ZeB.mjs";
10
10
  import { mkdtemp, readFile, writeFile } from "node:fs/promises";
11
11
  import path from "node:path";
12
12
  import process from "node:process";
@@ -373,7 +373,7 @@ async function bundleDone(bundleByPkg, bundle) {
373
373
  async function packTarball(packageJsonPath) {
374
374
  const pkgDir = path.dirname(packageJsonPath);
375
375
  const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
376
- const [{ detect }, { pack }] = await Promise.all([import("./detect-DK-FDZQ9.mjs"), import("./index-node-Djp92Gzb.mjs")]);
376
+ const [{ detect }, { pack }] = await Promise.all([import("./detect-J1_Vd1yf.mjs"), import("./index-node-Bpsmc0eX.mjs")]);
377
377
  try {
378
378
  const detected = await detect({ cwd: pkgDir });
379
379
  if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
@@ -498,14 +498,11 @@ async function resolveInputOptions(config, format, configFiles, bundle, cjsDts,
498
498
  ...unused
499
499
  }));
500
500
  }
501
- let cssPlugin;
502
- try {
503
- const { CssPlugin: AdvancedCssPlugin } = await import("@tsdown/css");
504
- cssPlugin = AdvancedCssPlugin(config, { logger });
505
- } catch {
506
- cssPlugin = CssPlugin(config);
507
- }
508
- plugins.push(cssPlugin, ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
501
+ if (pkgExists("@tsdown/css")) {
502
+ const { CssPlugin } = await import("@tsdown/css");
503
+ plugins.push(CssPlugin(config, { logger }));
504
+ } else plugins.push(CssGuardPlugin());
505
+ plugins.push(ShebangPlugin(logger, cwd, nameLabel, isDualFormat));
509
506
  if (globImport) plugins.push(importGlobPlugin({ root: cwd }));
510
507
  }
511
508
  if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(config, cjsDts, isDualFormat));
@@ -600,6 +597,18 @@ function handlePluginInspect(plugins) {
600
597
  else return `"rolldown plugin: ${plugins.name}"`;
601
598
  };
602
599
  }
600
+ function CssGuardPlugin() {
601
+ return {
602
+ name: "tsdown:css-guard",
603
+ transform: {
604
+ order: "post",
605
+ filter: { id: /\.(?:css|less|sass|scss|styl|stylus)$/ },
606
+ handler(_code, id) {
607
+ throw new Error(`CSS file "${id}" was encountered but \`@tsdown/css\` is not installed. Please install it: \`npm install @tsdown/css\``);
608
+ }
609
+ }
610
+ };
611
+ }
603
612
  //#endregion
604
613
  //#region src/features/shortcuts.ts
605
614
  function shortcuts(restart) {
@@ -0,0 +1,2 @@
1
+ import { t as build } from "./build-BG-XbM6V.mjs";
2
+ export { build };
@@ -1,4 +1,4 @@
1
- import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-DS6cAXR1.mjs";
1
+ import { d as UserConfig, f as UserConfigExport, i as InlineConfig, o as ResolvedConfig, p as UserConfigFn } from "./types-CuHu3Iaq.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-DS6cAXR1.mjs";
2
- import { n as mergeConfig, t as defineConfig } from "./config-BJBl3n_a.mjs";
1
+ import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./types-CuHu3Iaq.mjs";
2
+ import { n as mergeConfig, t as defineConfig } from "./config-B9iARaO_.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-DpJJmGDp.mjs";
1
+ import { t as mergeConfig } from "./options-CQzuh3xe.mjs";
2
2
  //#region src/config.ts
3
3
  function defineConfig(options) {
4
4
  return options;
@@ -1,54 +1,11 @@
1
1
  import { c as resolveRegex, l as slash, r as matchPattern, u as toArray } from "./general-CRszZCrY.mjs";
2
2
  import { isBuiltin } from "node:module";
3
- import { access, cp, readFile, rm, stat } from "node:fs/promises";
3
+ import { readFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { blue, underline, yellow } from "ansis";
6
6
  import { createDebug } from "obug";
7
7
  import { RE_DTS, RE_NODE_MODULES } from "rolldown-plugin-dts/filename";
8
8
  import { and, id, importerId, include } from "rolldown/filter";
9
- //#region src/utils/fs.ts
10
- function fsExists(path) {
11
- return access(path).then(() => true, () => false);
12
- }
13
- function fsStat(path) {
14
- return stat(path).catch(() => null);
15
- }
16
- function fsRemove(path) {
17
- return rm(path, {
18
- force: true,
19
- recursive: true
20
- }).catch(() => {});
21
- }
22
- function fsCopy(from, to) {
23
- return cp(from, to, {
24
- recursive: true,
25
- force: true
26
- });
27
- }
28
- function lowestCommonAncestor(...filepaths) {
29
- if (filepaths.length === 0) return "";
30
- if (filepaths.length === 1) return path.dirname(filepaths[0]);
31
- filepaths = filepaths.map(path.normalize);
32
- const [first, ...rest] = filepaths;
33
- let ancestor = first.split(path.sep);
34
- for (const filepath of rest) {
35
- const directories = filepath.split(path.sep, ancestor.length);
36
- let index = 0;
37
- for (const directory of directories) if (directory === ancestor[index]) index += 1;
38
- else {
39
- ancestor = ancestor.slice(0, index);
40
- break;
41
- }
42
- ancestor = ancestor.slice(0, index);
43
- }
44
- return ancestor.length <= 1 && ancestor[0] === "" ? path.sep + ancestor[0] : ancestor.join(path.sep);
45
- }
46
- function stripExtname(filePath) {
47
- const ext = path.extname(filePath);
48
- if (!ext.length) return filePath;
49
- return filePath.slice(0, -ext.length);
50
- }
51
- //#endregion
52
9
  //#region src/features/shims.ts
53
10
  const shimFile = path.resolve(import.meta.dirname, "..", "esm-shims.js");
54
11
  function getShimsInject(format, platform) {
@@ -204,4 +161,4 @@ function detectIndentation(jsonText) {
204
161
  return 2;
205
162
  }
206
163
  //#endregion
207
- export { getShimsInject as a, fsRemove as c, stripExtname as d, resolveDepsConfig as i, fsStat as l, formatBytes as n, fsCopy as o, DepPlugin as r, fsExists as s, detectIndentation as t, lowestCommonAncestor as u };
164
+ export { getShimsInject as a, resolveDepsConfig as i, formatBytes as n, DepPlugin as r, detectIndentation as t };
@@ -0,0 +1,46 @@
1
+ import { access, cp, rm, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ //#region src/utils/fs.ts
4
+ function fsExists(path) {
5
+ return access(path).then(() => true, () => false);
6
+ }
7
+ function fsStat(path) {
8
+ return stat(path).catch(() => null);
9
+ }
10
+ function fsRemove(path) {
11
+ return rm(path, {
12
+ force: true,
13
+ recursive: true
14
+ }).catch(() => {});
15
+ }
16
+ function fsCopy(from, to) {
17
+ return cp(from, to, {
18
+ recursive: true,
19
+ force: true
20
+ });
21
+ }
22
+ function lowestCommonAncestor(...filepaths) {
23
+ if (filepaths.length === 0) return "";
24
+ if (filepaths.length === 1) return path.dirname(filepaths[0]);
25
+ filepaths = filepaths.map(path.normalize);
26
+ const [first, ...rest] = filepaths;
27
+ let ancestor = first.split(path.sep);
28
+ for (const filepath of rest) {
29
+ const directories = filepath.split(path.sep, ancestor.length);
30
+ let index = 0;
31
+ for (const directory of directories) if (directory === ancestor[index]) index += 1;
32
+ else {
33
+ ancestor = ancestor.slice(0, index);
34
+ break;
35
+ }
36
+ ancestor = ancestor.slice(0, index);
37
+ }
38
+ return ancestor.length <= 1 && ancestor[0] === "" ? path.sep + ancestor[0] : ancestor.join(path.sep);
39
+ }
40
+ function stripExtname(filePath) {
41
+ const ext = path.extname(filePath);
42
+ if (!ext.length) return filePath;
43
+ return filePath.slice(0, -ext.length);
44
+ }
45
+ //#endregion
46
+ export { lowestCommonAncestor as a, fsStat as i, fsExists as n, stripExtname as o, fsRemove as r, fsCopy as t };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { A as RolldownContext, B as globalLogger, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject, G as LightningCSSOptions, H as TsdownBundle, I as DepsConfig, L as NoExternalFn, M as ExeOptions, N as SeaConfig, O as PackageType, P as DevtoolsOptions, Q as StylusPreprocessorOptions, R as ResolvedDepsConfig, S as ChunkAddonFunction, T as OutExtensionFactory, U as CssOptions, V as RolldownChunk, W as LessPreprocessorOptions, X as ResolvedCssOptions, Y as PreprocessorOptions, Z as SassPreprocessorOptions, a as NormalizedFormat, b as AttwOptions, c as TreeshakingOptions, d as UserConfig, f as UserConfigExport, g as ReportOptions, h as Workspace, i as InlineConfig, it as Arrayable, j as TsdownHooks, k as BuildContext, l as TsdownInputOption, m as WithEnabled, n as DtsOptions, nt as CopyOptions, o as ResolvedConfig, p as UserConfigFn, r as Format, rt as CopyOptionsFn, s as Sourcemap, t as CIOption, tt as CopyEntry, u as UnusedOptions, v as PublintOptions, w as OutExtensionContext, x as ChunkAddon, y as ExportsOptions, z as Logger } from "./types-DS6cAXR1.mjs";
2
- import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-BJBl3n_a.mjs";
1
+ import { i as Arrayable, n as Logger, r as globalLogger } from "./logger-BUKd5OJy.mjs";
2
+ import { A as RolldownContext, B as TsdownBundle, C as ChunkAddonObject, D as PackageJsonWithPath, E as OutExtensionObject, H as CopyOptions, I as DepsConfig, 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-CuHu3Iaq.mjs";
3
+ import { n as mergeConfig, r as resolveUserConfig, t as defineConfig } from "./config-B9iARaO_.mjs";
3
4
  import * as Rolldown from "rolldown";
4
5
 
5
6
  //#region src/build.d.ts
@@ -18,4 +19,4 @@ declare function buildWithConfigs(configs: ResolvedConfig[], configFiles: string
18
19
  //#region src/features/debug.d.ts
19
20
  declare function enableDebug(debug?: boolean | Arrayable<string>): void;
20
21
  //#endregion
21
- export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, CssOptions, DepsConfig, DevtoolsOptions, DtsOptions, ExeOptions, ExportsOptions, Format, InlineConfig, LessPreprocessorOptions, LightningCSSOptions, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PreprocessorOptions, PublintOptions, ReportOptions, ResolvedConfig, ResolvedCssOptions, ResolvedDepsConfig, Rolldown, RolldownChunk, RolldownContext, SassPreprocessorOptions, SeaConfig, Sourcemap, StylusPreprocessorOptions, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
22
+ export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DepsConfig, DevtoolsOptions, DtsOptions, ExeOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageJsonWithPath, PackageType, PublintOptions, ReportOptions, ResolvedConfig, ResolvedDepsConfig, Rolldown, RolldownChunk, RolldownContext, SeaConfig, Sourcemap, TreeshakingOptions, TsdownBundle, TsdownHooks, TsdownInputOption, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { r as resolveUserConfig, t as mergeConfig } from "./options-DpJJmGDp.mjs";
1
+ import { r as resolveUserConfig, t as mergeConfig } from "./options-CQzuh3xe.mjs";
2
2
  import { a as globalLogger } from "./logger-BU0v7CAk.mjs";
3
3
  import { defineConfig } from "./config.mjs";
4
- import { n as buildWithConfigs, t as build } from "./build-TmLngPCw.mjs";
5
- import { t as enableDebug } from "./debug-tOJ_PtrM.mjs";
4
+ import { n as buildWithConfigs, t as build } from "./build-BG-XbM6V.mjs";
5
+ import { t as enableDebug } from "./debug-C4FmgzkJ.mjs";
6
6
  import * as Rolldown from "rolldown";
7
7
  export { Rolldown, build, buildWithConfigs, defineConfig, enableDebug, globalLogger, mergeConfig, resolveUserConfig };
@@ -0,0 +1,12 @@
1
+ import { n as Logger, o as MarkPartial, s as Overwrite } from "./logger-BUKd5OJy.mjs";
2
+
3
+ //#region src/utils/fs.d.ts
4
+ declare function fsExists(path: string): Promise<boolean>;
5
+ declare function fsRemove(path: string): Promise<void>;
6
+ //#endregion
7
+ //#region src/utils/general.d.ts
8
+ declare function toArray<T>(val: T | T[] | null | undefined, defaultValue?: T): T[];
9
+ declare function resolveComma<T extends string>(arr: T[]): T[];
10
+ declare function importWithError<T>(moduleName: string, resolvePaths?: string[]): Promise<T>;
11
+ //#endregion
12
+ export { type Logger, type MarkPartial, type Overwrite, fsExists, fsRemove, importWithError, resolveComma, toArray };
@@ -0,0 +1,3 @@
1
+ import { n as importWithError, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
2
+ import { n as fsExists, r as fsRemove } from "./fs-Dd6Htx2P.mjs";
3
+ export { fsExists, fsRemove, importWithError, resolveComma, toArray };
@@ -0,0 +1,30 @@
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 };
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
3
  import { a as pkgExists, c as resolveRegex, l as slash, n as importWithError, r as matchPattern, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
4
- import { c as fsRemove, d as stripExtname, i as resolveDepsConfig, l as fsStat, n as formatBytes, s as fsExists, t as detectIndentation, u as lowestCommonAncestor } from "./format-CM79ZE77.mjs";
4
+ import { a as lowestCommonAncestor, i as fsStat, n as fsExists, o as stripExtname, r as fsRemove } from "./fs-Dd6Htx2P.mjs";
5
5
  import { a as globalLogger, i as getNameLabel, n as createLogger, r as generateColor } from "./logger-BU0v7CAk.mjs";
6
- import { n as resolveCssOptions } from "./css-CzF_A79W.mjs";
6
+ import { i as resolveDepsConfig, n as formatBytes, t as detectIndentation } from "./format-CEIo9KZy.mjs";
7
7
  import { mkdtemp, readFile, writeFile } from "node:fs/promises";
8
8
  import path from "node:path";
9
9
  import process, { env } from "node:process";
@@ -342,8 +342,8 @@ function exportMeta(exports, all, packageJson) {
342
342
  if (all) exports["./*"] = "./*";
343
343
  else if (packageJson) exports["./package.json"] = "./package.json";
344
344
  }
345
- function exportCss(exports, chunks, { splitting }, pkgRoot) {
346
- if (splitting) return;
345
+ function exportCss(exports, chunks, css, pkgRoot) {
346
+ if (css?.splitting) return;
347
347
  for (const chunksByFormat of Object.values(chunks)) for (const chunk of chunksByFormat) if (chunk.type === "asset" && RE_CSS.test(chunk.fileName)) {
348
348
  const filename = slash(chunk.fileName);
349
349
  exports[`./${filename}`] = join(pkgRoot, chunk.outDir, filename);
@@ -601,7 +601,7 @@ const parseEnv = process.getBuiltinModule("node:util").parseEnv;
601
601
  * @private
602
602
  */
603
603
  async function resolveUserConfig(userConfig, inlineConfig) {
604
- let { entry, format, plugins = [], clean = true, logLevel = "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, css, fixedExtension = platform === "node", devtools = false, write = true, exe = false } = userConfig;
604
+ let { entry, format, plugins = [], clean = true, logLevel = "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, publint = false, attw = false, fromVite, alias, tsconfig, report = true, target, env = {}, envFile, envPrefix = "TSDOWN_", copy, publicDir, hash = true, cwd = process.cwd(), name, workspace, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, css, injectStyle, fixedExtension = platform === "node", devtools = false, write = true, exe = false } = userConfig;
605
605
  const pkg = await readPackageJson(cwd);
606
606
  if (workspace) name ||= pkg?.name;
607
607
  const color = generateColor(name);
@@ -639,6 +639,13 @@ async function resolveUserConfig(userConfig, inlineConfig) {
639
639
  if (publint) logger.warn(nameLabel, "publint is enabled but package.json is not found");
640
640
  if (attw) logger.warn(nameLabel, "attw is enabled but package.json is not found");
641
641
  }
642
+ if (injectStyle != null) if (css?.inject == null) {
643
+ logger.warn(`${blue`injectStyle`} is deprecated. Use ${blue`css.inject`} instead.`);
644
+ css = {
645
+ ...css,
646
+ inject: injectStyle
647
+ };
648
+ } else throw new TypeError("`injectStyle` is deprecated. Cannot be used with `css.inject`");
642
649
  if (publicDir) if (copy) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
643
650
  else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
644
651
  envPrefix = toArray(envPrefix);
@@ -688,7 +695,7 @@ async function resolveUserConfig(userConfig, inlineConfig) {
688
695
  cjsDefault,
689
696
  clean,
690
697
  copy: publicDir || copy,
691
- css: resolveCssOptions(css, target),
698
+ css,
692
699
  cwd,
693
700
  deps: depsConfig,
694
701
  devtools,
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.21.0";
2
+ var version = "0.21.1";
3
3
  //#endregion
4
4
  export { version as t };
@@ -1,4 +1,5 @@
1
- import { F as DepPlugin, H as TsdownBundle, _ as ReportPlugin, z as Logger } from "./types-DS6cAXR1.mjs";
1
+ import { n as Logger } from "./logger-BUKd5OJy.mjs";
2
+ import { B as TsdownBundle, F as DepPlugin, _ as ReportPlugin } from "./types-CuHu3Iaq.mjs";
2
3
  import { Plugin } from "rolldown";
3
4
 
4
5
  //#region src/features/node-protocol.d.ts
package/dist/plugins.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { r as DepPlugin } from "./format-CM79ZE77.mjs";
2
- import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-BAbxxJcJ.mjs";
1
+ import { r as DepPlugin } from "./format-CEIo9KZy.mjs";
2
+ import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, t as WatchPlugin } from "./watch-yZCV-ZeB.mjs";
3
3
  export { DepPlugin, 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-BU0v7CAk.mjs";
5
- import { t as version } from "./package-BzvC5Wbf.mjs";
6
- import { t as enableDebug } from "./debug-tOJ_PtrM.mjs";
5
+ import { t as version } from "./package-9LGtt4SC.mjs";
6
+ import { t as enableDebug } from "./debug-C4FmgzkJ.mjs";
7
7
  import module from "node:module";
8
8
  import process from "node:process";
9
9
  import { dim, 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("--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(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
23
- const { build } = await import("./build-gOkJM1H9.mjs");
23
+ const { build } = await import("./build-DHPfiKA-.mjs");
24
24
  if (input.length > 0) flags.entry = input;
25
25
  await build(flags);
26
26
  });
@@ -1,6 +1,8 @@
1
+ import { a as Awaitable, i as Arrayable, n as Logger, o as MarkPartial, s as Overwrite, t as LogLevel } from "./logger-BUKd5OJy.mjs";
1
2
  import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, TreeshakingOptions } from "rolldown";
2
3
  import { Hookable } from "hookable";
3
4
  import { Buffer } from "node:buffer";
5
+ import * as _tsdown_css0 from "@tsdown/css";
4
6
  import { Options as DtsOptions } from "rolldown-plugin-dts";
5
7
  import { StartOptions } from "@vitejs/devtools/cli-commands";
6
8
  import { ExeExtensionOptions } from "@tsdown/exe";
@@ -8,12 +10,6 @@ import { CheckPackageOptions } from "@arethetypeswrong/core";
8
10
  import { Options } from "publint";
9
11
  import { Options as UnusedOptions } from "unplugin-unused";
10
12
 
11
- //#region src/utils/types.d.ts
12
- type Overwrite<T, U> = Omit<T, keyof U> & U;
13
- type Awaitable<T> = T | Promise<T>;
14
- type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
15
- type Arrayable<T> = T | T[];
16
- //#endregion
17
13
  //#region src/features/copy.d.ts
18
14
  interface CopyEntry {
19
15
  /**
@@ -44,128 +40,6 @@ interface CopyEntry {
44
40
  type CopyOptions = Arrayable<string | CopyEntry>;
45
41
  type CopyOptionsFn = (options: ResolvedConfig) => Awaitable<CopyOptions>;
46
42
  //#endregion
47
- //#region src/features/css/index.d.ts
48
- interface CssOptions {
49
- /**
50
- * Enable/disable CSS code splitting.
51
- * When set to `false`, all CSS in the entire project will be extracted into a single CSS file.
52
- * When set to `true`, CSS imported in async JS chunks will be preserved as chunks.
53
- * @default false
54
- */
55
- splitting?: boolean;
56
- /**
57
- * Specify the name of the CSS file.
58
- * @default 'style.css'
59
- */
60
- fileName?: string;
61
- /**
62
- * Set the target environment for CSS syntax lowering.
63
- * Accepts esbuild-style target strings (e.g., `'chrome99'`, `'safari16.2'`).
64
- * Defaults to the top-level `target` option.
65
- *
66
- * Requires `@tsdown/css` to be installed.
67
- *
68
- * @see https://vite.dev/config/build-options#build-csstarget
69
- */
70
- target?: string | string[] | false;
71
- /**
72
- * Options for CSS preprocessors (Sass/Less/Stylus).
73
- *
74
- * In addition to options specific to each processor, `additionalData` option
75
- * can be used to inject extra code for each style content.
76
- *
77
- * Requires `@tsdown/css` to be installed.
78
- */
79
- preprocessorOptions?: PreprocessorOptions;
80
- /**
81
- * Enable/disable CSS minification.
82
- *
83
- * Requires `@tsdown/css` to be installed.
84
- *
85
- * @default false
86
- */
87
- minify?: boolean;
88
- /**
89
- * Lightning CSS options for CSS syntax lowering and transformations.
90
- *
91
- * Requires `@tsdown/css` to be installed.
92
- */
93
- lightningcss?: LightningCSSOptions;
94
- /**
95
- * PostCSS configuration.
96
- *
97
- * - `string`: Path to the directory to search for PostCSS config files.
98
- * - `object`: Inline PostCSS options with optional `plugins` array.
99
- * - Omitted: Auto-detect PostCSS config from the project root.
100
- *
101
- * Only used when `transformer` is `'postcss'`.
102
- * Requires `postcss` and `@tsdown/css` to be installed.
103
- *
104
- * @see https://github.com/postcss/postcss
105
- */
106
- postcss?: PostCSSOptions;
107
- /**
108
- * CSS transformer to use. Controls how CSS is processed:
109
- *
110
- * - `'lightningcss'` (default): `@import` handled by Lightning CSS
111
- * `bundleAsync()`, PostCSS is **not** used at all.
112
- * - `'postcss'`: `@import` handled by `postcss-import`,
113
- * PostCSS plugins applied, Lightning CSS used only for final
114
- * targets/minify transform.
115
- *
116
- * Requires `@tsdown/css` to be installed.
117
- *
118
- * @default 'lightningcss'
119
- * @see https://vite.dev/config/shared-options#css-transformer
120
- */
121
- transformer?: "postcss" | "lightningcss";
122
- }
123
- type PostCSSOptions = string | (Record<string, any> & {
124
- plugins?: any[];
125
- });
126
- interface PreprocessorOptions {
127
- scss?: SassPreprocessorOptions;
128
- sass?: SassPreprocessorOptions;
129
- less?: LessPreprocessorOptions;
130
- styl?: StylusPreprocessorOptions;
131
- stylus?: StylusPreprocessorOptions;
132
- }
133
- type PreprocessorAdditionalDataResult = string | {
134
- content: string;
135
- map?: any;
136
- };
137
- type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
138
- interface SassPreprocessorOptions {
139
- additionalData?: PreprocessorAdditionalData;
140
- [key: string]: any;
141
- }
142
- interface LessPreprocessorOptions {
143
- additionalData?: PreprocessorAdditionalData;
144
- math?: any;
145
- paths?: string[];
146
- plugins?: any[];
147
- [key: string]: any;
148
- }
149
- interface StylusPreprocessorOptions {
150
- additionalData?: PreprocessorAdditionalData;
151
- define?: Record<string, any>;
152
- paths?: string[];
153
- [key: string]: any;
154
- }
155
- type LightningCSSOptions = Record<string, any>;
156
- interface ResolvedCssOptions {
157
- transformer: "postcss" | "lightningcss";
158
- splitting: boolean;
159
- fileName: string;
160
- minify: boolean;
161
- target?: string[];
162
- preprocessorOptions?: PreprocessorOptions;
163
- lightningcss?: LightningCSSOptions;
164
- postcss?: PostCSSOptions;
165
- }
166
- declare const defaultCssBundleName = "style.css";
167
- declare function resolveCssOptions(options?: CssOptions, topLevelTarget?: string[]): ResolvedCssOptions;
168
- //#endregion
169
43
  //#region src/utils/chunks.d.ts
170
44
  type RolldownChunk = (OutputChunk | OutputAsset) & {
171
45
  outDir: string;
@@ -177,27 +51,6 @@ interface TsdownBundle extends AsyncDisposable {
177
51
  inlinedDeps: Map<string, Set<string>>;
178
52
  }
179
53
  //#endregion
180
- //#region src/utils/logger.d.ts
181
- type LogType = "error" | "warn" | "info";
182
- type LogLevel = LogType | "silent";
183
- interface LoggerOptions {
184
- allowClearScreen?: boolean;
185
- customLogger?: Logger;
186
- console?: Console;
187
- failOnWarn?: boolean;
188
- }
189
- interface Logger {
190
- level: LogLevel;
191
- options?: LoggerOptions;
192
- info: (...args: any[]) => void;
193
- warn: (...args: any[]) => void;
194
- warnOnce: (...args: any[]) => void;
195
- error: (...args: any[]) => void;
196
- success: (...args: any[]) => void;
197
- clearScreen: (type: LogType) => void;
198
- }
199
- declare const globalLogger: Logger;
200
- //#endregion
201
54
  //#region src/features/deps.d.ts
202
55
  type NoExternalFn = (id: string, importer: string | undefined) => boolean | null | undefined | void;
203
56
  interface DepsConfig {
@@ -1201,8 +1054,13 @@ interface UserConfig {
1201
1054
  exports?: WithEnabled<ExportsOptions>;
1202
1055
  /**
1203
1056
  * **[experimental]** CSS options.
1057
+ * Requires `@tsdown/css` to be installed.
1058
+ */
1059
+ css?: _tsdown_css0.CssOptions;
1060
+ /**
1061
+ * @deprecated Use `css.inject` instead.
1204
1062
  */
1205
- css?: CssOptions;
1063
+ injectStyle?: boolean;
1206
1064
  /**
1207
1065
  * @deprecated Alias for `copy`, will be removed in the future.
1208
1066
  */
@@ -1254,7 +1112,7 @@ type UserConfigFn = (inlineConfig: InlineConfig, context: {
1254
1112
  ci: boolean;
1255
1113
  }) => Awaitable<Arrayable<UserConfig>>;
1256
1114
  type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
1257
- type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "removeNodeProtocol" | "external" | "noExternal" | "inlineOnly" | "skipNodeModulesBundle" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks">, {
1115
+ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "injectStyle" | "removeNodeProtocol" | "external" | "noExternal" | "inlineOnly" | "skipNodeModulesBundle" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
1258
1116
  /** Resolved entry map (after glob expansion) */entry: Record<string, string>; /** Original entry config before glob resolution (for watch mode re-globbing) */
1259
1117
  rawEntry?: TsdownInputOption;
1260
1118
  nameLabel: string | undefined;
@@ -1266,7 +1124,6 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
1266
1124
  logger: Logger;
1267
1125
  ignoreWatch: Array<string | RegExp>;
1268
1126
  deps: ResolvedDepsConfig;
1269
- css: ResolvedCssOptions;
1270
1127
  dts: false | DtsOptions;
1271
1128
  report: false | ReportOptions;
1272
1129
  tsconfig: false | string;
@@ -1278,4 +1135,4 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
1278
1135
  exe: false | ExeOptions;
1279
1136
  }>;
1280
1137
  //#endregion
1281
- export { defaultCssBundleName as $, RolldownContext as A, globalLogger as B, ChunkAddonObject as C, PackageJsonWithPath as D, OutExtensionObject as E, DepPlugin as F, LightningCSSOptions as G, TsdownBundle as H, DepsConfig as I, PreprocessorAdditionalDataResult as J, PostCSSOptions as K, NoExternalFn as L, ExeOptions as M, SeaConfig as N, PackageType as O, DevtoolsOptions as P, StylusPreprocessorOptions as Q, ResolvedDepsConfig as R, ChunkAddonFunction as S, OutExtensionFactory as T, CssOptions as U, RolldownChunk as V, LessPreprocessorOptions as W, ResolvedCssOptions as X, PreprocessorOptions as Y, SassPreprocessorOptions as Z, ReportPlugin as _, NormalizedFormat as a, AttwOptions as b, TreeshakingOptions as c, UserConfig as d, resolveCssOptions as et, UserConfigExport as f, ReportOptions as g, Workspace as h, InlineConfig as i, Arrayable as it, TsdownHooks as j, BuildContext as k, TsdownInputOption as l, WithEnabled as m, DtsOptions as n, CopyOptions as nt, ResolvedConfig as o, UserConfigFn as p, PreprocessorAdditionalData as q, Format as r, CopyOptionsFn as rt, Sourcemap as s, CIOption as t, CopyEntry as tt, UnusedOptions as u, PublintOptions as v, OutExtensionContext as w, ChunkAddon as x, ExportsOptions as y, Logger as z };
1138
+ export { RolldownContext as A, TsdownBundle as B, ChunkAddonObject as C, PackageJsonWithPath as D, OutExtensionObject as E, DepPlugin as F, CopyOptions as H, DepsConfig as I, NoExternalFn as L, ExeOptions as M, SeaConfig as N, PackageType as O, DevtoolsOptions as P, ResolvedDepsConfig as R, ChunkAddonFunction as S, OutExtensionFactory as T, CopyOptionsFn as U, CopyEntry as V, ReportPlugin as _, NormalizedFormat as a, AttwOptions as b, TreeshakingOptions as c, UserConfig as d, UserConfigExport as f, ReportOptions as g, Workspace as h, InlineConfig as i, TsdownHooks as j, BuildContext as k, TsdownInputOption as l, WithEnabled as m, DtsOptions as n, ResolvedConfig as o, UserConfigFn as p, Format as r, Sourcemap as s, CIOption as t, UnusedOptions as u, PublintOptions as v, OutExtensionContext as w, ChunkAddon as x, ExportsOptions as y, RolldownChunk as z };
@@ -1,6 +1,7 @@
1
1
  import { i as noop, s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
2
- import { n as formatBytes, s as fsExists } from "./format-CM79ZE77.mjs";
2
+ import { n as fsExists } from "./fs-Dd6Htx2P.mjs";
3
3
  import { o as prettyFormat } from "./logger-BU0v7CAk.mjs";
4
+ import { n as formatBytes } from "./format-CEIo9KZy.mjs";
4
5
  import { builtinModules } from "node:module";
5
6
  import { chmod } from "node:fs/promises";
6
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.0",
4
+ "version": "0.21.1",
5
5
  "description": "The Elegant Bundler for Libraries",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "exports": {
18
18
  ".": "./dist/index.mjs",
19
19
  "./config": "./dist/config.mjs",
20
- "./css": "./dist/css.mjs",
20
+ "./internal": "./dist/internal.mjs",
21
21
  "./plugins": "./dist/plugins.mjs",
22
22
  "./run": "./dist/run.mjs",
23
23
  "./package.json": "./package.json",
@@ -52,8 +52,8 @@
52
52
  "publint": "^0.3.0",
53
53
  "typescript": "^5.0.0",
54
54
  "unplugin-unused": "^0.5.0",
55
- "@tsdown/exe": "0.21.0",
56
- "@tsdown/css": "0.21.0"
55
+ "@tsdown/css": "0.21.1",
56
+ "@tsdown/exe": "0.21.1"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@arethetypeswrong/core": {
@@ -87,14 +87,14 @@
87
87
  "import-without-cache": "^0.2.5",
88
88
  "obug": "^2.1.1",
89
89
  "picomatch": "^4.0.3",
90
- "rolldown": "1.0.0-rc.7",
91
- "rolldown-plugin-dts": "^0.22.3",
90
+ "rolldown": "1.0.0-rc.8",
91
+ "rolldown-plugin-dts": "^0.22.4",
92
92
  "semver": "^7.7.4",
93
93
  "tinyexec": "^1.0.2",
94
94
  "tinyglobby": "^0.2.15",
95
95
  "tree-kill": "^1.2.2",
96
96
  "unconfig-core": "^7.5.0",
97
- "unrun": "^0.2.29"
97
+ "unrun": "^0.2.31"
98
98
  },
99
99
  "inlinedDependencies": {
100
100
  "package-manager-detector": "1.6.0",
@@ -108,18 +108,18 @@
108
108
  "@sxzz/eslint-config": "^7.8.3",
109
109
  "@sxzz/prettier-config": "^2.3.1",
110
110
  "@sxzz/test-utils": "^0.5.15",
111
- "@types/node": "^25.3.3",
111
+ "@types/node": "^25.3.5",
112
112
  "@types/picomatch": "^4.0.2",
113
113
  "@types/semver": "^7.7.1",
114
- "@typescript/native-preview": "7.0.0-dev.20260304.1",
115
- "@unocss/eslint-plugin": "^66.6.5",
116
- "@vitejs/devtools": "^0.0.0-alpha.32",
114
+ "@typescript/native-preview": "7.0.0-dev.20260308.1",
115
+ "@unocss/eslint-plugin": "^66.6.6",
116
+ "@vitejs/devtools": "^0.0.0-alpha.33",
117
117
  "@vitest/coverage-v8": "^4.0.18",
118
118
  "@vitest/ui": "^4.0.18",
119
119
  "@vueuse/core": "^14.2.1",
120
120
  "bumpp": "^10.4.1",
121
121
  "dedent": "^1.7.2",
122
- "eslint": "^10.0.2",
122
+ "eslint": "^10.0.3",
123
123
  "is-in-ci": "^2.0.0",
124
124
  "memfs": "^4.56.11",
125
125
  "package-manager-detector": "^1.6.0",
@@ -130,21 +130,25 @@
130
130
  "publint": "^0.3.18",
131
131
  "rolldown-plugin-dts-snapshot": "^0.4.0",
132
132
  "rolldown-plugin-require-cjs": "^0.3.3",
133
+ "sass": "^1.97.3",
133
134
  "typescript": "~5.9.3",
134
- "unocss": "^66.6.5",
135
+ "unocss": "^66.6.6",
135
136
  "unplugin-ast": "^0.16.0",
137
+ "unplugin-raw": "^0.6.4",
136
138
  "unplugin-unused": "^0.5.7",
137
- "vite": "^8.0.0-beta.15",
139
+ "unplugin-vue": "^7.1.1",
140
+ "vite": "^8.0.0-beta.18",
138
141
  "vitest": "^4.0.18",
139
- "@tsdown/css": "0.21.0",
140
- "@tsdown/exe": "0.21.0"
142
+ "vue": "^3.5.29",
143
+ "@tsdown/css": "0.21.1",
144
+ "@tsdown/exe": "0.21.1"
141
145
  },
142
146
  "prettier": "@sxzz/prettier-config",
143
147
  "scripts": {
144
148
  "lint": "eslint --cache --max-warnings 0 .",
145
149
  "lint:fix": "pnpm run lint --fix",
146
- "build": "unrun ./src/run.ts",
147
- "dev": "node ./src/run.ts",
150
+ "build": "node -C dev ./src/run.ts",
151
+ "dev": "pnpm run build",
148
152
  "test": "vitest",
149
153
  "typecheck": "tsgo --noEmit",
150
154
  "format": "prettier --cache --write .",
@@ -1,2 +0,0 @@
1
- import { t as build } from "./build-TmLngPCw.mjs";
2
- export { build };
@@ -1,21 +0,0 @@
1
- import { s as resolveComma, u as toArray } from "./general-CRszZCrY.mjs";
2
- //#region src/features/css/index.ts
3
- const defaultCssBundleName = "style.css";
4
- function resolveCssOptions(options = {}, topLevelTarget) {
5
- let cssTarget;
6
- if (options.target === false) cssTarget = void 0;
7
- else if (options.target == null) cssTarget = topLevelTarget;
8
- else cssTarget = resolveComma(toArray(options.target));
9
- return {
10
- transformer: options.transformer ?? "lightningcss",
11
- splitting: options.splitting ?? false,
12
- fileName: options.fileName ?? "style.css",
13
- minify: options.minify ?? false,
14
- target: cssTarget,
15
- preprocessorOptions: options.preprocessorOptions,
16
- lightningcss: options.lightningcss,
17
- postcss: options.postcss
18
- };
19
- }
20
- //#endregion
21
- export { resolveCssOptions as n, defaultCssBundleName as t };
package/dist/css.d.mts DELETED
@@ -1,29 +0,0 @@
1
- import { $ as defaultCssBundleName, G as LightningCSSOptions, J as PreprocessorAdditionalDataResult, K as PostCSSOptions, Q as StylusPreprocessorOptions, U as CssOptions, W as LessPreprocessorOptions, X as ResolvedCssOptions, Y as PreprocessorOptions, Z as SassPreprocessorOptions, et as resolveCssOptions, q as PreprocessorAdditionalData, s as Sourcemap } from "./types-DS6cAXR1.mjs";
2
- import { OutputAsset, OutputChunk, Plugin } from "rolldown";
3
-
4
- //#region src/features/css/plugin.d.ts
5
- declare const RE_CSS: RegExp;
6
- //#endregion
7
- //#region src/features/css/post.d.ts
8
- type CssStyles = Map<string, string>;
9
- declare function createCssPostHooks(config: {
10
- css: {
11
- splitting: boolean;
12
- fileName: string;
13
- };
14
- }, styles: CssStyles): Pick<Required<Plugin>, "renderChunk" | "generateBundle">;
15
- //#endregion
16
- //#region src/features/css/pure-chunk.d.ts
17
- /**
18
- * Detect and remove "pure CSS chunks" — JS chunks that exist only because
19
- * they imported CSS files. These chunks have no JS exports and all their
20
- * modules are CSS. Following Vite's implementation.
21
- */
22
- declare function removePureCssChunks(bundle: Record<string, OutputChunk | OutputAsset>, styles: CssStyles): void;
23
- /**
24
- * Create a replacer function that replaces import statements for pure CSS
25
- * chunks with block comments of the same length, preserving source map offsets.
26
- */
27
- declare function getEmptyChunkReplacer(pureCssChunkNames: string[]): (code: string) => string;
28
- //#endregion
29
- export { type CssOptions, type CssStyles, type LessPreprocessorOptions, type LightningCSSOptions, type PostCSSOptions, type PreprocessorAdditionalData, type PreprocessorAdditionalDataResult, type PreprocessorOptions, RE_CSS, type ResolvedCssOptions, type SassPreprocessorOptions, type Sourcemap, type StylusPreprocessorOptions, createCssPostHooks, defaultCssBundleName, getEmptyChunkReplacer, removePureCssChunks, resolveCssOptions };
package/dist/css.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { n as resolveCssOptions, t as defaultCssBundleName } from "./css-CzF_A79W.mjs";
2
- import { a as removePureCssChunks, i as getEmptyChunkReplacer, n as RE_CSS, r as createCssPostHooks } from "./plugin-BQv869Ce.mjs";
3
- export { RE_CSS, createCssPostHooks, defaultCssBundleName, getEmptyChunkReplacer, removePureCssChunks, resolveCssOptions };
@@ -1,119 +0,0 @@
1
- import { t as defaultCssBundleName } from "./css-CzF_A79W.mjs";
2
- import { readFile } from "node:fs/promises";
3
- import path from "node:path";
4
- //#region src/features/css/pure-chunk.ts
5
- /**
6
- * Detect and remove "pure CSS chunks" — JS chunks that exist only because
7
- * they imported CSS files. These chunks have no JS exports and all their
8
- * modules are CSS. Following Vite's implementation.
9
- */
10
- function removePureCssChunks(bundle, styles) {
11
- const pureCssChunkNames = [];
12
- for (const [fileName, chunk] of Object.entries(bundle)) {
13
- if (chunk.type !== "chunk") continue;
14
- if (chunk.exports.length > 0) continue;
15
- const moduleIds = Object.keys(chunk.modules);
16
- if (moduleIds.length === 0) continue;
17
- if (!moduleIds.every((id) => styles.has(id))) continue;
18
- pureCssChunkNames.push(fileName);
19
- }
20
- if (!pureCssChunkNames.length) return;
21
- const replaceEmptyChunk = getEmptyChunkReplacer(pureCssChunkNames);
22
- for (const file of Object.keys(bundle)) {
23
- const chunk = bundle[file];
24
- if (chunk.type !== "chunk") continue;
25
- let chunkImportsPureCssChunk = false;
26
- chunk.imports = chunk.imports.filter((importFile) => {
27
- if (pureCssChunkNames.includes(importFile)) {
28
- chunkImportsPureCssChunk = true;
29
- return false;
30
- }
31
- return true;
32
- });
33
- if (chunkImportsPureCssChunk) chunk.code = replaceEmptyChunk(chunk.code);
34
- }
35
- for (const fileName of pureCssChunkNames) {
36
- delete bundle[fileName];
37
- delete bundle[`${fileName}.map`];
38
- }
39
- }
40
- /**
41
- * Create a replacer function that replaces import statements for pure CSS
42
- * chunks with block comments of the same length, preserving source map offsets.
43
- */
44
- function getEmptyChunkReplacer(pureCssChunkNames) {
45
- const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path.basename(file))).join("|");
46
- const emptyChunkRE = new RegExp(String.raw`\bimport\s*["'][^"']*(?:${emptyChunkFiles})["'];`, "g");
47
- return (code) => code.replace(emptyChunkRE, (m) => {
48
- return `/* empty css ${"".padEnd(m.length - 15)}*/`;
49
- });
50
- }
51
- function escapeRegex(str) {
52
- return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
53
- }
54
- //#endregion
55
- //#region src/features/css/post.ts
56
- function createCssPostHooks(config, styles) {
57
- const collectedCSS = [];
58
- return {
59
- renderChunk(_code, chunk) {
60
- let chunkCSS = "";
61
- for (const id of Object.keys(chunk.modules)) {
62
- const code = styles.get(id);
63
- if (code) chunkCSS += code;
64
- }
65
- if (!chunkCSS) return;
66
- if (chunkCSS.length > 0 && !chunkCSS.endsWith("\n")) chunkCSS += "\n";
67
- if (config.css.splitting) {
68
- const cssAssetFileName = chunk.fileName.replace(/\.(m?js|cjs)$/, ".css");
69
- this.emitFile({
70
- type: "asset",
71
- fileName: cssAssetFileName,
72
- source: chunkCSS
73
- });
74
- } else collectedCSS.push(chunkCSS);
75
- },
76
- generateBundle(_outputOptions, bundle) {
77
- if (!config.css.splitting && collectedCSS.length > 0) {
78
- const allCSS = collectedCSS.join("");
79
- if (allCSS) this.emitFile({
80
- type: "asset",
81
- fileName: config.css.fileName,
82
- source: allCSS,
83
- originalFileName: defaultCssBundleName
84
- });
85
- collectedCSS.length = 0;
86
- }
87
- removePureCssChunks(bundle, styles);
88
- }
89
- };
90
- }
91
- //#endregion
92
- //#region src/features/css/plugin.ts
93
- const RE_CSS = /\.css(?:$|\?)/;
94
- function CssPlugin(config) {
95
- const styles = /* @__PURE__ */ new Map();
96
- const postHooks = createCssPostHooks(config, styles);
97
- return {
98
- name: "tsdown:builtin-css",
99
- buildStart() {
100
- styles.clear();
101
- },
102
- load: {
103
- filter: { id: RE_CSS },
104
- async handler(id) {
105
- let code = await readFile(id, "utf8");
106
- if (code.length > 0 && !code.endsWith("\n")) code += "\n";
107
- styles.set(id, code);
108
- return {
109
- code: "",
110
- moduleSideEffects: "no-treeshake",
111
- moduleType: "js"
112
- };
113
- }
114
- },
115
- ...postHooks
116
- };
117
- }
118
- //#endregion
119
- export { removePureCssChunks as a, getEmptyChunkReplacer as i, RE_CSS as n, createCssPostHooks as r, CssPlugin as t };
File without changes