@pubinfo/vite 2.0.0-rc.3 → 2.0.0-rc.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.
Files changed (2) hide show
  1. package/dist/index.js +15 -33
  2. package/package.json +3 -5
package/dist/index.js CHANGED
@@ -106,12 +106,11 @@ function createComponents() {
106
106
  {
107
107
  type: "component",
108
108
  resolve(name) {
109
- const components$1 = [
109
+ if ([
110
110
  "PubinfoApp",
111
111
  "PubinfoProvider",
112
112
  "PubinfoIcon"
113
- ];
114
- if (components$1.includes(name)) return {
113
+ ].includes(name)) return {
115
114
  name,
116
115
  from: "pubinfo"
117
116
  };
@@ -258,14 +257,9 @@ function libResolverPlugin(options) {
258
257
  const normalizedFile = normalizePath$1(file);
259
258
  const isVueOrTsFile = /\.(vue|tsx?|jsx?)$/.test(normalizedFile);
260
259
  const relativePath = serverRoot ? normalizePath$1(relative(serverRoot, normalizedFile)) : normalizedFile;
261
- const patterns = Object.values(options.entries);
262
- const matchesPattern = patterns.some((pattern, index) => {
263
- const matcher = picomatch(pattern);
264
- const matches = matcher(relativePath);
265
- return matches;
266
- });
267
- const result = matchesPattern && isVueOrTsFile;
268
- return result;
260
+ return Object.values(options.entries).some((pattern, index) => {
261
+ return picomatch(pattern)(relativePath);
262
+ }) && isVueOrTsFile;
269
263
  }
270
264
  return {
271
265
  name: "vite-plugin-lib-resolver",
@@ -299,7 +293,7 @@ function libResolverPlugin(options) {
299
293
  },
300
294
  async load(id) {
301
295
  if (id !== resolvedId) return null;
302
- const moduleResults = await Promise.all(Object.entries(options.entries).map(async ([key, pattern]) => {
296
+ return `export default {\n ${(await Promise.all(Object.entries(options.entries).map(async ([key, pattern]) => {
303
297
  try {
304
298
  const files = await fg(pattern, { absolute: true });
305
299
  if (files.length === 0) return {
@@ -311,8 +305,7 @@ function libResolverPlugin(options) {
311
305
  const imports = files.map((file) => {
312
306
  const absPath = normalizePath$1(file);
313
307
  const relToBase = normalizePath$1(relative(resolve(base), file));
314
- const relPath = posix.join(base, relToBase);
315
- return `"${relPath}": () => import("${absPath}")`;
308
+ return `"${posix.join(base, relToBase)}": () => import("${absPath}")`;
316
309
  }).join(",\n");
317
310
  return {
318
311
  key,
@@ -327,10 +320,7 @@ function libResolverPlugin(options) {
327
320
  files: []
328
321
  };
329
322
  }
330
- }));
331
- const moduleDefs = moduleResults.map((result) => result.content);
332
- const content = `export default {\n ${moduleDefs.join(",\n ")}\n}`;
333
- return content;
323
+ }))).map((result) => result.content).join(",\n ")}\n}`;
334
324
  }
335
325
  };
336
326
  }
@@ -370,8 +360,7 @@ function createUnocss() {
370
360
  //#endregion
371
361
  //#region src/plugins/virtual-inspector.ts
372
362
  function getInspectorPath() {
373
- const pluginPath = normalizePath(dirname(fileURLToPath(import.meta.url)));
374
- return pluginPath;
363
+ return normalizePath(dirname(fileURLToPath(import.meta.url)));
375
364
  }
376
365
  function createVirtualInspectorPlugin(options = {}) {
377
366
  const { enabled = true } = options;
@@ -395,10 +384,7 @@ function createVirtualInspectorPlugin(options = {}) {
395
384
  });
396
385
  },
397
386
  async resolveId(importee) {
398
- if (importee === virtualModuleId) {
399
- const resolved = resolve(inspectorPath, "load.js");
400
- return resolved;
401
- }
387
+ if (importee === virtualModuleId) return resolve(inspectorPath, "load.js");
402
388
  return null;
403
389
  },
404
390
  async load(id) {
@@ -439,7 +425,7 @@ function createVirtualInspector(options) {
439
425
  //#endregion
440
426
  //#region src/plugins/index.ts
441
427
  function createVitePlugins(viteEnv, isBuild = false, config, type) {
442
- const vitePlugins = [
428
+ return [
443
429
  vue(),
444
430
  vueJsx(),
445
431
  createLegacy(viteEnv),
@@ -455,8 +441,7 @@ function createVitePlugins(viteEnv, isBuild = false, config, type) {
455
441
  createVirtualInspector({ enabled: true }),
456
442
  type === "module" ? [createDTS(), createInjectCSS()] : null,
457
443
  isBuild ? createCompression(viteEnv) : null
458
- ];
459
- return vitePlugins.filter(Boolean);
444
+ ].filter(Boolean);
460
445
  }
461
446
 
462
447
  //#endregion
@@ -468,13 +453,12 @@ function createDefaultAppConfig(config) {
468
453
  const timestamp = (/* @__PURE__ */ new Date()).getTime();
469
454
  const env = loadEnv(mode, root);
470
455
  const { VITE_OPEN_PROXY, VITE_BUILD_SOURCEMAP } = env;
471
- const serverProxy = getServerProxy(env, !isBuild && VITE_OPEN_PROXY === "true");
472
- const applicationConfig = {
456
+ return {
473
457
  base: "./",
474
458
  server: {
475
459
  open: true,
476
460
  host: true,
477
- proxy: serverProxy,
461
+ proxy: getServerProxy(env, !isBuild && VITE_OPEN_PROXY === "true"),
478
462
  warmup: { clientFiles: ["./index.html"] }
479
463
  },
480
464
  optimizeDeps: { exclude: [
@@ -498,7 +482,6 @@ function createDefaultAppConfig(config) {
498
482
  },
499
483
  plugins: createVitePlugins(env, isBuild, config, "app")
500
484
  };
501
- return applicationConfig;
502
485
  };
503
486
  }
504
487
 
@@ -509,7 +492,7 @@ function createDefaultModuleConfig(config) {
509
492
  const root = cwd();
510
493
  const isBuild = command === "build";
511
494
  const env = loadEnv(mode, root);
512
- const applicationConfig = {
495
+ return {
513
496
  optimizeDeps: { exclude: [
514
497
  "pubinfo",
515
498
  "@pubinfo/core",
@@ -527,7 +510,6 @@ function createDefaultModuleConfig(config) {
527
510
  } },
528
511
  plugins: createVitePlugins(env, isBuild, config, "module")
529
512
  };
530
- return applicationConfig;
531
513
  };
532
514
  }
533
515
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/vite",
3
3
  "type": "module",
4
- "version": "2.0.0-rc.3",
4
+ "version": "2.0.0-rc.4",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -15,8 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "peerDependencies": {
18
- "vue": "^3.5.17",
19
- "vue-i18n": "^10.0.7"
18
+ "vue": "^3.5.17"
20
19
  },
21
20
  "dependencies": {
22
21
  "@pubinfo/unplugin-openapi": "^0.9.0",
@@ -51,8 +50,7 @@
51
50
  "@types/lodash-es": "^4.17.12",
52
51
  "@types/node": "^24.0.10",
53
52
  "@types/picomatch": "^4.0.2",
54
- "vue": "^3.5.17",
55
- "vue-i18n": "^10.0.7"
53
+ "vue": "^3.5.17"
56
54
  },
57
55
  "scripts": {
58
56
  "dev": "tsdown --watch",