@vueuse/nuxt 7.6.2 → 8.0.0-beta.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.
Files changed (3) hide show
  1. package/index.mjs +9 -17
  2. package/package.json +3 -2
  3. package/indexes.json +0 -1701
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import fs from 'fs';
2
1
  import { dirname, resolve } from 'path';
3
2
  import { fileURLToPath } from 'url';
4
3
  import { isPackageExists } from 'local-pkg';
5
4
  import { defineNuxtModule } from '@nuxt/kit';
5
+ import { metadata } from '@vueuse/metadata';
6
6
 
7
7
  const _dirname = dirname(fileURLToPath(import.meta.url));
8
8
  const disabledFunctions = [
@@ -41,7 +41,6 @@ var index = defineNuxtModule({
41
41
  nuxt.options.build = nuxt.options.build || {};
42
42
  nuxt.options.build.transpile = nuxt.options.build.transpile || [];
43
43
  nuxt.options.build.transpile.push(...fullPackages);
44
- let indexes;
45
44
  if (options.ssrHandlers) {
46
45
  const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
47
46
  nuxt.options.plugins = nuxt.options.plugins || [];
@@ -51,29 +50,22 @@ var index = defineNuxtModule({
51
50
  nuxt.hook("autoImports:sources", (sources) => {
52
51
  if (sources.find((i) => fullPackages.includes(i.from)))
53
52
  return;
54
- if (!indexes) {
55
- try {
56
- indexes = JSON.parse(fs.readFileSync(resolve(_dirname, "./indexes.json"), "utf-8"));
57
- indexes == null ? void 0 : indexes.functions.forEach((i) => {
58
- if (i.package === "shared")
59
- i.package = "core";
60
- });
61
- } catch (e) {
62
- throw new Error("[@vueuse/nuxt] Failed to load indexes.json");
63
- }
64
- }
65
- if (!indexes)
66
- return;
53
+ metadata.functions.forEach((i) => {
54
+ if (i.package === "shared")
55
+ i.package = "core";
56
+ });
67
57
  for (const pkg of packages) {
68
58
  if (pkg === "shared")
69
59
  continue;
70
60
  if (!isPackageExists(`@vueuse/${pkg}`))
71
61
  continue;
72
- const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
62
+ const functions = metadata.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
73
63
  if (functions.length) {
64
+ const imports = metadata.functions.filter((i) => i.package === pkg && !i.internal).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i.length >= 4 && !disabledFunctions.includes(i));
74
65
  sources.push({
75
66
  from: `@vueuse/${pkg}`,
76
- names: indexes.functions.filter((i) => i.package === pkg && !i.internal).map((i) => i.name).filter((i) => i.length >= 4 && !disabledFunctions.includes(i))
67
+ names: imports,
68
+ imports
77
69
  });
78
70
  }
79
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/nuxt",
3
- "version": "7.6.2",
3
+ "version": "8.0.0-beta.2",
4
4
  "description": "VueUse Nuxt Module",
5
5
  "keywords": [
6
6
  "vue",
@@ -35,7 +35,8 @@
35
35
  "types": "./index.d.ts",
36
36
  "dependencies": {
37
37
  "@nuxt/kit": "npm:@nuxt/kit-edge@latest",
38
- "@vueuse/core": "7.6.2",
38
+ "@vueuse/core": "8.0.0-beta.2",
39
+ "@vueuse/metadata": "8.0.0-beta.2",
39
40
  "local-pkg": "^0.4.1",
40
41
  "vue-demi": "*"
41
42
  },