vite-plugin-blocklet 0.5.17 → 0.5.20
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/README.md +1 -1
- package/dist/index.cjs +18 -2
- package/index.js +12 -1
- package/libs/client.js +3 -1
- package/package.json +5 -4
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var vitePluginNodePolyfills = require('vite-plugin-node-polyfills');
|
|
5
6
|
var vite = require('vite');
|
|
6
7
|
var semver = require('semver');
|
|
7
8
|
var Mcrypto = require('@ocap/mcrypto');
|
|
@@ -162,7 +163,7 @@ async function setupClient(app, options = {}) {
|
|
|
162
163
|
config: 'c',
|
|
163
164
|
},
|
|
164
165
|
});
|
|
165
|
-
const { host = '127.0.0.1', protocol = 'ws', port: inputPort, configFile = '' } = options;
|
|
166
|
+
const { host = '127.0.0.1', protocol = 'ws', port: inputPort, configFile = '', appType = 'spa' } = options;
|
|
166
167
|
const port = await getPort__default["default"]({ port: inputPort });
|
|
167
168
|
// 以中间件模式创建 Vite 服务器
|
|
168
169
|
const vite$1 = await vite.createServer({
|
|
@@ -175,14 +176,22 @@ async function setupClient(app, options = {}) {
|
|
|
175
176
|
protocol,
|
|
176
177
|
},
|
|
177
178
|
},
|
|
179
|
+
appType,
|
|
178
180
|
});
|
|
179
181
|
// 将 vite 的 connect 实例作中间件使用
|
|
180
182
|
app.use(vite$1.middlewares);
|
|
183
|
+
return vite$1;
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
function createBlockletPlugin(options = {}) {
|
|
185
|
-
const {
|
|
188
|
+
const {
|
|
189
|
+
// NOTICE: 由于 polyfill 不是每个项目都必须的,并且有些现有的项目已经配置了 polyfill,所以这个配置默认 disable 会比较好
|
|
190
|
+
disableNodePolyfills = true,
|
|
191
|
+
disableConfig = false,
|
|
192
|
+
disableMeta = false,
|
|
193
|
+
disableHmr = false,
|
|
194
|
+
} = options;
|
|
186
195
|
const plugins = [];
|
|
187
196
|
if (!disableMeta) {
|
|
188
197
|
plugins.push(createMetaPlugin());
|
|
@@ -193,10 +202,17 @@ function createBlockletPlugin(options = {}) {
|
|
|
193
202
|
if (!disableHmr) {
|
|
194
203
|
plugins.push(createHmrPlugin(options));
|
|
195
204
|
}
|
|
205
|
+
if (!disableNodePolyfills) {
|
|
206
|
+
plugins.push(vitePluginNodePolyfills.nodePolyfills({ protocolImports: true }));
|
|
207
|
+
}
|
|
196
208
|
|
|
197
209
|
return plugins;
|
|
198
210
|
}
|
|
199
211
|
|
|
212
|
+
Object.defineProperty(exports, 'nodePolyfills', {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () { return vitePluginNodePolyfills.nodePolyfills; }
|
|
215
|
+
});
|
|
200
216
|
exports.createBlockletConfig = createConfigPlugin;
|
|
201
217
|
exports.createBlockletHmr = createHmrPlugin;
|
|
202
218
|
exports.createBlockletMeta = createMetaPlugin;
|
package/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
1
2
|
import createHmrPlugin from './libs/hmr.js';
|
|
2
3
|
import createConfigPlugin from './libs/config.js';
|
|
3
4
|
import createMetaPlugin from './libs/meta.js';
|
|
4
5
|
import setupClient from './libs/client.js';
|
|
5
6
|
|
|
6
7
|
export function createBlockletPlugin(options = {}) {
|
|
7
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
// NOTICE: 由于 polyfill 不是每个项目都必须的,并且有些现有的项目已经配置了 polyfill,所以这个配置默认 disable 会比较好
|
|
10
|
+
disableNodePolyfills = true,
|
|
11
|
+
disableConfig = false,
|
|
12
|
+
disableMeta = false,
|
|
13
|
+
disableHmr = false,
|
|
14
|
+
} = options;
|
|
8
15
|
const plugins = [];
|
|
9
16
|
if (!disableMeta) {
|
|
10
17
|
plugins.push(createMetaPlugin(options));
|
|
@@ -15,6 +22,9 @@ export function createBlockletPlugin(options = {}) {
|
|
|
15
22
|
if (!disableHmr) {
|
|
16
23
|
plugins.push(createHmrPlugin(options));
|
|
17
24
|
}
|
|
25
|
+
if (!disableNodePolyfills) {
|
|
26
|
+
plugins.push(nodePolyfills({ protocolImports: true }));
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
return plugins;
|
|
20
30
|
}
|
|
@@ -24,4 +34,5 @@ export {
|
|
|
24
34
|
createHmrPlugin as createBlockletHmr,
|
|
25
35
|
createConfigPlugin as createBlockletConfig,
|
|
26
36
|
createMetaPlugin as createBlockletMeta,
|
|
37
|
+
nodePolyfills,
|
|
27
38
|
};
|
package/libs/client.js
CHANGED
|
@@ -12,7 +12,7 @@ export default async function setupClient(app, options = {}) {
|
|
|
12
12
|
config: 'c',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
|
-
const { host = '127.0.0.1', protocol = 'ws', port: inputPort, configFile = '' } = options;
|
|
15
|
+
const { host = '127.0.0.1', protocol = 'ws', port: inputPort, configFile = '', appType = 'spa' } = options;
|
|
16
16
|
const port = await getPort({ port: inputPort });
|
|
17
17
|
// 以中间件模式创建 Vite 服务器
|
|
18
18
|
const vite = await createServer({
|
|
@@ -25,8 +25,10 @@ export default async function setupClient(app, options = {}) {
|
|
|
25
25
|
protocol,
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
+
appType,
|
|
28
29
|
});
|
|
29
30
|
// 将 vite 的 connect 实例作中间件使用
|
|
30
31
|
app.use(vite.middlewares);
|
|
32
|
+
return vite;
|
|
31
33
|
}
|
|
32
34
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.20",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"rollup": "^2.79.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@arcblock/did": "^1.18.
|
|
31
|
-
"@ocap/mcrypto": "^1.18.
|
|
32
|
-
"@ocap/util": "^1.18.
|
|
30
|
+
"@arcblock/did": "^1.18.65",
|
|
31
|
+
"@ocap/mcrypto": "^1.18.65",
|
|
32
|
+
"@ocap/util": "^1.18.65",
|
|
33
33
|
"get-port": "^5.1.1",
|
|
34
34
|
"mri": "^1.2.0",
|
|
35
35
|
"semver": "^7.3.8",
|
|
36
|
+
"vite-plugin-node-polyfills": "^0.7.0",
|
|
36
37
|
"yaml": "^2.2.1"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|