@nuxt/module-builder 0.5.4 → 0.5.5
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 +6 -7
- package/dist/chunks/build.mjs +13 -5
- package/dist/cli.mjs +2 -2
- package/package.json +16 -15
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` or `
|
|
45
|
+
You could also optionally export `ModuleHooks` or `ModuleRuntimeHooks` to annotate any custom hooks the module uses.
|
|
46
46
|
|
|
47
47
|
```ts [src/module.ts]
|
|
48
48
|
import { defineNuxtModule } from '@nuxt/kit'
|
|
@@ -55,16 +55,16 @@ export interface ModuleHooks {
|
|
|
55
55
|
'my-module:init': any
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export interface
|
|
58
|
+
export interface ModuleRuntimeHooks {
|
|
59
59
|
'my-module:runtime-hook': any
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export interface
|
|
63
|
-
|
|
62
|
+
export interface ModuleRuntimeConfig {
|
|
63
|
+
PRIVATE_NAME: string
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export interface
|
|
67
|
-
|
|
66
|
+
export interface ModulePublicRuntimeConfig {
|
|
67
|
+
NAME: string
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export default defineNuxtModule<ModuleOptions>({
|
|
@@ -145,7 +145,6 @@ Module builder generates dist files in `dist/` directory:
|
|
|
145
145
|
|
|
146
146
|
[MIT](./LICENSE) - Made with 💚
|
|
147
147
|
|
|
148
|
-
|
|
149
148
|
<!-- Badges -->
|
|
150
149
|
[npm-version-src]: https://img.shields.io/npm/v/@nuxt/module-builder/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
151
150
|
[npm-version-href]: https://npmjs.com/package/@nuxt/module-builder
|
package/dist/chunks/build.mjs
CHANGED
|
@@ -73,7 +73,7 @@ const build = defineCommand({
|
|
|
73
73
|
if (!moduleFn) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const moduleMeta = await moduleFn.getMeta();
|
|
76
|
+
const moduleMeta = await moduleFn.getMeta?.() || {};
|
|
77
77
|
if (ctx.pkg) {
|
|
78
78
|
if (!moduleMeta.name) {
|
|
79
79
|
moduleMeta.name = ctx.pkg.name;
|
|
@@ -119,9 +119,17 @@ async function writeTypes(distDir, meta) {
|
|
|
119
119
|
moduleImports.push("ModuleHooks");
|
|
120
120
|
schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
|
|
121
121
|
}
|
|
122
|
-
if (hasTypeExport("RuntimeModuleHooks")) {
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
if (hasTypeExport("RuntimeModuleHooks") || hasTypeExport("ModuleRuntimeHooks")) {
|
|
123
|
+
const runtimeHooksInterfaces = [];
|
|
124
|
+
if (hasTypeExport("RuntimeModuleHooks")) {
|
|
125
|
+
consola.warn("`RuntimeModuleHooks` is a deprecated naming and will be removed in the future. Please use `ModuleRuntimeHooks` instead.");
|
|
126
|
+
runtimeHooksInterfaces.push("RuntimeModuleHooks");
|
|
127
|
+
}
|
|
128
|
+
if (hasTypeExport("ModuleRuntimeHooks")) {
|
|
129
|
+
runtimeHooksInterfaces.push("ModuleRuntimeHooks");
|
|
130
|
+
}
|
|
131
|
+
moduleImports.push(...runtimeHooksInterfaces);
|
|
132
|
+
appShims.push(` interface RuntimeNuxtHooks extends ${runtimeHooksInterfaces.join(", ")} {}`);
|
|
125
133
|
}
|
|
126
134
|
if (hasTypeExport("ModuleRuntimeConfig")) {
|
|
127
135
|
moduleImports.push("ModuleRuntimeConfig");
|
|
@@ -151,7 +159,7 @@ export type { ${typeExports[0].names.join(", ")} } from './module'
|
|
|
151
159
|
`;
|
|
152
160
|
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
|
153
161
|
if (!existsSync(dtsFileMts)) {
|
|
154
|
-
await promises.writeFile(dtsFileMts, dtsContents, "utf8");
|
|
162
|
+
await promises.writeFile(dtsFileMts, dtsContents.replaceAll("./module", "./module.js"), "utf8");
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
async function writeCJSStub(distDir) {
|
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.5";
|
|
7
7
|
const description = "Complete solution for building Nuxt modules";
|
|
8
8
|
|
|
9
9
|
const _rDefault = (r) => r.default || r;
|
|
@@ -19,7 +19,7 @@ const main = defineCommand({
|
|
|
19
19
|
},
|
|
20
20
|
setup(context) {
|
|
21
21
|
const firstArg = context.rawArgs[0];
|
|
22
|
-
if (!(firstArg in context.cmd.subCommands)) {
|
|
22
|
+
if (context.cmd.subCommands && !(firstArg in context.cmd.subCommands)) {
|
|
23
23
|
consola.warn("Please specify the `build` command explicitly. In a future version of `@nuxt/module-builder`, the implicit default build command will be removed.");
|
|
24
24
|
context.rawArgs.unshift("build");
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"repository": "nuxt/module-builder",
|
|
5
5
|
"description": "Complete solution for building Nuxt modules",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,37 +19,38 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
-
"packageManager": "pnpm@8.
|
|
22
|
+
"packageManager": "pnpm@8.12.1",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"citty": "^0.1.
|
|
24
|
+
"citty": "^0.1.5",
|
|
25
25
|
"consola": "^3.2.3",
|
|
26
26
|
"mlly": "^1.4.2",
|
|
27
27
|
"pathe": "^1.1.1",
|
|
28
28
|
"unbuild": "^2.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@nuxt/kit": "^3.8.
|
|
32
|
-
"nuxi": "^3.
|
|
31
|
+
"@nuxt/kit": "^3.8.2",
|
|
32
|
+
"nuxi": "^3.10.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.8.
|
|
36
|
-
"@nuxt/schema": "^3.8.
|
|
35
|
+
"@nuxt/kit": "^3.8.2",
|
|
36
|
+
"@nuxt/schema": "^3.8.2",
|
|
37
37
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
38
|
-
"@types/node": "^20.
|
|
39
|
-
"@vitest/coverage-v8": "^
|
|
38
|
+
"@types/node": "^20.10.5",
|
|
39
|
+
"@vitest/coverage-v8": "^1.1.0",
|
|
40
40
|
"changelogen": "^0.5.5",
|
|
41
|
-
"eslint": "^8.
|
|
41
|
+
"eslint": "^8.56.0",
|
|
42
42
|
"jiti": "^1.21.0",
|
|
43
|
-
"nuxi": "^3.
|
|
44
|
-
"nuxt": "^3.8.
|
|
45
|
-
"vitest": "^
|
|
43
|
+
"nuxi": "^3.10.0",
|
|
44
|
+
"nuxt": "^3.8.2",
|
|
45
|
+
"vitest": "^1.1.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "unbuild",
|
|
49
|
-
"example:build": "pnpm nuxt-module-build ./example",
|
|
49
|
+
"example:build": "pnpm nuxt-module-build build ./example",
|
|
50
50
|
"lint": "eslint --ext .ts,.js,.mjs .",
|
|
51
51
|
"nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
|
|
52
52
|
"release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
53
|
-
"test": "pnpm vitest"
|
|
53
|
+
"test": "pnpm vitest",
|
|
54
|
+
"test:types": "tsc --noEmit && pnpm -r test:types"
|
|
54
55
|
}
|
|
55
56
|
}
|