@pubinfo-pr/vite 0.222.5 → 0.222.7
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.mjs +11 -116
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -13,8 +13,6 @@ import { createParsedCommandLine, createVueLanguagePlugin, getDefaultCompilerOpt
|
|
|
13
13
|
import ts from "typescript";
|
|
14
14
|
import boxen from "boxen";
|
|
15
15
|
import MagicString from "magic-string";
|
|
16
|
-
import { Buffer } from "node:buffer";
|
|
17
|
-
import { createHash } from "node:crypto";
|
|
18
16
|
import fg from "fast-glob";
|
|
19
17
|
import { merge } from "lodash-es";
|
|
20
18
|
import picomatch from "picomatch";
|
|
@@ -24,6 +22,7 @@ import dayjs from "dayjs";
|
|
|
24
22
|
import { readPackageJSON } from "pkg-types";
|
|
25
23
|
import { readFile } from "node:fs/promises";
|
|
26
24
|
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { Buffer } from "node:buffer";
|
|
27
26
|
import fse from "fs-extra/esm";
|
|
28
27
|
import JSZip from "jszip";
|
|
29
28
|
import autoImport from "unplugin-auto-import/vite";
|
|
@@ -308,59 +307,6 @@ function createInjectAuto(options) {
|
|
|
308
307
|
};
|
|
309
308
|
}
|
|
310
309
|
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/plugins/built-in/json-url-asset.ts
|
|
313
|
-
const BASE64_DATA_URL_RE = /["']data:application\/json;base64,([A-Za-z0-9+/=]+)["']/g;
|
|
314
|
-
/**
|
|
315
|
-
* 修复 Vite 8 + Rolldown 中 JSON 文件通过 `?url` 导入时
|
|
316
|
-
* 被内联为 base64 data URL 的问题。
|
|
317
|
-
*
|
|
318
|
-
* 问题原因:
|
|
319
|
-
* 1. 模块(如 rbac)作为 library 预构建时,`?url` 导入的 JSON 文件
|
|
320
|
-
* 被 Rolldown 直接转为 base64 data URL 内联到产物中,忽略 `assetsInlineLimit`。
|
|
321
|
-
* 2. 当主应用(playground)打包时消费这些预构建产物,base64 数据被原封不动保留。
|
|
322
|
-
*
|
|
323
|
-
* 解决方案:在 `transform` 钩子中检测已内联的 `data:application/json;base64,...`
|
|
324
|
-
* 字符串,将其解码并通过 `this.emitFile` 作为独立资源文件输出,
|
|
325
|
-
* 用 `import.meta.ROLLUP_FILE_URL_` 引用替换原始 data URL。
|
|
326
|
-
*/
|
|
327
|
-
function createJsonUrlAsset() {
|
|
328
|
-
let isBuild = false;
|
|
329
|
-
const emitted = /* @__PURE__ */ new Map();
|
|
330
|
-
return {
|
|
331
|
-
name: "pubinfo:json-url-asset",
|
|
332
|
-
enforce: "pre",
|
|
333
|
-
config(_config, env) {
|
|
334
|
-
isBuild = env.command === "build";
|
|
335
|
-
},
|
|
336
|
-
transform(code, _id) {
|
|
337
|
-
if (!isBuild) return null;
|
|
338
|
-
if (!code.includes("data:application/json;base64,")) return null;
|
|
339
|
-
let hasReplacement = false;
|
|
340
|
-
const result = code.replace(BASE64_DATA_URL_RE, (_match, base64Data) => {
|
|
341
|
-
const hash = createHash("sha256").update(base64Data).digest("hex").slice(0, 8);
|
|
342
|
-
let refId = emitted.get(hash);
|
|
343
|
-
if (!refId) {
|
|
344
|
-
const buffer = Buffer.from(base64Data, "base64");
|
|
345
|
-
refId = this.emitFile({
|
|
346
|
-
type: "asset",
|
|
347
|
-
name: `lottie-${hash}.json`,
|
|
348
|
-
source: buffer
|
|
349
|
-
});
|
|
350
|
-
emitted.set(hash, refId);
|
|
351
|
-
}
|
|
352
|
-
hasReplacement = true;
|
|
353
|
-
return `import.meta.ROLLUP_FILE_URL_${refId}`;
|
|
354
|
-
});
|
|
355
|
-
if (hasReplacement) return {
|
|
356
|
-
code: result,
|
|
357
|
-
map: null
|
|
358
|
-
};
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
|
|
364
310
|
//#endregion
|
|
365
311
|
//#region src/plugins/built-in/lib-resolver.ts
|
|
366
312
|
function getPatternBase(pattern) {
|
|
@@ -689,7 +635,7 @@ function createComponents() {
|
|
|
689
635
|
"PubinfoIcon"
|
|
690
636
|
].includes(name)) return {
|
|
691
637
|
name,
|
|
692
|
-
from: "pubinfo"
|
|
638
|
+
from: "pubinfo-pr"
|
|
693
639
|
};
|
|
694
640
|
}
|
|
695
641
|
}
|
|
@@ -780,7 +726,6 @@ function createUnocss() {
|
|
|
780
726
|
//#region src/plugins/index.ts
|
|
781
727
|
function createVitePlugins(viteEnv, isBuild = false, config, type) {
|
|
782
728
|
const vitePlugins = [
|
|
783
|
-
createJsonUrlAsset(),
|
|
784
729
|
vue(),
|
|
785
730
|
vueJsx(),
|
|
786
731
|
createLegacy(viteEnv),
|
|
@@ -827,8 +772,8 @@ function createDefaultAppConfig(config) {
|
|
|
827
772
|
warmup: { clientFiles: ["./index.html"] }
|
|
828
773
|
},
|
|
829
774
|
optimizeDeps: { exclude: [
|
|
830
|
-
"pubinfo",
|
|
831
|
-
"@pubinfo/core",
|
|
775
|
+
"pubinfo-pr",
|
|
776
|
+
"@pubinfo-pr/core",
|
|
832
777
|
"alova"
|
|
833
778
|
] },
|
|
834
779
|
resolve: { alias: alias(root) },
|
|
@@ -839,61 +784,11 @@ function createDefaultAppConfig(config) {
|
|
|
839
784
|
chunkSizeWarningLimit: 2e3,
|
|
840
785
|
rolldownOptions: { output: {
|
|
841
786
|
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`,
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
test: /[\\/]node_modules[\\/].*ant-design-vue/,
|
|
848
|
-
priority: 30
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
name: "antd-icons-vendor",
|
|
852
|
-
test: /[\\/]node_modules[\\/].*@ant-design[\\/]icons-vue/,
|
|
853
|
-
priority: 30
|
|
854
|
-
},
|
|
855
|
-
{
|
|
856
|
-
name: "antd-deps-vendor",
|
|
857
|
-
test: /[\\/]node_modules[\\/].*@ant-design[\\/](?!icons-vue)/,
|
|
858
|
-
priority: 28
|
|
859
|
-
},
|
|
860
|
-
{
|
|
861
|
-
name: "vue-vendor",
|
|
862
|
-
test: /[\\/]node_modules[\\/].*[\\/](vue|vue-router|pinia|@vue)[\\/]/,
|
|
863
|
-
priority: 25
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
name: "vueuse-vendor",
|
|
867
|
-
test: /[\\/]node_modules[\\/].*@vueuse[\\/]/,
|
|
868
|
-
priority: 20
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
name: "lodash-vendor",
|
|
872
|
-
test: /[\\/]node_modules[\\/].*lodash-es[\\/]/,
|
|
873
|
-
priority: 20
|
|
874
|
-
},
|
|
875
|
-
{
|
|
876
|
-
name: "crypto-vendor",
|
|
877
|
-
test: /[\\/]node_modules[\\/].*(jsencrypt|zxcvbn|md5)[\\/]/,
|
|
878
|
-
priority: 20
|
|
879
|
-
},
|
|
880
|
-
{
|
|
881
|
-
name: "lottie-vendor",
|
|
882
|
-
test: /[\\/]node_modules[\\/].*lottie-web[\\/]/,
|
|
883
|
-
priority: 20
|
|
884
|
-
},
|
|
885
|
-
{
|
|
886
|
-
name: "http-vendor",
|
|
887
|
-
test: /[\\/]node_modules[\\/].*(axios|alova|@alova)[\\/]/,
|
|
888
|
-
priority: 20
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
name: "vendor",
|
|
892
|
-
test: /[\\/]node_modules[\\/]/,
|
|
893
|
-
priority: 10
|
|
894
|
-
}
|
|
895
|
-
]
|
|
896
|
-
}
|
|
787
|
+
advancedChunks: { groups: [{
|
|
788
|
+
name: "pubinfo-pr",
|
|
789
|
+
test: "pubinfo-pr",
|
|
790
|
+
priority: 10
|
|
791
|
+
}] }
|
|
897
792
|
} }
|
|
898
793
|
},
|
|
899
794
|
plugins: createVitePlugins(env, isBuild, config, "app")
|
|
@@ -910,8 +805,8 @@ function createDefaultModuleConfig(config) {
|
|
|
910
805
|
const env = loadEnv(mode, root);
|
|
911
806
|
return {
|
|
912
807
|
optimizeDeps: { exclude: [
|
|
913
|
-
"pubinfo",
|
|
914
|
-
"@pubinfo/core",
|
|
808
|
+
"pubinfo-pr",
|
|
809
|
+
"@pubinfo-pr/core",
|
|
915
810
|
"alova"
|
|
916
811
|
] },
|
|
917
812
|
resolve: { alias: alias(root) },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo-pr/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.222.
|
|
4
|
+
"version": "0.222.7",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"vue-tsc": "^3.2.4"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@pubinfo-pr/devtools": "0.222.
|
|
29
|
-
"@pubinfo-pr/shared": "0.222.
|
|
28
|
+
"@pubinfo-pr/devtools": "0.222.7",
|
|
29
|
+
"@pubinfo-pr/shared": "0.222.7",
|
|
30
30
|
"@pubinfo/unplugin-openapi": "^0.9.1",
|
|
31
31
|
"@vitejs/plugin-legacy": "^7.2.1",
|
|
32
32
|
"@vitejs/plugin-vue": "^6.0.4",
|