@powerlines/plugin-unbuild 0.5.308 → 0.5.309
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/build-BGmzCfG9.d.mts +8 -0
- package/dist/build-BGmzCfG9.d.mts.map +1 -0
- package/dist/build-CcJjLdFm.mjs +1 -0
- package/dist/build-D-HKMVs4.d.cts +8 -0
- package/dist/build-D-HKMVs4.d.cts.map +1 -0
- package/dist/build-MNonspIb.cjs +0 -0
- package/dist/helpers/index.cjs +4 -4
- package/dist/helpers/index.d.cts +1 -1
- package/dist/helpers/index.d.mts +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/resolve-options.cjs +4 -125
- package/dist/helpers/resolve-options.d.cts +2 -17
- package/dist/helpers/resolve-options.d.mts +2 -18
- package/dist/helpers/resolve-options.mjs +2 -122
- package/dist/index-BR1oNnaF.d.cts +1 -0
- package/dist/index-DEHBdV_z.d.mts +1 -0
- package/dist/index.cjs +6 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-CXxxQ0lD.d.cts +19 -0
- package/dist/plugin-CXxxQ0lD.d.cts.map +1 -0
- package/dist/plugin-Dt6qEKIr.d.mts +19 -0
- package/dist/plugin-Dt6qEKIr.d.mts.map +1 -0
- package/dist/plugin-jZ9N9Mz-.mjs +1 -0
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/resolve-options-COWDeANr.cjs +173 -0
- package/dist/resolve-options-CpHtoivj.mjs +123 -0
- package/dist/resolve-options-CpHtoivj.mjs.map +1 -0
- package/dist/resolve-options-DPRrB4Qj.d.cts +17 -0
- package/dist/resolve-options-DPRrB4Qj.d.cts.map +1 -0
- package/dist/resolve-options-DRA_XDDs.d.mts +17 -0
- package/dist/resolve-options-DRA_XDDs.d.mts.map +1 -0
- package/dist/types/build.cjs +1 -0
- package/dist/types/build.d.cts +2 -8
- package/dist/types/build.d.mts +2 -8
- package/dist/types/build.mjs +2 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.mts +3 -2
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +3 -20
- package/dist/types/plugin.d.mts +3 -21
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-BtDR9wb1.mjs +1 -0
- package/dist/types-o3zWarRp.cjs +0 -0
- package/package.json +4 -4
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/core/src/lib/utilities/source-file.cjs +0 -22
- package/dist/core/src/lib/utilities/source-file.mjs +0 -22
- package/dist/core/src/lib/utilities/source-file.mjs.map +0 -1
- package/dist/core/src/types/_internal.d.cts +0 -85
- package/dist/core/src/types/_internal.d.cts.map +0 -1
- package/dist/core/src/types/_internal.d.mts +0 -85
- package/dist/core/src/types/_internal.d.mts.map +0 -1
- package/dist/core/src/types/api.d.cts +0 -103
- package/dist/core/src/types/api.d.cts.map +0 -1
- package/dist/core/src/types/api.d.mts +0 -103
- package/dist/core/src/types/api.d.mts.map +0 -1
- package/dist/core/src/types/commands.d.cts +0 -9
- package/dist/core/src/types/commands.d.cts.map +0 -1
- package/dist/core/src/types/commands.d.mts +0 -10
- package/dist/core/src/types/commands.d.mts.map +0 -1
- package/dist/core/src/types/config.d.cts +0 -551
- package/dist/core/src/types/config.d.cts.map +0 -1
- package/dist/core/src/types/config.d.mts +0 -551
- package/dist/core/src/types/config.d.mts.map +0 -1
- package/dist/core/src/types/context.d.cts +0 -511
- package/dist/core/src/types/context.d.cts.map +0 -1
- package/dist/core/src/types/context.d.mts +0 -511
- package/dist/core/src/types/context.d.mts.map +0 -1
- package/dist/core/src/types/fs.d.cts +0 -487
- package/dist/core/src/types/fs.d.cts.map +0 -1
- package/dist/core/src/types/fs.d.mts +0 -487
- package/dist/core/src/types/fs.d.mts.map +0 -1
- package/dist/core/src/types/hooks.d.cts +0 -99
- package/dist/core/src/types/hooks.d.cts.map +0 -1
- package/dist/core/src/types/hooks.d.mts +0 -99
- package/dist/core/src/types/hooks.d.mts.map +0 -1
- package/dist/core/src/types/index.d.mts +0 -9
- package/dist/core/src/types/plugin.d.cts +0 -204
- package/dist/core/src/types/plugin.d.cts.map +0 -1
- package/dist/core/src/types/plugin.d.mts +0 -204
- package/dist/core/src/types/plugin.d.mts.map +0 -1
- package/dist/core/src/types/tsconfig.d.cts +0 -70
- package/dist/core/src/types/tsconfig.d.cts.map +0 -1
- package/dist/core/src/types/tsconfig.d.mts +0 -70
- package/dist/core/src/types/tsconfig.d.mts.map +0 -1
- package/dist/core/src/types/unplugin.d.cts +0 -24
- package/dist/core/src/types/unplugin.d.cts.map +0 -1
- package/dist/core/src/types/unplugin.d.mts +0 -25
- package/dist/core/src/types/unplugin.d.mts.map +0 -1
- package/dist/helpers/resolve-options.d.cts.map +0 -1
- package/dist/helpers/resolve-options.d.mts.map +0 -1
- package/dist/helpers/resolve-options.mjs.map +0 -1
- package/dist/plugin-rollup/src/helpers/resolve-options.cjs +0 -122
- package/dist/plugin-rollup/src/helpers/resolve-options.mjs +0 -116
- package/dist/plugin-rollup/src/helpers/resolve-options.mjs.map +0 -1
- package/dist/types/build.d.cts.map +0 -1
- package/dist/types/build.d.mts.map +0 -1
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts.map +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { CompilerOptions, TsConfigJson } from "@stryke/types/tsconfig";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
//#region ../core/src/types/tsconfig.d.ts
|
|
5
|
-
type ReflectionMode = "default" | "explicit" | "never";
|
|
6
|
-
type RawReflectionMode = ReflectionMode | "" | boolean | string | string[] | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Defines the level of reflection to be used during the transpilation process.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
12
|
-
* - `minimal` - Only the essential type information is captured.
|
|
13
|
-
* - `normal` - Additional type information is captured, including some contextual data.
|
|
14
|
-
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
15
|
-
*/
|
|
16
|
-
type ReflectionLevel = "minimal" | "normal" | "verbose";
|
|
17
|
-
interface DeepkitOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Either true to activate reflection for all files compiled using this tsconfig,
|
|
20
|
-
* or a list of globs/file paths relative to this tsconfig.json.
|
|
21
|
-
* Globs/file paths can be prefixed with a ! to exclude them.
|
|
22
|
-
*/
|
|
23
|
-
reflection?: RawReflectionMode;
|
|
24
|
-
/**
|
|
25
|
-
* Defines the level of reflection to be used during the transpilation process.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
29
|
-
* - `minimal` - Only the essential type information is captured.
|
|
30
|
-
* - `normal` - Additional type information is captured, including some contextual data.
|
|
31
|
-
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
32
|
-
*/
|
|
33
|
-
reflectionLevel?: ReflectionLevel;
|
|
34
|
-
}
|
|
35
|
-
type TSCompilerOptions = CompilerOptions & DeepkitOptions;
|
|
36
|
-
/**
|
|
37
|
-
* The TypeScript compiler configuration.
|
|
38
|
-
*
|
|
39
|
-
* @see https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
|
|
40
|
-
*/
|
|
41
|
-
interface TSConfig extends Omit<TsConfigJson, "reflection"> {
|
|
42
|
-
/**
|
|
43
|
-
* Either true to activate reflection for all files compiled using this tsconfig,
|
|
44
|
-
* or a list of globs/file paths relative to this tsconfig.json.
|
|
45
|
-
* Globs/file paths can be prefixed with a ! to exclude them.
|
|
46
|
-
*/
|
|
47
|
-
reflection?: RawReflectionMode;
|
|
48
|
-
/**
|
|
49
|
-
* Defines the level of reflection to be used during the transpilation process.
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* The level determines how much extra data is captured in the byte code for each type. This can be one of the following values:
|
|
53
|
-
* - `minimal` - Only the essential type information is captured.
|
|
54
|
-
* - `normal` - Additional type information is captured, including some contextual data.
|
|
55
|
-
* - `verbose` - All available type information is captured, including detailed contextual data.
|
|
56
|
-
*/
|
|
57
|
-
reflectionLevel?: ReflectionLevel;
|
|
58
|
-
/**
|
|
59
|
-
* Instructs the TypeScript compiler how to compile `.ts` files.
|
|
60
|
-
*/
|
|
61
|
-
compilerOptions?: TSCompilerOptions;
|
|
62
|
-
}
|
|
63
|
-
type ParsedTypeScriptConfig = ts.ParsedCommandLine & {
|
|
64
|
-
originalTsconfigJson: TsConfigJson;
|
|
65
|
-
tsconfigJson: TSConfig;
|
|
66
|
-
tsconfigFilePath: string;
|
|
67
|
-
};
|
|
68
|
-
//#endregion
|
|
69
|
-
export { DeepkitOptions, ParsedTypeScriptConfig, RawReflectionMode, ReflectionLevel, ReflectionMode, TSCompilerOptions, TSConfig };
|
|
70
|
-
//# sourceMappingURL=tsconfig.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.d.mts","names":[],"sources":["../../../../../core/src/types/tsconfig.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,cAAA;KACA,iBAAA,GACR;AAFJ;AACA;AAiBA;AAEA;AAoBA;AAOA;;;;AAsBoB,KAnDR,eAAA,GAmDQ,SAAA,GAAA,QAAA,GAAA,SAAA;AAtBc,UA3BjB,cAAA,CA2BiB;EAAI;AAyBtC;;;;EAEwB,UAAA,CAAA,EAhDT,iBAgDS;;;;;;;;;;oBArCJ;;KAGR,iBAAA,GAAoB,kBAAkB;;;;;;UAOjC,QAAA,SAAiB,KAAK;;;;;;eAMxB;;;;;;;;;;oBAWK;;;;oBAKA;;KAGR,sBAAA,GAAyB,EAAA,CAAG;wBAChB;gBACR"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PluginHook } from "./plugin.cjs";
|
|
2
|
-
import { Context } from "./context.cjs";
|
|
3
|
-
import { API } from "./api.cjs";
|
|
4
|
-
import { MaybePromise } from "@stryke/types/base";
|
|
5
|
-
import { HookFilter, UnpluginOptions } from "unplugin";
|
|
6
|
-
|
|
7
|
-
//#region ../core/src/types/unplugin.d.ts
|
|
8
|
-
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
9
|
-
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
10
|
-
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
11
|
-
interface UnpluginOptions$1<TContext extends Context = Context> extends UnpluginOptions {
|
|
12
|
-
/**
|
|
13
|
-
* An API object that can be used for inter-plugin communication.
|
|
14
|
-
*
|
|
15
|
-
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
16
|
-
*/
|
|
17
|
-
api: API<TContext["config"]>;
|
|
18
|
-
}
|
|
19
|
-
type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TContext>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] extends infer THandler | {
|
|
20
|
-
handler: infer THandler;
|
|
21
|
-
} ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] };
|
|
22
|
-
//#endregion
|
|
23
|
-
export { BuilderVariant, InferUnpluginOptions, UnpluginBuilderVariant };
|
|
24
|
-
//# sourceMappingURL=unplugin.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.cts","names":[],"sources":["../../../../../core/src/types/unplugin.ts"],"sourcesContent":[],"mappings":";;;;;;;KA6BY,sBAAA;AAuBA,KAAA,cAAA,GACR,sBAAA,GAAA,MAAsB,GAAA,QAAA,GAAA,SAAA;AAY6B,KAA3C,oBAA2C,CAAA,sBAAA,cAAA,CAAA,GACrD,aADqD,SAAA,MAAA,GAAA,SAAA,GAGjD,aAHiD,SAAA,QAAA,GAAA,UAAA,GAK/C,aAL+C,SAAA,SAAA,GAAA,QAAA,GAO7C,aAP6C;AACrD,UAQe,iBARf,CAAA,iBASiB,OATjB,GAS2B,OAT3B,CAAA,SAUQ,eAVR,CAAA;EAEI;;;;AAMN;EACmB,GAAA,EAOZ,GAPY,CAOR,QAPQ,CAAA,QAAA,CAAA,CAAA;;AAOR,KAGC,oBAHD,CAAA,iBAIQ,OAJR,GAIkB,OAJlB,EAAA,wBAKe,cALf,GAKgC,cALhC,EAAA,yBAMgB,oBANhB,CAMqC,eANrC,CAAA,GAOP,oBAPO,CAOc,eAPd,CAAA,CAAA,GAAA,WAAJ,MASU,QATV,CAUH,iBAVG,CAUa,QAVb,CAAA,CAAA,CAWH,gBAXG,CAAA,IAWkB,QAXlB,CAYH,iBAZG,CAYa,QAZb,CAAA,CAAA,CAaH,gBAbG,CAAA,CAae,IAbf,CAAA,SAAA,KAAA,SAAA,GAAA;EANG,OAAA,EAAA,KAAA,SAAA;AAAmB,CAAA,GAAA,QAAA,UAAA,CAAA,IAAA,EAAA,KAAA,iBAAA,EAAA,GAAA,IAAA,EAAA,KAAA,MAAA,EAAA,GAAA,KAAA,QAAA,IA4BrB,UA5BqB,CAAA,CAAA,IAAA,EA8BX,gBA9BW,GA8BQ,QA9BR,EAAA,GAAA,IAAA,EA+BR,KA/BQ,EAAA,GAgCd,YAhCc,CAgCD,OAhCC,CAAA,EAAA,MAiCb,UAjCa,CAAA,GAmCrB,QAnCqB,CAmCZ,iBAnCY,CAmCI,QAnCJ,CAAA,CAAA,CAmCe,gBAnCf,CAAA,CAmCiC,IAnCjC,CAAA,GAoCvB,QApCuB,CAoCd,iBApCc,CAoCE,QApCF,CAAA,CAAA,CAoCa,gBApCb,CAAA,CAoC+B,IApC/B,CAAA,EAS7B"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PluginHook } from "./plugin.mjs";
|
|
2
|
-
import { Context } from "./context.mjs";
|
|
3
|
-
import "./config.mjs";
|
|
4
|
-
import { API } from "./api.mjs";
|
|
5
|
-
import { MaybePromise } from "@stryke/types/base";
|
|
6
|
-
import { HookFilter, UnpluginOptions } from "unplugin";
|
|
7
|
-
|
|
8
|
-
//#region ../core/src/types/unplugin.d.ts
|
|
9
|
-
type UnpluginBuilderVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown" | "bun";
|
|
10
|
-
type BuilderVariant = UnpluginBuilderVariant | "tsup" | "tsdown" | "unbuild";
|
|
11
|
-
type InferUnpluginVariant<TBuildVariant extends BuilderVariant> = TBuildVariant extends "tsup" ? "esbuild" : TBuildVariant extends "tsdown" ? "rolldown" : TBuildVariant extends "unbuild" ? "rollup" : TBuildVariant;
|
|
12
|
-
interface UnpluginOptions$1<TContext extends Context = Context> extends UnpluginOptions {
|
|
13
|
-
/**
|
|
14
|
-
* An API object that can be used for inter-plugin communication.
|
|
15
|
-
*
|
|
16
|
-
* @see https://rollupjs.org/plugin-development/#direct-plugin-communication
|
|
17
|
-
*/
|
|
18
|
-
api: API<TContext["config"]>;
|
|
19
|
-
}
|
|
20
|
-
type InferUnpluginOptions<TContext extends Context = Context, TBuilderVariant extends BuilderVariant = BuilderVariant, TUnpluginVariant extends InferUnpluginVariant<TBuilderVariant> = InferUnpluginVariant<TBuilderVariant>> = { [TKey in keyof Required<UnpluginOptions$1<TContext>>[TUnpluginVariant]]?: Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] extends infer THandler | {
|
|
21
|
-
handler: infer THandler;
|
|
22
|
-
} ? THandler extends ((this: infer TOriginalContext, ...args: infer TArgs) => infer TReturn) ? PluginHook<(this: TOriginalContext & TContext, ...args: TArgs) => MaybePromise<TReturn>, keyof HookFilter> : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] : Required<UnpluginOptions$1<TContext>>[TUnpluginVariant][TKey] };
|
|
23
|
-
//#endregion
|
|
24
|
-
export { BuilderVariant, InferUnpluginOptions, InferUnpluginVariant, UnpluginBuilderVariant, UnpluginOptions$1 as UnpluginOptions };
|
|
25
|
-
//# sourceMappingURL=unplugin.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.mts","names":[],"sources":["../../../../../core/src/types/unplugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6BY,sBAAA;AAAA,KAuBA,cAAA,GACR,sBAxB8B,GAAA,MAAA,GAAA,QAAA,GAAA,SAAA;AAoCtB,KAAA,oBAAoB,CAAA,sBAAuB,cAAvB,CAAA,GAC9B,aAD8B,SAAA,MAAA,GAAA,SAAA,GAG1B,aAH0B,SAAA,QAAA,GAAA,UAAA,GAKxB,aALwB,SAAA,SAAA,GAAA,QAAA,GAOtB,aAPsB;AAAuB,UAStC,iBATsC,CAAA,iBAUpC,OAVoC,GAU1B,OAV0B,CAAA,SAW7C,eAX6C,CAAA;EACrD;;;;;EAQe,GAAA,EAQV,GARU,CAQN,QARM,CAAA,QAAe,CAAA,CAAA;;AACH,KAUjB,oBAViB,CAAA,iBAWV,OAXU,GAWA,OAXA,EAAA,wBAYH,cAZG,GAYc,cAZd,EAAA,yBAaF,oBAbE,CAamB,eAbnB,CAAA,GAczB,oBAdyB,CAcJ,eAdI,CAAA,CAAA,GAAA,WAOlB,MASM,QATN,CAUP,iBAVO,CAUS,QAVT,CAAA,CAAA,CAWP,gBAXO,CAAA,IAWc,QAXd,CAYP,iBAZO,CAYS,QAZT,CAAA,CAAA,CAaP,gBAbO,CAAA,CAaW,IAbX,CAAA,SAAA,KAAA,SAAA,GAAA;EAAJ,OAAA,EAAA,KAAA,SAAA;AANG,CAAA,GAAA,QAAA,UAAA,CAAA,IAAA,EAAA,KAAA,iBAAA,EAAA,GAAA,IAAA,EAAA,KAAA,MAAA,EAAA,GAAA,KAAA,QAAA,IA4BF,UA5BE,CAAA,CAAA,IAAA,EA8BQ,gBA9BR,GA8B2B,QA9B3B,EAAA,GAAA,IAAA,EA+BW,KA/BX,EAAA,GAgCK,YAhCL,CAgCkB,OAhClB,CAAA,EAAA,MAiCM,UAjCN,CAAA,GAmCF,QAnCE,CAmCO,iBAnCP,CAmCuB,QAnCvB,CAAA,CAAA,CAmCkC,gBAnClC,CAAA,CAmCoD,IAnCpD,CAAA,GAoCJ,QApCI,CAoCK,iBApCL,CAoCqB,QApCrB,CAAA,CAAA,CAoCgC,gBApChC,CAAA,CAoCkD,IApClD,CAAA,EAAmB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-options.d.cts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;AAvB9D;AAuBA;AA0HA;;;;iBAAgB,cAAA,UAAwB,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-options.d.mts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;;AAvB9D;AAuBA;AA0HA;;;iBAAgB,cAAA,UAAwB,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-options.mjs","names":["output: LoaderResult","extension","transformed: TransformResult | string","resolveRollupOptions"],"sources":["../../src/helpers/resolve-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport { Context } from \"@powerlines/core/types\";\nimport { UNSAFE_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { resolveOptions as resolveRollupOptions } from \"@powerlines/plugin-rollup/helpers/resolve-options\";\nimport type {\n UnbuildOptions as ExternalUnbuildOptions,\n Loader,\n LoaderResult\n} from \"@storm-software/unbuild/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport defu from \"defu\";\nimport { transform } from \"esbuild\";\nimport { TransformResult } from \"unplugin\";\nimport { UnbuildPluginResolvedConfig } from \"../types\";\n\nexport const DEFAULT_UNBUILD_CONFIG = {\n dts: true,\n clean: false,\n includeSrc: false,\n treeShaking: true,\n splitting: true,\n stub: false,\n watchOptions: {},\n outputPath: \"dist\",\n generatePackageJson: true,\n banner: \" \",\n rollup: {\n dts: {},\n emitCJS: true,\n replace: {},\n resolve: {},\n json: {},\n esbuild: { target: \"es2020\" },\n commonjs: {},\n alias: {}\n }\n} as Partial<ExternalUnbuildOptions>;\n\nexport const unbuildLoader = (context: UNSAFE_PluginContext): Loader => {\n return async (input, { options }) => {\n if (\n !/\\.(?:c|m)?[jt]sx?$/.test(input.path) ||\n /\\.d\\.[cm]?ts$/.test(input.path)\n ) {\n return;\n }\n\n const output: LoaderResult = [];\n\n let contents = await input.getContents();\n\n // declaration\n if (options.declaration && !input.srcPath?.match(/\\.d\\.[cm]?ts$/)) {\n const cm = input.srcPath?.match(/(?<=\\.)(?:c|m)(?=[jt]s$)/)?.[0] || \"\";\n const extension = `.d.${cm}ts`;\n output.push({\n contents,\n srcPath: input.srcPath,\n path: input.path,\n extension,\n declaration: true\n });\n }\n\n let transformed: TransformResult | string = contents;\n\n let result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"pre\"\n },\n transformed,\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"normal\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"post\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n // typescript => js\n if ([\".ts\", \".mts\", \".cts\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n ),\n loader: \"ts\"\n }).then(r => r.code);\n } else if ([\".tsx\", \".jsx\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n loader: input.extension === \".tsx\" ? \"tsx\" : \"jsx\",\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n )\n }).then(r => r.code);\n }\n\n // esm => cjs\n const isCjs = options.format === \"cjs\";\n if (isCjs) {\n contents = context.resolver\n .transform({\n source: contents,\n retainLines: false\n })\n .replace(/^exports.default = /gm, \"module.exports = \")\n .replace(/^var _default = exports.default = /gm, \"module.exports = \")\n .replace(\"module.exports = void 0;\", \"\");\n }\n\n let extension = isCjs ? \".js\" : \".mjs\"; // TODO: Default to .cjs in next major version\n if (options.ext) {\n extension = options.ext.startsWith(\".\") ? options.ext : `.${options.ext}`;\n }\n\n output.push({\n contents,\n path: input.path,\n extension\n });\n\n return output;\n };\n};\n\n/**\n * Extracts the unbuild configuration from the context.\n *\n * @param context - The build context.\n * @returns The resolved unbuild configuration.\n */\nexport function resolveOptions(context: Context): ExternalUnbuildOptions {\n return defu(\n {\n alias: context.alias\n },\n (context.config as UnbuildPluginResolvedConfig).unbuild\n ? (context.config as UnbuildPluginResolvedConfig).unbuild\n : {},\n {\n projectName: context.config.name,\n name: context.config.name,\n orgName: isObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization,\n sourceRoot: joinPaths(context.config.root, \"src\"),\n projectRoot: context.config.root,\n outputPath: context.config.output.buildPath || \"dist\",\n platform: context.config.platform,\n external: context.builtins.reduce((ret, id) => {\n if (!ret.includes(id)) {\n ret.push(id);\n }\n\n return ret;\n }, context.config.resolve.external ?? []),\n loaders: [unbuildLoader(context as UNSAFE_PluginContext)],\n jiti: {\n interopDefault: true,\n fsCache: joinPaths(context.envPaths.cache, \"jiti\"),\n moduleCache: true\n },\n rollup: resolveRollupOptions(context) as any,\n debug: context.config.mode === \"development\",\n minify: context.config.mode !== \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_UNBUILD_CONFIG\n );\n}\n"],"mappings":";;;;;;;;AAkCA,MAAa,yBAAyB;CACpC,KAAK;CACL,OAAO;CACP,YAAY;CACZ,aAAa;CACb,WAAW;CACX,MAAM;CACN,cAAc,EAAE;CAChB,YAAY;CACZ,qBAAqB;CACrB,QAAQ;CACR,QAAQ;EACN,KAAK,EAAE;EACP,SAAS;EACT,SAAS,EAAE;EACX,SAAS,EAAE;EACX,MAAM,EAAE;EACR,SAAS,EAAE,QAAQ,UAAU;EAC7B,UAAU,EAAE;EACZ,OAAO,EAAE;EACV;CACF;AAED,MAAa,iBAAiB,YAA0C;AACtE,QAAO,OAAO,OAAO,EAAE,cAAc;AACnC,MACE,CAAC,qBAAqB,KAAK,MAAM,KAAK,IACtC,gBAAgB,KAAK,MAAM,KAAK,CAEhC;EAG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
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
3
|
-
let __rollup_plugin_alias = require("@rollup/plugin-alias");
|
|
4
|
-
__rollup_plugin_alias = require_rolldown_runtime.__toESM(__rollup_plugin_alias);
|
|
5
|
-
let __rollup_plugin_babel = require("@rollup/plugin-babel");
|
|
6
|
-
let __rollup_plugin_inject = require("@rollup/plugin-inject");
|
|
7
|
-
__rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
|
|
8
|
-
let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
9
|
-
__rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
|
|
10
|
-
let __rollup_plugin_replace = require("@rollup/plugin-replace");
|
|
11
|
-
__rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
|
|
12
|
-
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
13
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
14
|
-
let defu = require("defu");
|
|
15
|
-
defu = require_rolldown_runtime.__toESM(defu);
|
|
16
|
-
let node_fs = require("node:fs");
|
|
17
|
-
let rollup_plugin_typescript2 = require("rollup-plugin-typescript2");
|
|
18
|
-
rollup_plugin_typescript2 = require_rolldown_runtime.__toESM(rollup_plugin_typescript2);
|
|
19
|
-
|
|
20
|
-
//#region ../plugin-rollup/src/helpers/resolve-options.ts
|
|
21
|
-
/**
|
|
22
|
-
* A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
|
|
26
|
-
*/
|
|
27
|
-
const dtsBundlePlugin = {
|
|
28
|
-
name: "powerlines:dts-bundle",
|
|
29
|
-
async generateBundle(_opts, bundle) {
|
|
30
|
-
for (const [, file] of Object.entries(bundle)) {
|
|
31
|
-
if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
|
|
32
|
-
const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
|
|
33
|
-
const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
|
|
34
|
-
this.emitFile({
|
|
35
|
-
type: "asset",
|
|
36
|
-
fileName: dtsFileName,
|
|
37
|
-
source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Resolves the options for [rollup](https://rollupjs.org).
|
|
44
|
-
*
|
|
45
|
-
* @param context - The build context.
|
|
46
|
-
* @returns The resolved options.
|
|
47
|
-
*/
|
|
48
|
-
function resolveOptions(context) {
|
|
49
|
-
return (0, defu.default)({
|
|
50
|
-
input: (0, node_fs.globSync)((0, __stryke_convert_to_array.toArray)(context.entry).map((entry) => (0, __stryke_type_checks_is_string.isString)(entry) ? entry : entry.file)).flat(),
|
|
51
|
-
external: (source) => {
|
|
52
|
-
if (context.config.resolve.external && (0, __stryke_convert_to_array.toArray)(context.config.resolve.external).includes(source)) return true;
|
|
53
|
-
if (context.config.resolve.noExternal && (0, __stryke_convert_to_array.toArray)(context.config.resolve.noExternal).includes(source)) return false;
|
|
54
|
-
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
55
|
-
return !context.config.resolve.skipNodeModulesBundle;
|
|
56
|
-
},
|
|
57
|
-
plugins: [
|
|
58
|
-
(0, rollup_plugin_typescript2.default)({
|
|
59
|
-
check: false,
|
|
60
|
-
tsconfig: context.tsconfig.tsconfigFilePath
|
|
61
|
-
}),
|
|
62
|
-
context.config.define && Object.keys(context.config.define).length > 0 && (0, __rollup_plugin_replace.default)({
|
|
63
|
-
sourceMap: context.config.mode === "development",
|
|
64
|
-
preventAssignment: true,
|
|
65
|
-
...context.config.define ?? {}
|
|
66
|
-
}),
|
|
67
|
-
context.config.inject && Object.keys(context.config.inject).length > 0 && (0, __rollup_plugin_inject.default)({
|
|
68
|
-
sourceMap: context.config.mode === "development",
|
|
69
|
-
...context.config.inject
|
|
70
|
-
}),
|
|
71
|
-
(0, __rollup_plugin_alias.default)({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
|
|
72
|
-
if (!ret.find((e) => e.find === id)) ret.push({
|
|
73
|
-
find: id,
|
|
74
|
-
replacement: path
|
|
75
|
-
});
|
|
76
|
-
else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
|
|
77
|
-
return ret;
|
|
78
|
-
}, []) }),
|
|
79
|
-
context.config.babel && (0, __rollup_plugin_babel.getBabelInputPlugin)((0, defu.default)(context.config.babel, {
|
|
80
|
-
caller: {
|
|
81
|
-
name: "powerlines",
|
|
82
|
-
supportsStaticESM: true
|
|
83
|
-
},
|
|
84
|
-
cwd: context.config.root,
|
|
85
|
-
babelrc: false,
|
|
86
|
-
extensions: [
|
|
87
|
-
".js",
|
|
88
|
-
".jsx",
|
|
89
|
-
".ts",
|
|
90
|
-
".tsx"
|
|
91
|
-
],
|
|
92
|
-
babelHelpers: "bundled",
|
|
93
|
-
skipPreflightCheck: true,
|
|
94
|
-
exclude: /node_modules/
|
|
95
|
-
})),
|
|
96
|
-
(0, __rollup_plugin_node_resolve.default)({
|
|
97
|
-
moduleDirectories: ["node_modules"],
|
|
98
|
-
preferBuiltins: true
|
|
99
|
-
}),
|
|
100
|
-
dtsBundlePlugin
|
|
101
|
-
].filter(Boolean)
|
|
102
|
-
}, context.config?.rollup ? context.config?.rollup : {}, {
|
|
103
|
-
cache: !context.config.skipCache ? (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "rollup") : false,
|
|
104
|
-
logLevel: context.config.logLevel,
|
|
105
|
-
output: [{
|
|
106
|
-
dir: context.config.output.buildPath,
|
|
107
|
-
format: "es",
|
|
108
|
-
entryFileNames: "[name].js",
|
|
109
|
-
preserveModules: true,
|
|
110
|
-
sourcemap: context.config.mode === "development"
|
|
111
|
-
}, {
|
|
112
|
-
dir: context.config.output.buildPath,
|
|
113
|
-
format: "cjs",
|
|
114
|
-
entryFileNames: "[name].cjs",
|
|
115
|
-
preserveModules: true,
|
|
116
|
-
sourcemap: context.config.mode === "development"
|
|
117
|
-
}]
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
exports.resolveOptions = resolveOptions;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
2
|
-
import alias from "@rollup/plugin-alias";
|
|
3
|
-
import { getBabelInputPlugin } from "@rollup/plugin-babel";
|
|
4
|
-
import inject from "@rollup/plugin-inject";
|
|
5
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
6
|
-
import replace from "@rollup/plugin-replace";
|
|
7
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
8
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
-
import defu from "defu";
|
|
10
|
-
import { globSync } from "node:fs";
|
|
11
|
-
import typescriptPlugin from "rollup-plugin-typescript2";
|
|
12
|
-
|
|
13
|
-
//#region ../plugin-rollup/src/helpers/resolve-options.ts
|
|
14
|
-
/**
|
|
15
|
-
* A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
|
|
19
|
-
*/
|
|
20
|
-
const dtsBundlePlugin = {
|
|
21
|
-
name: "powerlines:dts-bundle",
|
|
22
|
-
async generateBundle(_opts, bundle) {
|
|
23
|
-
for (const [, file] of Object.entries(bundle)) {
|
|
24
|
-
if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
|
|
25
|
-
const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
|
|
26
|
-
const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
|
|
27
|
-
this.emitFile({
|
|
28
|
-
type: "asset",
|
|
29
|
-
fileName: dtsFileName,
|
|
30
|
-
source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Resolves the options for [rollup](https://rollupjs.org).
|
|
37
|
-
*
|
|
38
|
-
* @param context - The build context.
|
|
39
|
-
* @returns The resolved options.
|
|
40
|
-
*/
|
|
41
|
-
function resolveOptions(context) {
|
|
42
|
-
return defu({
|
|
43
|
-
input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
|
|
44
|
-
external: (source) => {
|
|
45
|
-
if (context.config.resolve.external && toArray(context.config.resolve.external).includes(source)) return true;
|
|
46
|
-
if (context.config.resolve.noExternal && toArray(context.config.resolve.noExternal).includes(source)) return false;
|
|
47
|
-
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
48
|
-
return !context.config.resolve.skipNodeModulesBundle;
|
|
49
|
-
},
|
|
50
|
-
plugins: [
|
|
51
|
-
typescriptPlugin({
|
|
52
|
-
check: false,
|
|
53
|
-
tsconfig: context.tsconfig.tsconfigFilePath
|
|
54
|
-
}),
|
|
55
|
-
context.config.define && Object.keys(context.config.define).length > 0 && replace({
|
|
56
|
-
sourceMap: context.config.mode === "development",
|
|
57
|
-
preventAssignment: true,
|
|
58
|
-
...context.config.define ?? {}
|
|
59
|
-
}),
|
|
60
|
-
context.config.inject && Object.keys(context.config.inject).length > 0 && inject({
|
|
61
|
-
sourceMap: context.config.mode === "development",
|
|
62
|
-
...context.config.inject
|
|
63
|
-
}),
|
|
64
|
-
alias({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
|
|
65
|
-
if (!ret.find((e) => e.find === id)) ret.push({
|
|
66
|
-
find: id,
|
|
67
|
-
replacement: path
|
|
68
|
-
});
|
|
69
|
-
else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
|
|
70
|
-
return ret;
|
|
71
|
-
}, []) }),
|
|
72
|
-
context.config.babel && getBabelInputPlugin(defu(context.config.babel, {
|
|
73
|
-
caller: {
|
|
74
|
-
name: "powerlines",
|
|
75
|
-
supportsStaticESM: true
|
|
76
|
-
},
|
|
77
|
-
cwd: context.config.root,
|
|
78
|
-
babelrc: false,
|
|
79
|
-
extensions: [
|
|
80
|
-
".js",
|
|
81
|
-
".jsx",
|
|
82
|
-
".ts",
|
|
83
|
-
".tsx"
|
|
84
|
-
],
|
|
85
|
-
babelHelpers: "bundled",
|
|
86
|
-
skipPreflightCheck: true,
|
|
87
|
-
exclude: /node_modules/
|
|
88
|
-
})),
|
|
89
|
-
resolve({
|
|
90
|
-
moduleDirectories: ["node_modules"],
|
|
91
|
-
preferBuiltins: true
|
|
92
|
-
}),
|
|
93
|
-
dtsBundlePlugin
|
|
94
|
-
].filter(Boolean)
|
|
95
|
-
}, context.config?.rollup ? context.config?.rollup : {}, {
|
|
96
|
-
cache: !context.config.skipCache ? joinPaths(context.cachePath, "rollup") : false,
|
|
97
|
-
logLevel: context.config.logLevel,
|
|
98
|
-
output: [{
|
|
99
|
-
dir: context.config.output.buildPath,
|
|
100
|
-
format: "es",
|
|
101
|
-
entryFileNames: "[name].js",
|
|
102
|
-
preserveModules: true,
|
|
103
|
-
sourcemap: context.config.mode === "development"
|
|
104
|
-
}, {
|
|
105
|
-
dir: context.config.output.buildPath,
|
|
106
|
-
format: "cjs",
|
|
107
|
-
entryFileNames: "[name].cjs",
|
|
108
|
-
preserveModules: true,
|
|
109
|
-
sourcemap: context.config.mode === "development"
|
|
110
|
-
}]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
export { resolveOptions };
|
|
116
|
-
//# sourceMappingURL=resolve-options.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-options.mjs","names":["dtsBundlePlugin: Plugin"],"sources":["../../../../../plugin-rollup/src/helpers/resolve-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"@powerlines/core/types\";\nimport { BabelPluginResolvedConfig } from \"@powerlines/plugin-babel/types/plugin\";\nimport alias from \"@rollup/plugin-alias\";\nimport {\n getBabelInputPlugin,\n RollupBabelInputPluginOptions\n} from \"@rollup/plugin-babel\";\nimport inject from \"@rollup/plugin-inject\";\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport replace from \"@rollup/plugin-replace\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { globSync } from \"node:fs\";\nimport type { RollupOptions } from \"rollup\";\nimport { Plugin } from \"rollup\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { RollupPluginResolvedConfig } from \"../types/plugin\";\n\n/**\n * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.\n *\n * @remarks\n * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.\n */\nexport const dtsBundlePlugin: Plugin = {\n name: \"powerlines:dts-bundle\",\n async generateBundle(_opts, bundle) {\n for (const [, file] of Object.entries(bundle)) {\n if (\n file.type === \"asset\" ||\n !file.isEntry ||\n file.facadeModuleId == null\n ) {\n continue;\n }\n\n // Replace various JavaScript file extensions (e.g., .js, .cjs, .mjs, .cjs.js, .mjs.js) with .d.ts for generating type definition file names.\n const dtsFileName = file.fileName.replace(\n /(?:\\.cjs|\\.mjs|\\.esm\\.js|\\.cjs\\.js|\\.mjs\\.js|\\.js)$/,\n \".d.ts\"\n );\n\n const relativeSourceDtsName = JSON.stringify(\n `./${file.facadeModuleId.replace(/\\.[cm]?[jt]sx?$/, \"\")}`\n );\n\n this.emitFile({\n type: \"asset\",\n fileName: dtsFileName,\n source: file.exports.includes(\"default\")\n ? `export * from ${relativeSourceDtsName};\\nexport { default } from ${relativeSourceDtsName};\\n`\n : `export * from ${relativeSourceDtsName};\\n`\n });\n }\n }\n};\n\n/**\n * Resolves the options for [rollup](https://rollupjs.org).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(context: Context): RollupOptions {\n const result = defu(\n {\n input: globSync(\n toArray(context.entry).map(entry =>\n isString(entry) ? entry : entry.file\n )\n ).flat(),\n external: (source: string) => {\n if (\n context.config.resolve.external &&\n toArray(context.config.resolve.external).includes(source)\n ) {\n return true;\n }\n\n if (\n context.config.resolve.noExternal &&\n toArray(context.config.resolve.noExternal).includes(source)\n ) {\n return false;\n }\n\n if (context.builtins.includes(source)) {\n return context.config.projectType !== \"application\";\n }\n\n return !context.config.resolve.skipNodeModulesBundle;\n },\n plugins: [\n typescriptPlugin({\n check: false,\n tsconfig: context.tsconfig.tsconfigFilePath\n }),\n context.config.define &&\n Object.keys(context.config.define).length > 0 &&\n replace({\n sourceMap: context.config.mode === \"development\",\n preventAssignment: true,\n ...(context.config.define ?? {})\n }),\n context.config.inject &&\n Object.keys(context.config.inject).length > 0 &&\n inject({\n sourceMap: context.config.mode === \"development\",\n ...context.config.inject\n }),\n alias({\n entries: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n )\n }),\n (context.config as BabelPluginResolvedConfig).babel &&\n getBabelInputPlugin(\n defu((context.config as BabelPluginResolvedConfig).babel, {\n caller: {\n name: \"powerlines\",\n supportsStaticESM: true\n },\n cwd: context.config.root,\n babelrc: false,\n extensions: [\".js\", \".jsx\", \".ts\", \".tsx\"],\n babelHelpers: \"bundled\",\n skipPreflightCheck: true,\n exclude: /node_modules/\n }) as RollupBabelInputPluginOptions\n ),\n resolve({\n moduleDirectories: [\"node_modules\"],\n preferBuiltins: true\n }),\n dtsBundlePlugin\n ].filter(Boolean) as Plugin[]\n },\n (context.config as RollupPluginResolvedConfig)?.rollup\n ? (context.config as RollupPluginResolvedConfig)?.rollup\n : {},\n {\n cache: !context.config.skipCache\n ? joinPaths(context.cachePath, \"rollup\")\n : false,\n logLevel: context.config.logLevel,\n output: [\n {\n dir: context.config.output.buildPath,\n format: \"es\",\n entryFileNames: \"[name].js\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n },\n {\n dir: context.config.output.buildPath,\n format: \"cjs\",\n entryFileNames: \"[name].cjs\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n }\n ]\n }\n ) as RollupOptions;\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,MAAaA,kBAA0B;CACrC,MAAM;CACN,MAAM,eAAe,OAAO,QAAQ;AAClC,OAAK,MAAM,GAAG,SAAS,OAAO,QAAQ,OAAO,EAAE;AAC7C,OACE,KAAK,SAAS,WACd,CAAC,KAAK,WACN,KAAK,kBAAkB,KAEvB;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CAAC,QACpC,KAAK,CAAC,IAAI,UAAU;AACnB,QAAI,CAAC,IAAI,MAAK,MAAK,EAAE,SAAS,GAAG,CAC/B,KAAI,KAAK;KACP,MAAM;KACN,aAAa;KACd,CAAC;QAEF,SAAQ,KACN,8BAA8B,GAAG,2CAClC;AAGH,WAAO;MAET,EAAE,CACH,EACF,CAAC;GACD,QAAQ,OAAqC,SAC5C,oBACE,KAAM,QAAQ,OAAqC,OAAO;IACxD,QAAQ;KACN,MAAM;KACN,mBAAmB;KACpB;IACD,KAAK,QAAQ,OAAO;IACpB,SAAS;IACT,YAAY;KAAC;KAAO;KAAQ;KAAO;KAAO;IAC1C,cAAc;IACd,oBAAoB;IACpB,SAAS;IACV,CAAC,CACH;GACH,QAAQ;IACN,mBAAmB,CAAC,eAAe;IACnC,gBAAgB;IACjB,CAAC;GACF;GACD,CAAC,OAAO,QAAQ;EAClB,EACA,QAAQ,QAAuC,SAC3C,QAAQ,QAAuC,SAChD,EAAE,EACN;EACE,OAAO,CAAC,QAAQ,OAAO,YACnB,UAAU,QAAQ,WAAW,SAAS,GACtC;EACJ,UAAU,QAAQ,OAAO;EACzB,QAAQ,CACN;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,gBAAgB;GAChB,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,EACD;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,gBAAgB;GAChB,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,CACF;EACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.cts","names":[],"sources":["../../src/types/build.ts"],"sourcesContent":[],"mappings":";;;KAoBY,cAAA,GAAiB,QAC3B,KACE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.mts","names":[],"sources":["../../src/types/build.ts"],"sourcesContent":[],"mappings":";;;KAoBY,cAAA,GAAiB,QAC3B,KACE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAyBY,oBAAA,GAAuB,QAAQ;UAE1B,uBAAA,SAAgC;YACrC;AAHZ;AAEiB,UAIA,2BAAA,SAAoC,cAJJ,CAAA;EAIhC,OAAA,EACN,cADM;AAIjB;AAC0B,KADd,oBACc,CAAA,wBAAA,2BAAA,GACtB,2BADsB,CAAA,GAEtB,aAFsB,CAER,eAFQ,CAAA;AACtB,uCAAA,GAAA,EAAA;AACc,0CAAA,GAAA,EAAA;AAAd,8CAAA,GAAA,EAAA;AAAa,uCAAA,GAAA,EAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;KAyBY,oBAAA,GAAuB,QAAQ;UAE1B,uBAAA,SAAgC;YACrC;;AAHA,UAMK,2BAAA,SAAoC,cANX,CAAA;EAEzB,OAAA,EAKN,cALM;AAIjB;AAIY,KAAA,oBAAoB,CAAA,wBACN,2BADM,GAE5B,2BAF4B,CAAA,GAG5B,aAH4B,CAGd,eAHc,CAAA;AACN,uCAAA,GAAA,EAAA;AACtB,0CAAA,GAAA,EAAA;AACc,8CAAA,GAAA,EAAA;AAAd,uCAAA,GAAA,EAAA"}
|