@powerlines/plugin-unbuild 0.5.137 → 0.5.139

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/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- const require_unbuild = require('./powerlines/src/lib/build/unbuild.cjs');
4
2
  let __storm_software_unbuild = require("@storm-software/unbuild");
3
+ let powerlines_lib_build_unbuild = require("powerlines/lib/build/unbuild");
5
4
 
6
5
  //#region src/index.ts
7
6
  /**
@@ -14,14 +13,14 @@ const plugin = (options = {}) => {
14
13
  return {
15
14
  output: { format: ["esm"] },
16
15
  build: {
17
- ...require_unbuild.DEFAULT_UNBUILD_CONFIG,
16
+ ...powerlines_lib_build_unbuild.DEFAULT_UNBUILD_CONFIG,
18
17
  ...options,
19
18
  variant: "unbuild"
20
19
  }
21
20
  };
22
21
  },
23
22
  async build() {
24
- await (0, __storm_software_unbuild.build)(require_unbuild.extractUnbuildConfig(this));
23
+ await (0, __storm_software_unbuild.build)((0, powerlines_lib_build_unbuild.extractUnbuildConfig)(this));
25
24
  }
26
25
  };
27
26
  };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
2
  import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig } from "./types/plugin.mjs";
3
- import "./types/index.mjs";
4
3
 
5
4
  //#region src/index.d.ts
6
5
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { DEFAULT_UNBUILD_CONFIG, extractUnbuildConfig } from "./powerlines/src/lib/build/unbuild.mjs";
2
1
  import { build } from "@storm-software/unbuild";
2
+ import { DEFAULT_UNBUILD_CONFIG, extractUnbuildConfig } from "powerlines/lib/build/unbuild";
3
3
 
4
4
  //#region src/index.ts
5
5
  /**
@@ -1,5 +1,3 @@
1
- import "../../types/hooks.mjs";
2
- import "../../types/resolved.mjs";
3
1
  import { SelectHooksOptions } from "../../types/context.mjs";
4
2
  import { MaybePromise } from "@stryke/types/base";
5
3
 
@@ -1,9 +1,9 @@
1
- import { BuildOptions } from "esbuild";
2
1
  import { OutputOptions, RollupOptions } from "rollup";
3
2
  import { UserConfig } from "@farmfe/core";
4
3
  import { Configuration } from "@rspack/core";
5
- import { BuildOptions as BuildOptions$1 } from "@storm-software/tsup/types";
4
+ import { BuildOptions } from "@storm-software/tsup/types";
6
5
  import { UnbuildOptions } from "@storm-software/unbuild/types";
6
+ import { BuildOptions as BuildOptions$1 } from "esbuild";
7
7
  import { RolldownOptions } from "rolldown";
8
8
  import { UserConfig as UserConfig$1 } from "tsdown";
9
9
  import { DepOptimizationOptions, UserConfig as UserConfig$2 } from "vite";
@@ -153,8 +153,8 @@ interface BuildConfig {
153
153
  override?: Record<string, any>;
154
154
  }
155
155
  type BuildResolvedConfig = Omit<BuildConfig, "override">;
156
- type ESBuildBuildConfig = Omit<BuildOptions, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
157
- type ESBuildResolvedBuildConfig = Omit<BuildOptions, "inject"> & BuildResolvedConfig;
156
+ type ESBuildBuildConfig = Omit<BuildOptions$1, "entryPoints" | "sourceRoot" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel"> & BuildConfig;
157
+ type ESBuildResolvedBuildConfig = Omit<BuildOptions$1, "inject"> & BuildResolvedConfig;
158
158
  type ViteBuildConfig = Omit<UserConfig$2, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig & {
159
159
  /**
160
160
  * Optimize deps config
@@ -173,8 +173,8 @@ type RollupBuildConfig = Omit<RollupOptions, "entry" | "external" | "input" | "o
173
173
  type RollupResolvedBuildConfig = RollupOptions & BuildResolvedConfig;
174
174
  type RolldownBuildConfig = Omit<RolldownOptions, "input" | "external" | "tsconfig" | "logLevel" | "output"> & BuildConfig;
175
175
  type RolldownResolvedBuildConfig = RolldownOptions & BuildResolvedConfig;
176
- type TsupBuildConfig = Partial<Omit<BuildOptions$1, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
177
- type TsupResolvedBuildConfig = BuildOptions$1 & BuildResolvedConfig;
176
+ type TsupBuildConfig = Partial<Omit<BuildOptions, "userOptions" | "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "clean" | "env" | "entry" | "entryPoints" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
177
+ type TsupResolvedBuildConfig = BuildOptions & BuildResolvedConfig;
178
178
  type TsdownBuildConfig = Partial<Omit<UserConfig$1, "name" | "outDir" | "clean" | "cwd" | "tsconfig" | "publicDir" | "copy" | "alias" | "format" | "platform" | "env" | "define" | "entry" | "external" | "noExternal" | "skipNodeModulesBundle">> & BuildConfig;
179
179
  type TsdownResolvedBuildConfig = UserConfig$1 & BuildResolvedConfig;
180
180
  type UnbuildBuildConfig = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
@@ -1,4 +1,3 @@
1
- import "./context.mjs";
2
1
  import { ArrayValues } from "@stryke/types/array";
3
2
  import { MaybePromise } from "@stryke/types/base";
4
3
 
@@ -1,5 +1,4 @@
1
1
  import { BuildConfig, BuildResolvedConfig, ESBuildBuildConfig, ESBuildResolvedBuildConfig, FarmBuildConfig, FarmResolvedBuildConfig, RolldownBuildConfig, RolldownResolvedBuildConfig, RollupBuildConfig, RollupResolvedBuildConfig, RspackBuildConfig, RspackResolvedBuildConfig, TsdownBuildConfig, TsdownResolvedBuildConfig, TsupBuildConfig, TsupResolvedBuildConfig, UnbuildBuildConfig, UnbuildResolvedBuildConfig, ViteBuildConfig, ViteResolvedBuildConfig, WebpackBuildConfig, WebpackResolvedBuildConfig } from "./build.mjs";
2
- import "./babel.mjs";
3
2
  import { StoragePort, StoragePreset } from "./fs.mjs";
4
3
  import { TSConfig } from "./tsconfig.mjs";
5
4
  import { PluginContext } from "./context.mjs";
@@ -14,6 +13,7 @@ import { AssetGlob } from "@stryke/types/file";
14
13
  import { DateString } from "compatx";
15
14
 
16
15
  //#region ../powerlines/src/types/config.d.ts
16
+
17
17
  type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
18
18
  /**
19
19
  * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
@@ -4,13 +4,13 @@ import { InlineConfig, LogFn, UserConfig, WorkspaceConfig } from "./config.mjs";
4
4
  import { HooksList, InferHooksListItem } from "./hooks.mjs";
5
5
  import { EnvironmentResolvedConfig, ResolvedConfig, ResolvedEntryTypeDefinition } from "./resolved.mjs";
6
6
  import { Plugin } from "./plugin.mjs";
7
- import { SourceMap } from "magic-string";
8
7
  import { NonUndefined } from "@stryke/types/base";
9
8
  import { ExternalIdResult, UnpluginBuildContext, UnpluginContext, UnpluginMessage } from "unplugin";
10
9
  import { EnvPaths } from "@stryke/env/get-env-paths";
11
10
  import { FetchRequestOptions } from "@stryke/http/fetch";
12
11
  import { PackageJson } from "@stryke/types/package-json";
13
12
  import { Jiti } from "jiti";
13
+ import { SourceMap } from "magic-string";
14
14
  import { ParseResult, ParserOptions } from "oxc-parser";
15
15
  import { Range } from "semver";
16
16
  import { Project } from "ts-morph";
@@ -1,5 +1,4 @@
1
1
  import { BuilderVariant, InferUnpluginVariant, UnpluginBuilderVariant } from "./build.mjs";
2
- import "./config.mjs";
3
2
  import { InferResolvedConfig } from "./resolved.mjs";
4
3
  import { Context } from "./context.mjs";
5
4
  import { API } from "./api.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unbuild",
3
- "version": "0.5.137",
3
+ "version": "0.5.139",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin to build projects using Unbuild.",
6
6
  "repository": {
@@ -146,20 +146,12 @@
146
146
  "keywords": ["unbuild", "powerlines", "storm-software", "powerlines-plugin"],
147
147
  "dependencies": {
148
148
  "@storm-software/unbuild": "^0.57.75",
149
- "@stryke/fs": "^0.33.27",
150
- "@stryke/path": "^0.24.1",
151
- "@stryke/type-checks": "^0.5.15",
152
- "@stryke/types": "^0.10.29",
153
- "defu": "^6.1.4",
154
- "jiti": "^2.6.1",
155
- "powerlines": "^0.37.1",
156
- "unplugin": "3.0.0-beta.3"
149
+ "powerlines": "^0.37.3"
157
150
  },
158
151
  "devDependencies": {
159
- "@powerlines/nx": "^0.11.57",
160
- "@powerlines/plugin-plugin": "^0.12.79",
152
+ "@powerlines/plugin-plugin": "^0.12.81",
161
153
  "@types/node": "^24.10.4"
162
154
  },
163
155
  "publishConfig": { "access": "public" },
164
- "gitHead": "de1cf37aba4595c9b10fbe4e26a87f8609d2ad1f"
156
+ "gitHead": "ae9a5afaa497538477b63988242f433b60974623"
165
157
  }
@@ -1,29 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
@@ -1,134 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_helpers_omit = require("@stryke/helpers/omit");
3
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
4
- let defu = require("defu");
5
- defu = require_rolldown_runtime.__toESM(defu);
6
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
7
- let __rollup_plugin_alias = require("@rollup/plugin-alias");
8
- __rollup_plugin_alias = require_rolldown_runtime.__toESM(__rollup_plugin_alias);
9
- let __rollup_plugin_babel = require("@rollup/plugin-babel");
10
- let __rollup_plugin_inject = require("@rollup/plugin-inject");
11
- __rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
12
- let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
13
- __rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
14
- let __rollup_plugin_replace = require("@rollup/plugin-replace");
15
- __rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
16
- let __stryke_convert_to_array = require("@stryke/convert/to-array");
17
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
18
- let node_fs = require("node:fs");
19
- let rollup_plugin_typescript2 = require("rollup-plugin-typescript2");
20
- rollup_plugin_typescript2 = require_rolldown_runtime.__toESM(rollup_plugin_typescript2);
21
-
22
- //#region ../powerlines/src/lib/build/rollup.ts
23
- /**
24
- * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
25
- *
26
- * @remarks
27
- * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
28
- */
29
- const dtsBundlePlugin = {
30
- name: "powerlines:dts-bundle",
31
- async generateBundle(_opts, bundle) {
32
- for (const [, file] of Object.entries(bundle)) {
33
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
34
- const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
35
- const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
36
- this.emitFile({
37
- type: "asset",
38
- fileName: dtsFileName,
39
- source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
40
- });
41
- }
42
- }
43
- };
44
- /**
45
- * Resolves the options for [rollup](https://rollupjs.org).
46
- *
47
- * @param context - The build context.
48
- * @returns The resolved options.
49
- */
50
- function extractRollupConfig(context) {
51
- return (0, defu.default)({
52
- 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(),
53
- external: (source, importer, isResolved) => {
54
- const externalFn = context.config.build.variant === "rollup" && context.config.build.override.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.override.external) ? context.config.build.override.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build.override.external).includes(id) : context.config.build.variant === "vite" && context.config.build.override.build?.rollupOptions?.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.override.build?.rollupOptions?.external) ? context.config.build.override.build?.rollupOptions?.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build?.build?.rollupOptions?.external).includes(id) : context.config.build.variant === "rollup" && context.config.build.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.external) ? context.config.build.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build.external).includes(id) : context.config.build.variant === "vite" && context.config.build.build?.rollupOptions?.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.build?.rollupOptions?.external) ? context.config.build.build?.rollupOptions?.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build?.build?.rollupOptions?.external).includes(id) : void 0;
55
- if ((0, __stryke_type_checks_is_function.isFunction)(externalFn) && externalFn(source, importer, isResolved)) return true;
56
- if (context.config.build.external && (0, __stryke_convert_to_array.toArray)(context.config.build.external).includes(source)) return true;
57
- if (context.config.build.noExternal && (0, __stryke_convert_to_array.toArray)(context.config.build.noExternal).includes(source)) return false;
58
- if (context.builtins.includes(source)) return context.config.projectType !== "application";
59
- return !context.config.build.skipNodeModulesBundle;
60
- },
61
- plugins: [
62
- (0, rollup_plugin_typescript2.default)({
63
- check: false,
64
- tsconfig: context.tsconfig.tsconfigFilePath
65
- }),
66
- context.config.build.define && Object.keys(context.config.build.define).length > 0 && (0, __rollup_plugin_replace.default)({
67
- sourceMap: context.config.mode === "development",
68
- preventAssignment: true,
69
- ...context.config.build.define ?? {}
70
- }),
71
- context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && (0, __rollup_plugin_inject.default)({
72
- sourceMap: context.config.mode === "development",
73
- ...context.config.build.inject
74
- }),
75
- (0, __rollup_plugin_alias.default)({ entries: context.builtins.reduce((ret, id) => {
76
- if (!ret.find((e) => e.find === id)) {
77
- const path = context.fs.ids[id];
78
- if (path) ret.push({
79
- find: id,
80
- replacement: path
81
- });
82
- }
83
- return ret;
84
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
85
- if (!ret.find((e) => e.find === id)) ret.push({
86
- find: id,
87
- replacement: path
88
- });
89
- return ret;
90
- }, []) : []) }),
91
- (0, __rollup_plugin_babel.getBabelInputPlugin)((0, defu.default)(context.config.transform.babel, {
92
- caller: {
93
- name: "powerlines",
94
- supportsStaticESM: true
95
- },
96
- cwd: context.config.projectRoot,
97
- babelrc: false,
98
- extensions: [
99
- ".js",
100
- ".jsx",
101
- ".ts",
102
- ".tsx"
103
- ],
104
- babelHelpers: "bundled",
105
- skipPreflightCheck: true,
106
- exclude: /node_modules/
107
- })),
108
- (0, __rollup_plugin_node_resolve.default)({
109
- moduleDirectories: ["node_modules"],
110
- preferBuiltins: true
111
- }),
112
- dtsBundlePlugin
113
- ].filter(Boolean)
114
- }, context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rollup" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build?.rollupOptions : {}, {
115
- cache: !context.config.skipCache ? (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "rollup") : false,
116
- logLevel: context.config.logLevel,
117
- output: [{
118
- dir: context.config.output.buildPath,
119
- format: "es",
120
- entryFileNames: "[name].js",
121
- preserveModules: true,
122
- sourcemap: context.config.mode === "development"
123
- }, {
124
- dir: context.config.output.buildPath,
125
- format: "cjs",
126
- entryFileNames: "[name].cjs",
127
- preserveModules: true,
128
- sourcemap: context.config.mode === "development"
129
- }]
130
- });
131
- }
132
-
133
- //#endregion
134
- exports.extractRollupConfig = extractRollupConfig;
@@ -1,127 +0,0 @@
1
- import { omit } from "@stryke/helpers/omit";
2
- import { joinPaths } from "@stryke/path/join-paths";
3
- import defu from "defu";
4
- import { isString } from "@stryke/type-checks/is-string";
5
- import alias from "@rollup/plugin-alias";
6
- import { getBabelInputPlugin } from "@rollup/plugin-babel";
7
- import inject from "@rollup/plugin-inject";
8
- import resolve from "@rollup/plugin-node-resolve";
9
- import replace from "@rollup/plugin-replace";
10
- import { toArray } from "@stryke/convert/to-array";
11
- import { isFunction } from "@stryke/type-checks/is-function";
12
- import { globSync } from "node:fs";
13
- import typescriptPlugin from "rollup-plugin-typescript2";
14
-
15
- //#region ../powerlines/src/lib/build/rollup.ts
16
- /**
17
- * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
18
- *
19
- * @remarks
20
- * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
21
- */
22
- const dtsBundlePlugin = {
23
- name: "powerlines:dts-bundle",
24
- async generateBundle(_opts, bundle) {
25
- for (const [, file] of Object.entries(bundle)) {
26
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
27
- const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
28
- const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
29
- this.emitFile({
30
- type: "asset",
31
- fileName: dtsFileName,
32
- source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
33
- });
34
- }
35
- }
36
- };
37
- /**
38
- * Resolves the options for [rollup](https://rollupjs.org).
39
- *
40
- * @param context - The build context.
41
- * @returns The resolved options.
42
- */
43
- function extractRollupConfig(context) {
44
- return defu({
45
- input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
46
- external: (source, importer, isResolved) => {
47
- const externalFn = context.config.build.variant === "rollup" && context.config.build.override.external ? isFunction(context.config.build.override.external) ? context.config.build.override.external : (id) => toArray(context.config.build.override.external).includes(id) : context.config.build.variant === "vite" && context.config.build.override.build?.rollupOptions?.external ? isFunction(context.config.build.override.build?.rollupOptions?.external) ? context.config.build.override.build?.rollupOptions?.external : (id) => toArray(context.config.build?.build?.rollupOptions?.external).includes(id) : context.config.build.variant === "rollup" && context.config.build.external ? isFunction(context.config.build.external) ? context.config.build.external : (id) => toArray(context.config.build.external).includes(id) : context.config.build.variant === "vite" && context.config.build.build?.rollupOptions?.external ? isFunction(context.config.build.build?.rollupOptions?.external) ? context.config.build.build?.rollupOptions?.external : (id) => toArray(context.config.build?.build?.rollupOptions?.external).includes(id) : void 0;
48
- if (isFunction(externalFn) && externalFn(source, importer, isResolved)) return true;
49
- if (context.config.build.external && toArray(context.config.build.external).includes(source)) return true;
50
- if (context.config.build.noExternal && toArray(context.config.build.noExternal).includes(source)) return false;
51
- if (context.builtins.includes(source)) return context.config.projectType !== "application";
52
- return !context.config.build.skipNodeModulesBundle;
53
- },
54
- plugins: [
55
- typescriptPlugin({
56
- check: false,
57
- tsconfig: context.tsconfig.tsconfigFilePath
58
- }),
59
- context.config.build.define && Object.keys(context.config.build.define).length > 0 && replace({
60
- sourceMap: context.config.mode === "development",
61
- preventAssignment: true,
62
- ...context.config.build.define ?? {}
63
- }),
64
- context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && inject({
65
- sourceMap: context.config.mode === "development",
66
- ...context.config.build.inject
67
- }),
68
- alias({ entries: context.builtins.reduce((ret, id) => {
69
- if (!ret.find((e) => e.find === id)) {
70
- const path = context.fs.ids[id];
71
- if (path) ret.push({
72
- find: id,
73
- replacement: path
74
- });
75
- }
76
- return ret;
77
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
78
- if (!ret.find((e) => e.find === id)) ret.push({
79
- find: id,
80
- replacement: path
81
- });
82
- return ret;
83
- }, []) : []) }),
84
- getBabelInputPlugin(defu(context.config.transform.babel, {
85
- caller: {
86
- name: "powerlines",
87
- supportsStaticESM: true
88
- },
89
- cwd: context.config.projectRoot,
90
- babelrc: false,
91
- extensions: [
92
- ".js",
93
- ".jsx",
94
- ".ts",
95
- ".tsx"
96
- ],
97
- babelHelpers: "bundled",
98
- skipPreflightCheck: true,
99
- exclude: /node_modules/
100
- })),
101
- resolve({
102
- moduleDirectories: ["node_modules"],
103
- preferBuiltins: true
104
- }),
105
- dtsBundlePlugin
106
- ].filter(Boolean)
107
- }, context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rollup" ? omit(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build?.rollupOptions : {}, {
108
- cache: !context.config.skipCache ? joinPaths(context.cachePath, "rollup") : false,
109
- logLevel: context.config.logLevel,
110
- output: [{
111
- dir: context.config.output.buildPath,
112
- format: "es",
113
- entryFileNames: "[name].js",
114
- preserveModules: true,
115
- sourcemap: context.config.mode === "development"
116
- }, {
117
- dir: context.config.output.buildPath,
118
- format: "cjs",
119
- entryFileNames: "[name].cjs",
120
- preserveModules: true,
121
- sourcemap: context.config.mode === "development"
122
- }]
123
- });
124
- }
125
-
126
- //#endregion
127
- export { extractRollupConfig };
@@ -1,135 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- const require_source_file = require('../utilities/source-file.cjs');
3
- const require_rollup = require('./rollup.cjs');
4
- let __stryke_helpers_omit = require("@stryke/helpers/omit");
5
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
6
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
7
- let defu = require("defu");
8
- defu = require_rolldown_runtime.__toESM(defu);
9
- let esbuild = require("esbuild");
10
-
11
- //#region ../powerlines/src/lib/build/unbuild.ts
12
- const DEFAULT_UNBUILD_CONFIG = {
13
- dts: true,
14
- clean: false,
15
- includeSrc: false,
16
- treeShaking: true,
17
- splitting: true,
18
- stub: false,
19
- watchOptions: {},
20
- outputPath: "dist",
21
- generatePackageJson: true,
22
- banner: " ",
23
- rollup: {
24
- dts: {},
25
- emitCJS: true,
26
- replace: {},
27
- resolve: {},
28
- json: {},
29
- esbuild: { target: "es2020" },
30
- commonjs: {},
31
- alias: {}
32
- }
33
- };
34
- const unbuildLoader = (context) => {
35
- return async (input, { options }) => {
36
- if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
37
- const output = [];
38
- let contents = await input.getContents();
39
- if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
40
- const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
41
- output.push({
42
- contents,
43
- srcPath: input.srcPath,
44
- path: input.path,
45
- extension: extension$1,
46
- declaration: true
47
- });
48
- }
49
- let transformed = contents;
50
- let result = await context.$$internal.callHook("transform", {
51
- sequential: true,
52
- order: "pre"
53
- }, transformed, input.path);
54
- if (result) transformed = result;
55
- result = await context.$$internal.callHook("transform", {
56
- sequential: true,
57
- order: "normal"
58
- }, require_source_file.getString(transformed), input.path);
59
- if (result) transformed = result;
60
- result = await context.$$internal.callHook("transform", {
61
- sequential: true,
62
- order: "post"
63
- }, require_source_file.getString(transformed), input.path);
64
- if (result) transformed = result;
65
- if ([
66
- ".ts",
67
- ".mts",
68
- ".cts"
69
- ].includes(input.extension)) contents = await (0, esbuild.transform)(require_source_file.getString(transformed), {
70
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
71
- loader: "ts"
72
- }).then((r) => r.code);
73
- else if ([".tsx", ".jsx"].includes(input.extension)) contents = await (0, esbuild.transform)(require_source_file.getString(transformed), {
74
- loader: input.extension === ".tsx" ? "tsx" : "jsx",
75
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
76
- }).then((r) => r.code);
77
- const isCjs = options.format === "cjs";
78
- if (isCjs) contents = context.resolver.transform({
79
- source: contents,
80
- retainLines: false
81
- }).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
82
- let extension = isCjs ? ".js" : ".mjs";
83
- if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
84
- output.push({
85
- contents,
86
- path: input.path,
87
- extension
88
- });
89
- return output;
90
- };
91
- };
92
- /**
93
- * Extracts the unbuild configuration from the context.
94
- *
95
- * @param context - The build context.
96
- * @returns The resolved unbuild configuration.
97
- */
98
- function extractUnbuildConfig(context) {
99
- return (0, defu.default)({ alias: context.builtins.reduce((ret, id) => {
100
- if (!ret[id]) {
101
- const path = context.fs.ids[id];
102
- if (path) ret[id] = path;
103
- }
104
- return ret;
105
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
106
- if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
107
- return ret;
108
- }, {}) : context.config.build.alias : {}) }, context.config.build.variant === "unbuild" ? context.config.build.override : {}, context.config.build.variant === "unbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, {
109
- projectName: context.config.name,
110
- name: context.config.name,
111
- orgName: (0, __stryke_type_checks_is_object.isObject)(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
112
- sourceRoot: context.config.sourceRoot,
113
- projectRoot: context.config.projectRoot,
114
- outputPath: context.config.output.buildPath || "dist",
115
- platform: context.config.build.platform,
116
- external: context.builtins.reduce((ret, id) => {
117
- if (!ret.includes(id)) ret.push(id);
118
- return ret;
119
- }, context.config.build.external ?? []),
120
- loaders: [unbuildLoader(context)],
121
- jiti: {
122
- interopDefault: true,
123
- fsCache: (0, __stryke_path_join_paths.joinPaths)(context.envPaths.cache, "jiti"),
124
- moduleCache: true
125
- },
126
- rollup: require_rollup.extractRollupConfig(context),
127
- debug: context.config.mode === "development",
128
- minify: context.config.mode !== "development",
129
- sourcemap: context.config.mode === "development"
130
- }, DEFAULT_UNBUILD_CONFIG);
131
- }
132
-
133
- //#endregion
134
- exports.DEFAULT_UNBUILD_CONFIG = DEFAULT_UNBUILD_CONFIG;
135
- exports.extractUnbuildConfig = extractUnbuildConfig;
@@ -1,132 +0,0 @@
1
- import { getString } from "../utilities/source-file.mjs";
2
- import { extractRollupConfig } from "./rollup.mjs";
3
- import { omit } from "@stryke/helpers/omit";
4
- import { joinPaths } from "@stryke/path/join-paths";
5
- import { isObject } from "@stryke/type-checks/is-object";
6
- import defu from "defu";
7
- import { transform } from "esbuild";
8
-
9
- //#region ../powerlines/src/lib/build/unbuild.ts
10
- const DEFAULT_UNBUILD_CONFIG = {
11
- dts: true,
12
- clean: false,
13
- includeSrc: false,
14
- treeShaking: true,
15
- splitting: true,
16
- stub: false,
17
- watchOptions: {},
18
- outputPath: "dist",
19
- generatePackageJson: true,
20
- banner: " ",
21
- rollup: {
22
- dts: {},
23
- emitCJS: true,
24
- replace: {},
25
- resolve: {},
26
- json: {},
27
- esbuild: { target: "es2020" },
28
- commonjs: {},
29
- alias: {}
30
- }
31
- };
32
- const unbuildLoader = (context) => {
33
- return async (input, { options }) => {
34
- if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
35
- const output = [];
36
- let contents = await input.getContents();
37
- if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
38
- const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
39
- output.push({
40
- contents,
41
- srcPath: input.srcPath,
42
- path: input.path,
43
- extension: extension$1,
44
- declaration: true
45
- });
46
- }
47
- let transformed = contents;
48
- let result = await context.$$internal.callHook("transform", {
49
- sequential: true,
50
- order: "pre"
51
- }, transformed, input.path);
52
- if (result) transformed = result;
53
- result = await context.$$internal.callHook("transform", {
54
- sequential: true,
55
- order: "normal"
56
- }, getString(transformed), input.path);
57
- if (result) transformed = result;
58
- result = await context.$$internal.callHook("transform", {
59
- sequential: true,
60
- order: "post"
61
- }, getString(transformed), input.path);
62
- if (result) transformed = result;
63
- if ([
64
- ".ts",
65
- ".mts",
66
- ".cts"
67
- ].includes(input.extension)) contents = await transform(getString(transformed), {
68
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
69
- loader: "ts"
70
- }).then((r) => r.code);
71
- else if ([".tsx", ".jsx"].includes(input.extension)) contents = await transform(getString(transformed), {
72
- loader: input.extension === ".tsx" ? "tsx" : "jsx",
73
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
74
- }).then((r) => r.code);
75
- const isCjs = options.format === "cjs";
76
- if (isCjs) contents = context.resolver.transform({
77
- source: contents,
78
- retainLines: false
79
- }).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
80
- let extension = isCjs ? ".js" : ".mjs";
81
- if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
82
- output.push({
83
- contents,
84
- path: input.path,
85
- extension
86
- });
87
- return output;
88
- };
89
- };
90
- /**
91
- * Extracts the unbuild configuration from the context.
92
- *
93
- * @param context - The build context.
94
- * @returns The resolved unbuild configuration.
95
- */
96
- function extractUnbuildConfig(context) {
97
- return defu({ alias: context.builtins.reduce((ret, id) => {
98
- if (!ret[id]) {
99
- const path = context.fs.ids[id];
100
- if (path) ret[id] = path;
101
- }
102
- return ret;
103
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
104
- if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
105
- return ret;
106
- }, {}) : context.config.build.alias : {}) }, context.config.build.variant === "unbuild" ? context.config.build.override : {}, context.config.build.variant === "unbuild" ? omit(context.config.build, ["override", "variant"]) : {}, {
107
- projectName: context.config.name,
108
- name: context.config.name,
109
- orgName: isObject(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
110
- sourceRoot: context.config.sourceRoot,
111
- projectRoot: context.config.projectRoot,
112
- outputPath: context.config.output.buildPath || "dist",
113
- platform: context.config.build.platform,
114
- external: context.builtins.reduce((ret, id) => {
115
- if (!ret.includes(id)) ret.push(id);
116
- return ret;
117
- }, context.config.build.external ?? []),
118
- loaders: [unbuildLoader(context)],
119
- jiti: {
120
- interopDefault: true,
121
- fsCache: joinPaths(context.envPaths.cache, "jiti"),
122
- moduleCache: true
123
- },
124
- rollup: extractRollupConfig(context),
125
- debug: context.config.mode === "development",
126
- minify: context.config.mode !== "development",
127
- sourcemap: context.config.mode === "development"
128
- }, DEFAULT_UNBUILD_CONFIG);
129
- }
130
-
131
- //#endregion
132
- export { DEFAULT_UNBUILD_CONFIG, extractUnbuildConfig };
@@ -1,22 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- require("@stryke/fs/read-file");
3
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
5
- require("magic-string");
6
-
7
- //#region ../powerlines/src/lib/utilities/source-file.ts
8
- /**
9
- * Get the string from the source.
10
- *
11
- * @param code - The source string or magic string.
12
- * @returns The source string.
13
- */
14
- function getString(code) {
15
- if (!code) return "";
16
- if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
17
- if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
18
- return code.toString();
19
- }
20
-
21
- //#endregion
22
- exports.getString = getString;
@@ -1,21 +0,0 @@
1
- import "@stryke/fs/read-file";
2
- import { isSetObject } from "@stryke/type-checks/is-set-object";
3
- import { isString } from "@stryke/type-checks/is-string";
4
- import "magic-string";
5
-
6
- //#region ../powerlines/src/lib/utilities/source-file.ts
7
- /**
8
- * Get the string from the source.
9
- *
10
- * @param code - The source string or magic string.
11
- * @returns The source string.
12
- */
13
- function getString(code) {
14
- if (!code) return "";
15
- if (isString(code)) return code;
16
- if (isSetObject(code) && "code" in code) return code.code;
17
- return code.toString();
18
- }
19
-
20
- //#endregion
21
- export { getString };
@@ -1,2 +0,0 @@
1
- import "./config.mjs";
2
- import "./context.mjs";