@vueuse/nuxt 7.5.1 → 7.5.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/index.mjs +57 -48
- package/indexes.json +1 -0
- package/package.json +7 -3
package/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import { dirname, resolve } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { isPackageExists } from 'local-pkg';
|
|
5
|
+
import { defineNuxtModule } from '@nuxt/kit';
|
|
5
6
|
|
|
6
7
|
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
8
|
const disabledFunctions = [
|
|
@@ -22,55 +23,63 @@ const packages = [
|
|
|
22
23
|
"head"
|
|
23
24
|
];
|
|
24
25
|
const fullPackages = packages.map((p) => `@vueuse/${p}`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nuxt.options.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
26
|
+
var index = defineNuxtModule({
|
|
27
|
+
meta: {
|
|
28
|
+
name: "vueuse",
|
|
29
|
+
configKey: "vueuse"
|
|
30
|
+
},
|
|
31
|
+
defaults: {
|
|
32
|
+
ssrHandlers: false,
|
|
33
|
+
autoImports: true
|
|
34
|
+
},
|
|
35
|
+
setup(options, nuxt) {
|
|
36
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
37
|
+
config.optimizeDeps = config.optimizeDeps || {};
|
|
38
|
+
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
39
|
+
config.optimizeDeps.exclude.push(...fullPackages);
|
|
40
|
+
});
|
|
41
|
+
nuxt.options.build = nuxt.options.build || {};
|
|
42
|
+
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
43
|
+
nuxt.options.build.transpile.push(...fullPackages);
|
|
44
|
+
let indexes;
|
|
45
|
+
if (options.ssrHandlers) {
|
|
46
|
+
const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
|
|
47
|
+
nuxt.options.plugins = nuxt.options.plugins || [];
|
|
48
|
+
nuxt.options.plugins.push(pluginPath);
|
|
49
|
+
}
|
|
50
|
+
if (options.autoImports) {
|
|
51
|
+
nuxt.hook("autoImports:sources", (sources) => {
|
|
52
|
+
if (sources.find((i) => fullPackages.includes(i.from)))
|
|
53
|
+
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
|
+
}
|
|
55
64
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
65
|
+
if (!indexes)
|
|
66
|
+
return;
|
|
67
|
+
for (const pkg of packages) {
|
|
68
|
+
if (pkg === "shared")
|
|
69
|
+
continue;
|
|
70
|
+
if (!isPackageExists(`@vueuse/${pkg}`))
|
|
71
|
+
continue;
|
|
72
|
+
const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
|
|
73
|
+
if (functions.length) {
|
|
74
|
+
sources.push({
|
|
75
|
+
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))
|
|
77
|
+
});
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
73
82
|
}
|
|
74
|
-
}
|
|
83
|
+
});
|
|
75
84
|
|
|
76
|
-
export {
|
|
85
|
+
export { index as default };
|
package/indexes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/nuxt",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2",
|
|
4
4
|
"description": "VueUse Nuxt Module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -34,8 +34,12 @@
|
|
|
34
34
|
"module": "./index.mjs",
|
|
35
35
|
"types": "./index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
37
|
+
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
|
|
38
|
+
"@vueuse/core": "7.5.2",
|
|
39
|
+
"local-pkg": "^0.4.1",
|
|
39
40
|
"vue-demi": "*"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@nuxt/schema": "npm:@nuxt/schema-edge@latest"
|
|
40
44
|
}
|
|
41
45
|
}
|