@uni_toolkit/vite-plugin-component-config 0.0.21-alpha.1776521649215 → 0.0.21
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 +106 -8
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +100 -2
- package/package.json +3 -4
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProp$1 = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
9
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
10
|
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
|
|
12
12
|
get: ((k) => from[k]).bind(null, key),
|
|
13
13
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
@@ -25,9 +25,107 @@ node_fs = __toESM(node_fs, 1);
|
|
|
25
25
|
let node_path = require("node:path");
|
|
26
26
|
node_path = __toESM(node_path, 1);
|
|
27
27
|
let _dcloudio_uni_cli_shared = require("@dcloudio/uni-cli-shared");
|
|
28
|
-
let _rollup_pluginutils = require("@rollup/pluginutils");
|
|
29
28
|
let _uni_toolkit_shared = require("@uni_toolkit/shared");
|
|
30
|
-
let
|
|
29
|
+
let vite = require("vite");
|
|
30
|
+
//#region ../../node_modules/.pnpm/rattail@1.0.8/node_modules/rattail/lib/index.js
|
|
31
|
+
var __defProp = Object.defineProperty;
|
|
32
|
+
var __defProps = Object.defineProperties;
|
|
33
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
34
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
35
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
36
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37
|
+
var __defNormalProp = (obj, key3, value) => key3 in obj ? __defProp(obj, key3, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value
|
|
42
|
+
}) : obj[key3] = value;
|
|
43
|
+
var __spreadValues = (a, b) => {
|
|
44
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
45
|
+
if (__getOwnPropSymbols) {
|
|
46
|
+
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
47
|
+
}
|
|
48
|
+
return a;
|
|
49
|
+
};
|
|
50
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
51
|
+
function at(arr, index) {
|
|
52
|
+
if (!arr.length) return;
|
|
53
|
+
if (index < 0) index += arr.length;
|
|
54
|
+
return arr[index];
|
|
55
|
+
}
|
|
56
|
+
function inBrowser() {
|
|
57
|
+
return typeof window !== "undefined";
|
|
58
|
+
}
|
|
59
|
+
function getGlobalThis() {
|
|
60
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
61
|
+
if (inBrowser()) return window;
|
|
62
|
+
return typeof global !== "undefined" ? global : self;
|
|
63
|
+
}
|
|
64
|
+
var { hasOwnProperty } = Object.prototype;
|
|
65
|
+
function hasOwn(val, key3) {
|
|
66
|
+
return hasOwnProperty.call(val, key3);
|
|
67
|
+
}
|
|
68
|
+
function isArray(val) {
|
|
69
|
+
return Array.isArray(val);
|
|
70
|
+
}
|
|
71
|
+
function isObject(val) {
|
|
72
|
+
return typeof val === "object" && val !== null;
|
|
73
|
+
}
|
|
74
|
+
function isString(val) {
|
|
75
|
+
return typeof val === "string";
|
|
76
|
+
}
|
|
77
|
+
function createStorage(storage) {
|
|
78
|
+
return __spreadProps(__spreadValues({}, storage), {
|
|
79
|
+
set(key3, value) {
|
|
80
|
+
if (value == null) return;
|
|
81
|
+
if (!isString(value)) value = JSON.stringify(value);
|
|
82
|
+
storage.setItem(key3, value);
|
|
83
|
+
},
|
|
84
|
+
get(key3) {
|
|
85
|
+
const data = storage.getItem(key3);
|
|
86
|
+
try {
|
|
87
|
+
return JSON.parse(data);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
remove(key3) {
|
|
93
|
+
storage.removeItem(key3);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
createStorage(getGlobalThis().sessionStorage);
|
|
98
|
+
createStorage(getGlobalThis().localStorage);
|
|
99
|
+
function mergeWith(object, ...sources) {
|
|
100
|
+
const fn = at(sources, -1);
|
|
101
|
+
const targets = [object, ...sources.slice(0, -1)];
|
|
102
|
+
let len = targets.length - 1;
|
|
103
|
+
let result = targets[len];
|
|
104
|
+
while (len) {
|
|
105
|
+
result = baseMergeWith(targets[len - 1], result, fn);
|
|
106
|
+
len--;
|
|
107
|
+
}
|
|
108
|
+
function baseMergeWith(object2, source, fn2) {
|
|
109
|
+
function baseMerge(target, src) {
|
|
110
|
+
for (const key3 in src) if (hasOwn(src, key3)) {
|
|
111
|
+
const srcValue = src[key3];
|
|
112
|
+
const targetValue = target[key3];
|
|
113
|
+
const customResult = fn2(targetValue, srcValue, key3, object2, source);
|
|
114
|
+
if (customResult !== void 0) target[key3] = customResult;
|
|
115
|
+
else if (isObject(srcValue)) if (isObject(targetValue)) target[key3] = baseMerge(targetValue, srcValue);
|
|
116
|
+
else target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
117
|
+
else target[key3] = srcValue;
|
|
118
|
+
}
|
|
119
|
+
return target;
|
|
120
|
+
}
|
|
121
|
+
return baseMerge(object2, source);
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
function merge(object, ...sources) {
|
|
126
|
+
return mergeWith(object, ...sources, () => void 0);
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
31
129
|
//#region src/index.ts
|
|
32
130
|
function vitePluginComponentConfig(options = {
|
|
33
131
|
include: ["**/*.{vue,nvue,uvue}"],
|
|
@@ -39,7 +137,7 @@ function vitePluginComponentConfig(options = {
|
|
|
39
137
|
enforce: "pre",
|
|
40
138
|
transform(code, id) {
|
|
41
139
|
if (!(0, _uni_toolkit_shared.isMiniProgram)()) return;
|
|
42
|
-
if (!(0,
|
|
140
|
+
if (!(0, vite.createFilter)(options.include, options.exclude)(id)) return;
|
|
43
141
|
const matches = code.match(/<component-config>([\s\S]*?)<\/component-config>/g);
|
|
44
142
|
if (!matches) return;
|
|
45
143
|
matches.forEach((match) => {
|
|
@@ -54,7 +152,7 @@ function vitePluginComponentConfig(options = {
|
|
|
54
152
|
if (!node_fs.default.existsSync(outputPath)) continue;
|
|
55
153
|
const content = node_fs.default.readFileSync(outputPath, "utf-8");
|
|
56
154
|
const json = JSON.parse(content);
|
|
57
|
-
node_fs.default.writeFileSync(outputPath, JSON.stringify(
|
|
155
|
+
node_fs.default.writeFileSync(outputPath, JSON.stringify(merge(json, config), null, 2));
|
|
58
156
|
}
|
|
59
157
|
}
|
|
60
158
|
};
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,107 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parseJson } from "@dcloudio/uni-cli-shared";
|
|
4
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
5
4
|
import { getOutputJsonPath, isMiniProgram } from "@uni_toolkit/shared";
|
|
6
|
-
import {
|
|
5
|
+
import { createFilter } from "vite";
|
|
6
|
+
//#region ../../node_modules/.pnpm/rattail@1.0.8/node_modules/rattail/lib/index.js
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key3, value) => key3 in obj ? __defProp(obj, key3, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value
|
|
18
|
+
}) : obj[key3] = value;
|
|
19
|
+
var __spreadValues = (a, b) => {
|
|
20
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
21
|
+
if (__getOwnPropSymbols) {
|
|
22
|
+
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
function at(arr, index) {
|
|
28
|
+
if (!arr.length) return;
|
|
29
|
+
if (index < 0) index += arr.length;
|
|
30
|
+
return arr[index];
|
|
31
|
+
}
|
|
32
|
+
function inBrowser() {
|
|
33
|
+
return typeof window !== "undefined";
|
|
34
|
+
}
|
|
35
|
+
function getGlobalThis() {
|
|
36
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
37
|
+
if (inBrowser()) return window;
|
|
38
|
+
return typeof global !== "undefined" ? global : self;
|
|
39
|
+
}
|
|
40
|
+
var { hasOwnProperty } = Object.prototype;
|
|
41
|
+
function hasOwn(val, key3) {
|
|
42
|
+
return hasOwnProperty.call(val, key3);
|
|
43
|
+
}
|
|
44
|
+
function isArray(val) {
|
|
45
|
+
return Array.isArray(val);
|
|
46
|
+
}
|
|
47
|
+
function isObject(val) {
|
|
48
|
+
return typeof val === "object" && val !== null;
|
|
49
|
+
}
|
|
50
|
+
function isString(val) {
|
|
51
|
+
return typeof val === "string";
|
|
52
|
+
}
|
|
53
|
+
function createStorage(storage) {
|
|
54
|
+
return __spreadProps(__spreadValues({}, storage), {
|
|
55
|
+
set(key3, value) {
|
|
56
|
+
if (value == null) return;
|
|
57
|
+
if (!isString(value)) value = JSON.stringify(value);
|
|
58
|
+
storage.setItem(key3, value);
|
|
59
|
+
},
|
|
60
|
+
get(key3) {
|
|
61
|
+
const data = storage.getItem(key3);
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(data);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
remove(key3) {
|
|
69
|
+
storage.removeItem(key3);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createStorage(getGlobalThis().sessionStorage);
|
|
74
|
+
createStorage(getGlobalThis().localStorage);
|
|
75
|
+
function mergeWith(object, ...sources) {
|
|
76
|
+
const fn = at(sources, -1);
|
|
77
|
+
const targets = [object, ...sources.slice(0, -1)];
|
|
78
|
+
let len = targets.length - 1;
|
|
79
|
+
let result = targets[len];
|
|
80
|
+
while (len) {
|
|
81
|
+
result = baseMergeWith(targets[len - 1], result, fn);
|
|
82
|
+
len--;
|
|
83
|
+
}
|
|
84
|
+
function baseMergeWith(object2, source, fn2) {
|
|
85
|
+
function baseMerge(target, src) {
|
|
86
|
+
for (const key3 in src) if (hasOwn(src, key3)) {
|
|
87
|
+
const srcValue = src[key3];
|
|
88
|
+
const targetValue = target[key3];
|
|
89
|
+
const customResult = fn2(targetValue, srcValue, key3, object2, source);
|
|
90
|
+
if (customResult !== void 0) target[key3] = customResult;
|
|
91
|
+
else if (isObject(srcValue)) if (isObject(targetValue)) target[key3] = baseMerge(targetValue, srcValue);
|
|
92
|
+
else target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
93
|
+
else target[key3] = srcValue;
|
|
94
|
+
}
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
97
|
+
return baseMerge(object2, source);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function merge(object, ...sources) {
|
|
102
|
+
return mergeWith(object, ...sources, () => void 0);
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
7
105
|
//#region src/index.ts
|
|
8
106
|
function vitePluginComponentConfig(options = {
|
|
9
107
|
include: ["**/*.{vue,nvue,uvue}"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni_toolkit/vite-plugin-component-config",
|
|
3
|
-
"version": "0.0.21
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "chouchouji <1305974212@qq.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -38,9 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4080120250820001",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"@uni_toolkit/shared": "0.0.21-alpha.1776521649215"
|
|
41
|
+
"rattail": "1.0.8",
|
|
42
|
+
"@uni_toolkit/shared": "0.0.21"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"typescript": "5.3.3",
|