vite-plugin-blocklet 0.14.1 → 0.14.2
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 +18 -1
- package/index.js +19 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vitePluginNodePolyfills = require('vite-plugin-node-polyfills');
|
|
4
|
+
var defu = require('defu');
|
|
4
5
|
var vite = require('vite');
|
|
5
6
|
var semver = require('semver');
|
|
6
7
|
var node_fs = require('node:fs');
|
|
@@ -1002,6 +1003,14 @@ async function setupClient(app, options = {}) {
|
|
|
1002
1003
|
* @property {number} [chunkSizeLimit=2000] - The chunk size limit in KB.
|
|
1003
1004
|
*/
|
|
1004
1005
|
|
|
1006
|
+
const defuReplaceArray = defu.createDefu((obj, key, value) => {
|
|
1007
|
+
// 如果当前值或默认值是数组,直接使用新值(实现替换)
|
|
1008
|
+
if (Array.isArray(obj[key]) || Array.isArray(value)) {
|
|
1009
|
+
obj[key] = value;
|
|
1010
|
+
return true // 返回 true 表示我们已经处理了这个 key,defu 不需要再做默认处理
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1005
1014
|
/**
|
|
1006
1015
|
* Create blocklet plugins.
|
|
1007
1016
|
*
|
|
@@ -1037,7 +1046,15 @@ function createBlockletPlugin(options = {}) {
|
|
|
1037
1046
|
plugins.push(createHmrPlugin(restOptions));
|
|
1038
1047
|
}
|
|
1039
1048
|
if (!disableNodePolyfills) {
|
|
1040
|
-
|
|
1049
|
+
const mergedOptions = defuReplaceArray(nodePolyfillsOptions, {
|
|
1050
|
+
include: ['buffer'],
|
|
1051
|
+
globals: {
|
|
1052
|
+
buffer: true,
|
|
1053
|
+
global: false,
|
|
1054
|
+
process: false,
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
plugins.push(vitePluginNodePolyfills.nodePolyfills(mergedOptions));
|
|
1041
1058
|
}
|
|
1042
1059
|
if (!disableLoading) {
|
|
1043
1060
|
plugins.push(createLoadingPlugin(restOptions));
|
package/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
2
|
+
import { createDefu } from 'defu';
|
|
3
|
+
|
|
2
4
|
import createHmrPlugin from './libs/hmr.js';
|
|
3
5
|
import createConfigPlugin from './libs/config.js';
|
|
4
6
|
import createMetaPlugin from './libs/meta.js';
|
|
@@ -44,6 +46,14 @@ import setupClient from './libs/client.js';
|
|
|
44
46
|
* @property {number} [chunkSizeLimit=2000] - The chunk size limit in KB.
|
|
45
47
|
*/
|
|
46
48
|
|
|
49
|
+
const defuReplaceArray = createDefu((obj, key, value) => {
|
|
50
|
+
// 如果当前值或默认值是数组,直接使用新值(实现替换)
|
|
51
|
+
if (Array.isArray(obj[key]) || Array.isArray(value)) {
|
|
52
|
+
obj[key] = value
|
|
53
|
+
return true // 返回 true 表示我们已经处理了这个 key,defu 不需要再做默认处理
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
47
57
|
/**
|
|
48
58
|
* Create blocklet plugins.
|
|
49
59
|
*
|
|
@@ -79,7 +89,15 @@ export function createBlockletPlugin(options = {}) {
|
|
|
79
89
|
plugins.push(createHmrPlugin(restOptions));
|
|
80
90
|
}
|
|
81
91
|
if (!disableNodePolyfills) {
|
|
82
|
-
|
|
92
|
+
const mergedOptions = defuReplaceArray(nodePolyfillsOptions, {
|
|
93
|
+
include: ['buffer'],
|
|
94
|
+
globals: {
|
|
95
|
+
buffer: true,
|
|
96
|
+
global: false,
|
|
97
|
+
process: false,
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
plugins.push(nodePolyfills(mergedOptions));
|
|
83
101
|
}
|
|
84
102
|
if (!disableLoading) {
|
|
85
103
|
plugins.push(createLoadingPlugin(restOptions));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.2",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@arcblock/did": "^1.28.0",
|
|
34
34
|
"@ocap/mcrypto": "^1.28.0",
|
|
35
35
|
"@ocap/util": "^1.28.0",
|
|
36
|
+
"defu": "^6.1.4",
|
|
36
37
|
"get-port": "^5.1.1",
|
|
37
38
|
"http-proxy-middleware": "^3.0.3",
|
|
38
39
|
"ismobilejs": "^1.1.1",
|