vite-plugin-blocklet 0.8.3 → 0.8.4
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 +4 -6
- package/libs/client.js +1 -1
- package/libs/express.js +4 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,6 @@ var getPort = require('get-port');
|
|
|
14
14
|
var mri = require('mri');
|
|
15
15
|
var httpProxyMiddleware = require('http-proxy-middleware');
|
|
16
16
|
|
|
17
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
18
17
|
const { types } = Mcrypto;
|
|
19
18
|
|
|
20
19
|
function toBlockletDid(name) {
|
|
@@ -406,13 +405,12 @@ function createConfigPlugin(options) {
|
|
|
406
405
|
*
|
|
407
406
|
* @param {object} options - The options for the plugin.
|
|
408
407
|
* @param {string} options.entryPath - The entry path of the Express app.
|
|
408
|
+
* @param {array} options.ignorePath - The entry path of the Express app.
|
|
409
409
|
* @return {object} The Vite config plugin.
|
|
410
410
|
*/
|
|
411
|
-
function createExpressPlugin({ entryPath }) {
|
|
411
|
+
function createExpressPlugin({ entryPath, ignorePath = [] }) {
|
|
412
|
+
ignorePath = Array.isArray(ignorePath) ? ignorePath : [ignorePath];
|
|
412
413
|
// 此处需要解构 import.meta 对象,才能拿到 vite.config 的地址,否则拿到的地址会是 express.js 文件的地址
|
|
413
|
-
const { dirname } = { ...({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) }) };
|
|
414
|
-
const fullPath = path.join(dirname, entryPath);
|
|
415
|
-
const folderPath = path.dirname(fullPath);
|
|
416
414
|
return {
|
|
417
415
|
name: 'blocklet:express',
|
|
418
416
|
apply: 'serve',
|
|
@@ -432,7 +430,7 @@ function createExpressPlugin({ entryPath }) {
|
|
|
432
430
|
const invalidatedModules = [];
|
|
433
431
|
|
|
434
432
|
for (const mod of modules) {
|
|
435
|
-
if (mod.file.
|
|
433
|
+
if (ignorePath.some((x) => mod.file.startsWith(x))) {
|
|
436
434
|
invalidatedModules.push(mod);
|
|
437
435
|
} else {
|
|
438
436
|
validatedModules.push(mod);
|
package/libs/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import getPort from 'get-port';
|
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
4
|
import mri from 'mri';
|
|
5
5
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
6
|
-
import { blockletPrefix } from './utils';
|
|
6
|
+
import { blockletPrefix } from './utils.js';
|
|
7
7
|
|
|
8
8
|
const argv = process.argv.slice(2);
|
|
9
9
|
const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
|
package/libs/express.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
1
|
/**
|
|
3
2
|
* Creates a config plugin for Vite development server.
|
|
4
3
|
*
|
|
5
4
|
* @param {object} options - The options for the plugin.
|
|
6
5
|
* @param {string} options.entryPath - The entry path of the Express app.
|
|
6
|
+
* @param {array} options.ignorePath - The entry path of the Express app.
|
|
7
7
|
* @return {object} The Vite config plugin.
|
|
8
8
|
*/
|
|
9
|
-
export default function createExpressPlugin({ entryPath }) {
|
|
9
|
+
export default function createExpressPlugin({ entryPath, ignorePath = [] }) {
|
|
10
|
+
ignorePath = Array.isArray(ignorePath) ? ignorePath : [ignorePath];
|
|
10
11
|
// 此处需要解构 import.meta 对象,才能拿到 vite.config 的地址,否则拿到的地址会是 express.js 文件的地址
|
|
11
|
-
const { dirname } = { ...import.meta };
|
|
12
|
-
const fullPath = path.join(dirname, entryPath);
|
|
13
|
-
const folderPath = path.dirname(fullPath);
|
|
14
12
|
return {
|
|
15
13
|
name: 'blocklet:express',
|
|
16
14
|
apply: 'serve',
|
|
@@ -30,7 +28,7 @@ export default function createExpressPlugin({ entryPath }) {
|
|
|
30
28
|
const invalidatedModules = [];
|
|
31
29
|
|
|
32
30
|
for (const mod of modules) {
|
|
33
|
-
if (mod.file.
|
|
31
|
+
if (ignorePath.some((x) => mod.file.startsWith(x))) {
|
|
34
32
|
invalidatedModules.push(mod);
|
|
35
33
|
} else {
|
|
36
34
|
validatedModules.push(mod);
|