@nuxt/module-builder 0.5.3 → 0.5.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/README.md +5 -1
- package/dist/chunks/build.mjs +11 -2
- package/dist/cli.mjs +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ The entrypoint for module definition.
|
|
|
42
42
|
|
|
43
43
|
A default export using `defineNuxtModule` and `ModuleOptions` type export is expected.
|
|
44
44
|
|
|
45
|
-
You could also optionally export `ModuleHooks` to annotate any custom hooks the module uses.
|
|
45
|
+
You could also optionally export `ModuleHooks` or `RuntimeModuleHooks` to annotate any custom hooks the module uses.
|
|
46
46
|
|
|
47
47
|
```ts [src/module.ts]
|
|
48
48
|
import { defineNuxtModule } from '@nuxt/kit'
|
|
@@ -55,6 +55,10 @@ export interface ModuleHooks {
|
|
|
55
55
|
'my-module:init': any
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export interface RuntimeModuleHooks {
|
|
59
|
+
'my-module:runtime-hook': any
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
export interface ModulePublicRuntimeConfig {
|
|
59
63
|
NAME: string
|
|
60
64
|
}
|
package/dist/chunks/build.mjs
CHANGED
|
@@ -106,6 +106,7 @@ async function writeTypes(distDir, meta) {
|
|
|
106
106
|
)
|
|
107
107
|
);
|
|
108
108
|
const isStub = moduleTypes.includes("export *");
|
|
109
|
+
const appShims = [];
|
|
109
110
|
const schemaShims = [];
|
|
110
111
|
const moduleImports = [];
|
|
111
112
|
const hasTypeExport = (name) => isStub || typeExports.find((exp) => exp.names.includes(name));
|
|
@@ -118,6 +119,10 @@ async function writeTypes(distDir, meta) {
|
|
|
118
119
|
moduleImports.push("ModuleHooks");
|
|
119
120
|
schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
|
|
120
121
|
}
|
|
122
|
+
if (hasTypeExport("RuntimeModuleHooks")) {
|
|
123
|
+
moduleImports.push("RuntimeModuleHooks");
|
|
124
|
+
appShims.push(" interface RuntimeNuxtHooks extends RuntimeModuleHooks {}");
|
|
125
|
+
}
|
|
121
126
|
if (hasTypeExport("ModuleRuntimeConfig")) {
|
|
122
127
|
moduleImports.push("ModuleRuntimeConfig");
|
|
123
128
|
schemaShims.push(" interface RuntimeConfig extends ModuleRuntimeConfig {}");
|
|
@@ -127,8 +132,12 @@ async function writeTypes(distDir, meta) {
|
|
|
127
132
|
schemaShims.push(" interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}");
|
|
128
133
|
}
|
|
129
134
|
const dtsContents = `
|
|
130
|
-
import { ${moduleImports.join(", ")} } from './module'
|
|
135
|
+
import type { ${moduleImports.join(", ")} } from './module'
|
|
131
136
|
|
|
137
|
+
${appShims.length ? `declare module '#app' {
|
|
138
|
+
${appShims.join("\n")}
|
|
139
|
+
}
|
|
140
|
+
` : ""}
|
|
132
141
|
${schemaShims.length ? `declare module '@nuxt/schema' {
|
|
133
142
|
${schemaShims.join("\n")}
|
|
134
143
|
}
|
|
@@ -138,7 +147,7 @@ ${schemaShims.join("\n")}
|
|
|
138
147
|
}
|
|
139
148
|
` : ""}
|
|
140
149
|
|
|
141
|
-
export { ${typeExports[0].names.join(", ")} } from './module'
|
|
150
|
+
export type { ${typeExports[0].names.join(", ")} } from './module'
|
|
142
151
|
`;
|
|
143
152
|
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
|
144
153
|
if (!existsSync(dtsFileMts)) {
|
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { defineCommand, runMain } from 'citty';
|
|
|
3
3
|
import { consola } from 'consola';
|
|
4
4
|
|
|
5
5
|
const name = "@nuxt/module-builder";
|
|
6
|
-
const version = "0.5.
|
|
6
|
+
const version = "0.5.4";
|
|
7
7
|
const description = "Complete solution for building Nuxt modules";
|
|
8
8
|
|
|
9
9
|
const _rDefault = (r) => r.default || r;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"repository": "nuxt/module-builder",
|
|
5
5
|
"description": "Complete solution for building Nuxt modules",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"unbuild": "^2.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@nuxt/kit": "^3.8.
|
|
31
|
+
"@nuxt/kit": "^3.8.1",
|
|
32
32
|
"nuxi": "^3.9.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.8.
|
|
36
|
-
"@nuxt/schema": "^3.8.
|
|
35
|
+
"@nuxt/kit": "^3.8.1",
|
|
36
|
+
"@nuxt/schema": "^3.8.1",
|
|
37
37
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
38
|
-
"@types/node": "^20.
|
|
38
|
+
"@types/node": "^20.9.0",
|
|
39
39
|
"@vitest/coverage-v8": "^0.34.6",
|
|
40
40
|
"changelogen": "^0.5.5",
|
|
41
41
|
"eslint": "^8.53.0",
|
|
42
42
|
"jiti": "^1.21.0",
|
|
43
43
|
"nuxi": "^3.9.1",
|
|
44
|
-
"nuxt": "^3.8.
|
|
44
|
+
"nuxt": "^3.8.1",
|
|
45
45
|
"vitest": "^0.34.6"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|