@powerlines/plugin-vite 0.14.124 → 0.14.125
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/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/helpers/index.cjs +2 -3
- package/dist/helpers/index.d.cts +1 -3
- package/dist/helpers/index.d.mts +1 -3
- package/dist/helpers/index.mjs +1 -2
- package/dist/helpers/unplugin.cjs +11 -2
- package/dist/helpers/unplugin.d.cts +6 -2
- package/dist/helpers/unplugin.d.mts +6 -2
- package/dist/helpers/unplugin.mjs +9 -1
- package/dist/index.cjs +9 -170
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +3 -165
- package/dist/powerlines/schemas/fs.cjs +226 -0
- package/dist/powerlines/schemas/fs.mjs +224 -0
- package/dist/powerlines/src/api.cjs +580 -0
- package/dist/powerlines/src/api.mjs +578 -0
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -0
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -0
- package/dist/powerlines/src/internal/helpers/environment.cjs +52 -0
- package/dist/powerlines/src/internal/helpers/environment.mjs +48 -0
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +51 -0
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +49 -0
- package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.cts +48 -0
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +50 -0
- package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -0
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -0
- package/dist/powerlines/src/internal/helpers/install.cjs +37 -0
- package/dist/powerlines/src/internal/helpers/install.mjs +36 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +98 -0
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +94 -0
- package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
- package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
- package/dist/powerlines/src/lib/build/vite.cjs +74 -0
- package/dist/powerlines/src/lib/build/vite.mjs +71 -0
- package/dist/powerlines/src/lib/config-file.cjs +79 -0
- package/dist/powerlines/src/lib/config-file.mjs +76 -0
- package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
- package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
- package/dist/powerlines/src/lib/contexts/context.cjs +933 -0
- package/dist/powerlines/src/lib/contexts/context.mjs +931 -0
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -0
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -0
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -0
- package/dist/powerlines/src/lib/entry.cjs +69 -0
- package/dist/powerlines/src/lib/entry.mjs +67 -0
- package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
- package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
- package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
- package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
- package/dist/powerlines/src/lib/fs/vfs.cjs +830 -0
- package/dist/powerlines/src/lib/fs/vfs.mjs +828 -0
- package/dist/powerlines/src/lib/logger.cjs +58 -0
- package/dist/powerlines/src/lib/logger.mjs +55 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -0
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
- package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
- package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -0
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -0
- package/dist/powerlines/src/lib/unplugin/index.cjs +3 -0
- package/dist/powerlines/src/lib/unplugin/index.mjs +5 -0
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +128 -0
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +127 -0
- package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
- package/dist/powerlines/src/lib/utilities/meta.cjs +45 -0
- package/dist/powerlines/src/lib/utilities/meta.mjs +41 -0
- package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
- package/dist/powerlines/src/lib/utilities/source-file.mjs +20 -0
- package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -0
- package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
- package/dist/powerlines/src/types/api.d.cts +104 -0
- package/dist/powerlines/src/types/api.d.mts +104 -0
- package/dist/powerlines/src/types/babel.d.mts +4 -0
- package/dist/powerlines/src/types/build.cjs +15 -0
- package/dist/powerlines/src/types/build.d.cts +154 -0
- package/dist/powerlines/src/types/build.d.mts +154 -0
- package/dist/powerlines/src/types/build.mjs +14 -0
- package/dist/powerlines/src/types/commands.cjs +16 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/commands.mjs +15 -0
- package/dist/powerlines/src/types/config.d.cts +423 -0
- package/dist/powerlines/src/types/config.d.mts +424 -0
- package/dist/powerlines/src/types/context.d.cts +514 -0
- package/dist/powerlines/src/types/context.d.mts +514 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.cts +30 -0
- package/dist/powerlines/src/types/hooks.d.mts +30 -0
- package/dist/powerlines/src/types/internal.d.cts +58 -0
- package/dist/powerlines/src/types/internal.d.mts +58 -0
- package/dist/powerlines/src/types/plugin.cjs +32 -0
- package/dist/powerlines/src/types/plugin.d.cts +234 -0
- package/dist/powerlines/src/types/plugin.d.mts +234 -0
- package/dist/powerlines/src/types/plugin.mjs +31 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +83 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/internal.d.cts +3 -191
- package/dist/types/internal.d.mts +3 -191
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +12 -1
- package/dist/types/plugin.d.mts +12 -1
- package/dist/types/plugin.mjs +0 -2
- package/package.json +5 -5
- package/dist/helpers-CmEjzAn_.mjs +0 -1
- package/dist/helpers-LF26RHol.cjs +0 -0
- package/dist/index-BR1oNnaF.d.cts +0 -1
- package/dist/index-DEHBdV_z.d.mts +0 -1
- package/dist/index-_wQ5ClJU.d.cts +0 -1
- package/dist/index-vkGVyY9v.d.mts +0 -1
- package/dist/plugin-Dc12T6ZF.d.mts +0 -1960
- package/dist/plugin-jZ9N9Mz-.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/plugin-vkCGh5de.d.cts +0 -1957
- package/dist/types-BtDR9wb1.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-B3TcDD6I.mjs +0 -4617
- package/dist/unplugin-Bv2agFkI.cjs +0 -4661
- package/dist/unplugin-D_zrAqRh.d.mts +0 -7
- package/dist/unplugin-F1UAxbOS.d.cts +0 -7
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
require('../helpers-LF26RHol.cjs');
|
|
1
|
+
const require_helpers_unplugin = require('./unplugin.cjs');
|
|
3
2
|
|
|
4
|
-
exports.createVitePlugin =
|
|
3
|
+
exports.createVitePlugin = require_helpers_unplugin.createVitePlugin;
|
package/dist/helpers/index.d.cts
CHANGED
package/dist/helpers/index.d.mts
CHANGED
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_plugin = require('../powerlines/src/lib/unplugin/plugin.cjs');
|
|
3
|
+
require('../powerlines/src/lib/unplugin/index.cjs');
|
|
4
|
+
let unplugin = require("unplugin");
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
//#region src/helpers/unplugin.ts
|
|
7
|
+
function createVitePlugin(context) {
|
|
8
|
+
return (0, unplugin.createVitePlugin)(require_plugin.createUnplugin(context))({});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.createVitePlugin = createVitePlugin;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { VitePluginContext } from "../types/plugin.cjs";
|
|
2
|
+
import * as vite0 from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createVitePlugin(context: VitePluginContext): vite0.Plugin<any> | vite0.Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createVitePlugin };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import "../plugin
|
|
2
|
-
import
|
|
1
|
+
import { VitePluginContext } from "../types/plugin.mjs";
|
|
2
|
+
import * as vite0 from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/unplugin.d.ts
|
|
5
|
+
declare function createVitePlugin(context: VitePluginContext): vite0.Plugin<any> | vite0.Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
3
7
|
export { createVitePlugin };
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createUnplugin } from "../powerlines/src/lib/unplugin/plugin.mjs";
|
|
2
|
+
import "../powerlines/src/lib/unplugin/index.mjs";
|
|
3
|
+
import { createVitePlugin as createVitePlugin$1 } from "unplugin";
|
|
2
4
|
|
|
5
|
+
//#region src/helpers/unplugin.ts
|
|
6
|
+
function createVitePlugin(context) {
|
|
7
|
+
return createVitePlugin$1(createUnplugin(context))({});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
3
11
|
export { createVitePlugin };
|
package/dist/index.cjs
CHANGED
|
@@ -1,174 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
require('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_vite = require('./powerlines/src/lib/build/vite.cjs');
|
|
4
|
+
const require_helpers_unplugin = require('./helpers/unplugin.cjs');
|
|
5
|
+
require('./helpers/index.cjs');
|
|
6
6
|
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
7
7
|
let defu = require("defu");
|
|
8
|
-
defu =
|
|
9
|
-
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
10
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
11
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
12
|
-
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
13
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
14
9
|
let vite = require("vite");
|
|
15
10
|
|
|
16
|
-
//#region ../powerlines/src/lib/build/esbuild.ts
|
|
17
|
-
const DEFAULT_ESBUILD_CONFIG = {
|
|
18
|
-
target: "esnext",
|
|
19
|
-
platform: "neutral",
|
|
20
|
-
format: "esm",
|
|
21
|
-
write: true,
|
|
22
|
-
minify: true,
|
|
23
|
-
sourcemap: false,
|
|
24
|
-
bundle: true,
|
|
25
|
-
treeShaking: true,
|
|
26
|
-
keepNames: true,
|
|
27
|
-
splitting: true,
|
|
28
|
-
logLevel: "silent"
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Resolves the esbuild options.
|
|
32
|
-
*
|
|
33
|
-
* @param context - The build context.
|
|
34
|
-
* @returns The resolved esbuild options.
|
|
35
|
-
*/
|
|
36
|
-
function extractESBuildConfig(context) {
|
|
37
|
-
const inject = context.config.build.override.inject ?? context.config.build.inject;
|
|
38
|
-
if (inject && Object.keys(inject).length > 0) context.fs.writeSync((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
|
|
39
|
-
if (value) if (Array.isArray(value)) {
|
|
40
|
-
if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) {
|
|
41
|
-
if (value.length === 1) return `
|
|
42
|
-
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
43
|
-
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
44
|
-
else if (value.length > 1) return `
|
|
45
|
-
import ${value[1] === "*" ? `* as ${(0, __stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, __stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
|
|
46
|
-
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
47
|
-
} else if (value.length === 1) return `
|
|
48
|
-
import ${key} from "${value[0]}";
|
|
49
|
-
export { ${key} };`;
|
|
50
|
-
else if (value.length > 1) return `
|
|
51
|
-
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
52
|
-
export { ${key} };`;
|
|
53
|
-
} else if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) return `
|
|
54
|
-
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
55
|
-
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
56
|
-
else return `
|
|
57
|
-
import ${key} from "${value}";
|
|
58
|
-
export { ${key} };`;
|
|
59
|
-
return "";
|
|
60
|
-
}).join("\n"));
|
|
61
|
-
return (0, defu.default)({
|
|
62
|
-
alias: context.builtins.reduce((ret, id) => {
|
|
63
|
-
if (!ret[id]) {
|
|
64
|
-
const path = context.fs.ids[id];
|
|
65
|
-
if (path) ret[id] = path;
|
|
66
|
-
}
|
|
67
|
-
return ret;
|
|
68
|
-
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
69
|
-
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
70
|
-
return ret;
|
|
71
|
-
}, {}) : context.config.build.alias : {}),
|
|
72
|
-
inject: inject && Object.keys(inject).length > 0 ? [(0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
|
|
73
|
-
}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build.override, [
|
|
74
|
-
"alias",
|
|
75
|
-
"inject",
|
|
76
|
-
"external",
|
|
77
|
-
"noExternal",
|
|
78
|
-
"skipNodeModulesBundle",
|
|
79
|
-
"extensions"
|
|
80
|
-
]) : {}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, [
|
|
81
|
-
"alias",
|
|
82
|
-
"inject",
|
|
83
|
-
"external",
|
|
84
|
-
"noExternal",
|
|
85
|
-
"skipNodeModulesBundle",
|
|
86
|
-
"extensions",
|
|
87
|
-
"variant",
|
|
88
|
-
"override"
|
|
89
|
-
]) : {}, {
|
|
90
|
-
mainFields: context.config.build.mainFields,
|
|
91
|
-
conditions: context.config.build.conditions,
|
|
92
|
-
define: context.config.build.define,
|
|
93
|
-
resolveExtensions: context.config.build.extensions,
|
|
94
|
-
packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
|
|
95
|
-
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
96
|
-
platform: context.config.build.platform,
|
|
97
|
-
treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
|
|
98
|
-
outdir: context.config.output.buildPath,
|
|
99
|
-
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
100
|
-
minify: context.config.mode !== "development",
|
|
101
|
-
metafile: context.config.mode === "development",
|
|
102
|
-
sourcemap: context.config.mode === "development"
|
|
103
|
-
}, DEFAULT_ESBUILD_CONFIG);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region ../powerlines/src/lib/build/vite.ts
|
|
108
|
-
const DEFAULT_VITE_CONFIG = {
|
|
109
|
-
resolve: { extensions: [
|
|
110
|
-
".mjs",
|
|
111
|
-
".js",
|
|
112
|
-
".mts",
|
|
113
|
-
".ts",
|
|
114
|
-
".jsx",
|
|
115
|
-
".tsx",
|
|
116
|
-
".json"
|
|
117
|
-
] },
|
|
118
|
-
json: { stringify: true },
|
|
119
|
-
logLevel: "silent",
|
|
120
|
-
clearScreen: true
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Resolves the options for [vite](https://vitejs.dev/).
|
|
124
|
-
*
|
|
125
|
-
* @param context - The build context.
|
|
126
|
-
* @returns The resolved options.
|
|
127
|
-
*/
|
|
128
|
-
function extractViteConfig(context) {
|
|
129
|
-
return (0, defu.default)({ resolve: {
|
|
130
|
-
alias: context.builtins.reduce((ret, id) => {
|
|
131
|
-
if (!ret.find((e) => e.find === id)) {
|
|
132
|
-
const path = context.fs.ids[id];
|
|
133
|
-
if (path) ret.push({
|
|
134
|
-
find: id,
|
|
135
|
-
replacement: path
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return ret;
|
|
139
|
-
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
140
|
-
if (!ret.find((e) => e.find === id)) ret.push({
|
|
141
|
-
find: id,
|
|
142
|
-
replacement: path
|
|
143
|
-
});
|
|
144
|
-
return ret;
|
|
145
|
-
}, []) : []),
|
|
146
|
-
dedupe: context.config.build.dedupe,
|
|
147
|
-
mainFields: context.config.build.mainFields,
|
|
148
|
-
conditions: context.config.build.conditions,
|
|
149
|
-
extensions: context.config.build.extensions
|
|
150
|
-
} }, context.config.build.variant === "vite" ? (0, defu.default)(context.config.build.override ?? {}, { optimizeDeps: context.config.build.override?.optimizeDeps ?? {} }, { optimizeDeps: { extensions: context.config.build.override?.extensions } }) : {}, context.config.build.variant === "vite" ? (0, defu.default)((0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]), { optimizeDeps: context.config.build?.optimizeDeps ?? {} }, { optimizeDeps: { extensions: context.config.build.extensions } }) : {}, {
|
|
151
|
-
keepProcessEnv: context.config.build.keepProcessEnv,
|
|
152
|
-
define: context.config.build.define,
|
|
153
|
-
rootDir: context.config.sourceRoot,
|
|
154
|
-
platform: context.config.build.platform,
|
|
155
|
-
mode: context.config.mode === "development" ? "development" : "production",
|
|
156
|
-
cacheDir: (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "vite"),
|
|
157
|
-
build: {
|
|
158
|
-
minify: context.config.mode !== "development",
|
|
159
|
-
metafile: context.config.mode === "development",
|
|
160
|
-
sourcemap: context.config.mode === "development",
|
|
161
|
-
outDir: context.config.output.buildPath,
|
|
162
|
-
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
163
|
-
tsconfigRaw: context.tsconfig.tsconfigJson
|
|
164
|
-
},
|
|
165
|
-
esbuild: extractESBuildConfig(context),
|
|
166
|
-
logLevel: context.config.logLevel ?? void 0,
|
|
167
|
-
envDir: context.config.projectRoot
|
|
168
|
-
}, DEFAULT_VITE_CONFIG);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
11
|
//#region src/index.ts
|
|
173
12
|
/**
|
|
174
13
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
@@ -181,7 +20,7 @@ const plugin = (options = {}) => {
|
|
|
181
20
|
return {
|
|
182
21
|
output: { format: ["cjs", "esm"] },
|
|
183
22
|
build: {
|
|
184
|
-
...DEFAULT_VITE_CONFIG,
|
|
23
|
+
...require_vite.DEFAULT_VITE_CONFIG,
|
|
185
24
|
...options,
|
|
186
25
|
variant: "vite"
|
|
187
26
|
},
|
|
@@ -196,14 +35,14 @@ const plugin = (options = {}) => {
|
|
|
196
35
|
await (0, vite.build)((0, defu.default)({
|
|
197
36
|
config: false,
|
|
198
37
|
entry: this.entry,
|
|
199
|
-
environments: Object.fromEntries(Object.entries(environments).map(([name, env]) => [name, extractViteConfig(env)]))
|
|
200
|
-
}, extractViteConfig(this), { plugins: [
|
|
38
|
+
environments: Object.fromEntries(Object.entries(environments).map(([name, env]) => [name, require_vite.extractViteConfig(env)]))
|
|
39
|
+
}, require_vite.extractViteConfig(this), { plugins: [require_helpers_unplugin.createVitePlugin(this)] }));
|
|
201
40
|
}
|
|
202
41
|
};
|
|
203
42
|
};
|
|
204
43
|
var src_default = plugin;
|
|
205
44
|
|
|
206
45
|
//#endregion
|
|
207
|
-
exports.createVitePlugin =
|
|
46
|
+
exports.createVitePlugin = require_helpers_unplugin.createVitePlugin;
|
|
208
47
|
exports.default = src_default;
|
|
209
48
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./index-BR1oNnaF.cjs";
|
|
1
|
+
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
2
|
+
import { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig } from "./types/plugin.cjs";
|
|
3
|
+
import { createVitePlugin } from "./helpers/unplugin.cjs";
|
|
5
4
|
|
|
6
5
|
//#region src/index.d.ts
|
|
7
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./index
|
|
1
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
2
|
+
import { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig } from "./types/plugin.mjs";
|
|
3
|
+
import { createVitePlugin } from "./helpers/unplugin.mjs";
|
|
4
|
+
import "./helpers/index.mjs";
|
|
5
|
+
import "./types/index.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/index.d.ts
|
|
7
|
-
|
|
8
8
|
/**
|
|
9
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
10
10
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,172 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./helpers
|
|
3
|
-
import "./
|
|
4
|
-
import "./types-BtDR9wb1.mjs";
|
|
1
|
+
import { DEFAULT_VITE_CONFIG, extractViteConfig } from "./powerlines/src/lib/build/vite.mjs";
|
|
2
|
+
import { createVitePlugin } from "./helpers/unplugin.mjs";
|
|
3
|
+
import "./helpers/index.mjs";
|
|
5
4
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
6
5
|
import defu$1 from "defu";
|
|
7
|
-
import { omit } from "@stryke/helpers/omit";
|
|
8
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
-
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
10
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
11
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
12
6
|
import { build } from "vite";
|
|
13
7
|
|
|
14
|
-
//#region ../powerlines/src/lib/build/esbuild.ts
|
|
15
|
-
const DEFAULT_ESBUILD_CONFIG = {
|
|
16
|
-
target: "esnext",
|
|
17
|
-
platform: "neutral",
|
|
18
|
-
format: "esm",
|
|
19
|
-
write: true,
|
|
20
|
-
minify: true,
|
|
21
|
-
sourcemap: false,
|
|
22
|
-
bundle: true,
|
|
23
|
-
treeShaking: true,
|
|
24
|
-
keepNames: true,
|
|
25
|
-
splitting: true,
|
|
26
|
-
logLevel: "silent"
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Resolves the esbuild options.
|
|
30
|
-
*
|
|
31
|
-
* @param context - The build context.
|
|
32
|
-
* @returns The resolved esbuild options.
|
|
33
|
-
*/
|
|
34
|
-
function extractESBuildConfig(context) {
|
|
35
|
-
const inject = context.config.build.override.inject ?? context.config.build.inject;
|
|
36
|
-
if (inject && Object.keys(inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
|
|
37
|
-
if (value) if (Array.isArray(value)) {
|
|
38
|
-
if (camelCase(key) !== key) {
|
|
39
|
-
if (value.length === 1) return `
|
|
40
|
-
import ${camelCase(key)} from "${value[0]}";
|
|
41
|
-
export { ${camelCase(key)} as "${key}" }`;
|
|
42
|
-
else if (value.length > 1) return `
|
|
43
|
-
import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
|
|
44
|
-
export { ${camelCase(key)} as "${key}" }`;
|
|
45
|
-
} else if (value.length === 1) return `
|
|
46
|
-
import ${key} from "${value[0]}";
|
|
47
|
-
export { ${key} };`;
|
|
48
|
-
else if (value.length > 1) return `
|
|
49
|
-
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
50
|
-
export { ${key} };`;
|
|
51
|
-
} else if (camelCase(key) !== key) return `
|
|
52
|
-
import ${camelCase(key)} from "${value[0]}";
|
|
53
|
-
export { ${camelCase(key)} as "${key}" }`;
|
|
54
|
-
else return `
|
|
55
|
-
import ${key} from "${value}";
|
|
56
|
-
export { ${key} };`;
|
|
57
|
-
return "";
|
|
58
|
-
}).join("\n"));
|
|
59
|
-
return defu$1({
|
|
60
|
-
alias: context.builtins.reduce((ret, id) => {
|
|
61
|
-
if (!ret[id]) {
|
|
62
|
-
const path = context.fs.ids[id];
|
|
63
|
-
if (path) ret[id] = path;
|
|
64
|
-
}
|
|
65
|
-
return ret;
|
|
66
|
-
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
67
|
-
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
68
|
-
return ret;
|
|
69
|
-
}, {}) : context.config.build.alias : {}),
|
|
70
|
-
inject: inject && Object.keys(inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
|
|
71
|
-
}, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
|
|
72
|
-
"alias",
|
|
73
|
-
"inject",
|
|
74
|
-
"external",
|
|
75
|
-
"noExternal",
|
|
76
|
-
"skipNodeModulesBundle",
|
|
77
|
-
"extensions"
|
|
78
|
-
]) : {}, context.config.build.variant === "esbuild" ? omit(context.config.build, [
|
|
79
|
-
"alias",
|
|
80
|
-
"inject",
|
|
81
|
-
"external",
|
|
82
|
-
"noExternal",
|
|
83
|
-
"skipNodeModulesBundle",
|
|
84
|
-
"extensions",
|
|
85
|
-
"variant",
|
|
86
|
-
"override"
|
|
87
|
-
]) : {}, {
|
|
88
|
-
mainFields: context.config.build.mainFields,
|
|
89
|
-
conditions: context.config.build.conditions,
|
|
90
|
-
define: context.config.build.define,
|
|
91
|
-
resolveExtensions: context.config.build.extensions,
|
|
92
|
-
packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
|
|
93
|
-
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
94
|
-
platform: context.config.build.platform,
|
|
95
|
-
treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
|
|
96
|
-
outdir: context.config.output.buildPath,
|
|
97
|
-
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
98
|
-
minify: context.config.mode !== "development",
|
|
99
|
-
metafile: context.config.mode === "development",
|
|
100
|
-
sourcemap: context.config.mode === "development"
|
|
101
|
-
}, DEFAULT_ESBUILD_CONFIG);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region ../powerlines/src/lib/build/vite.ts
|
|
106
|
-
const DEFAULT_VITE_CONFIG = {
|
|
107
|
-
resolve: { extensions: [
|
|
108
|
-
".mjs",
|
|
109
|
-
".js",
|
|
110
|
-
".mts",
|
|
111
|
-
".ts",
|
|
112
|
-
".jsx",
|
|
113
|
-
".tsx",
|
|
114
|
-
".json"
|
|
115
|
-
] },
|
|
116
|
-
json: { stringify: true },
|
|
117
|
-
logLevel: "silent",
|
|
118
|
-
clearScreen: true
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Resolves the options for [vite](https://vitejs.dev/).
|
|
122
|
-
*
|
|
123
|
-
* @param context - The build context.
|
|
124
|
-
* @returns The resolved options.
|
|
125
|
-
*/
|
|
126
|
-
function extractViteConfig(context) {
|
|
127
|
-
return defu$1({ resolve: {
|
|
128
|
-
alias: context.builtins.reduce((ret, id) => {
|
|
129
|
-
if (!ret.find((e) => e.find === id)) {
|
|
130
|
-
const path = context.fs.ids[id];
|
|
131
|
-
if (path) ret.push({
|
|
132
|
-
find: id,
|
|
133
|
-
replacement: path
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return ret;
|
|
137
|
-
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
138
|
-
if (!ret.find((e) => e.find === id)) ret.push({
|
|
139
|
-
find: id,
|
|
140
|
-
replacement: path
|
|
141
|
-
});
|
|
142
|
-
return ret;
|
|
143
|
-
}, []) : []),
|
|
144
|
-
dedupe: context.config.build.dedupe,
|
|
145
|
-
mainFields: context.config.build.mainFields,
|
|
146
|
-
conditions: context.config.build.conditions,
|
|
147
|
-
extensions: context.config.build.extensions
|
|
148
|
-
} }, context.config.build.variant === "vite" ? defu$1(context.config.build.override ?? {}, { optimizeDeps: context.config.build.override?.optimizeDeps ?? {} }, { optimizeDeps: { extensions: context.config.build.override?.extensions } }) : {}, context.config.build.variant === "vite" ? defu$1(omit(context.config.build, ["override", "variant"]), { optimizeDeps: context.config.build?.optimizeDeps ?? {} }, { optimizeDeps: { extensions: context.config.build.extensions } }) : {}, {
|
|
149
|
-
keepProcessEnv: context.config.build.keepProcessEnv,
|
|
150
|
-
define: context.config.build.define,
|
|
151
|
-
rootDir: context.config.sourceRoot,
|
|
152
|
-
platform: context.config.build.platform,
|
|
153
|
-
mode: context.config.mode === "development" ? "development" : "production",
|
|
154
|
-
cacheDir: joinPaths(context.cachePath, "vite"),
|
|
155
|
-
build: {
|
|
156
|
-
minify: context.config.mode !== "development",
|
|
157
|
-
metafile: context.config.mode === "development",
|
|
158
|
-
sourcemap: context.config.mode === "development",
|
|
159
|
-
outDir: context.config.output.buildPath,
|
|
160
|
-
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
161
|
-
tsconfigRaw: context.tsconfig.tsconfigJson
|
|
162
|
-
},
|
|
163
|
-
esbuild: extractESBuildConfig(context),
|
|
164
|
-
logLevel: context.config.logLevel ?? void 0,
|
|
165
|
-
envDir: context.config.projectRoot
|
|
166
|
-
}, DEFAULT_VITE_CONFIG);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
8
|
//#region src/index.ts
|
|
171
9
|
/**
|
|
172
10
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|