@nuxt/module-builder 0.5.2 → 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 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
  }
@@ -44,6 +44,9 @@ const build = defineCommand({
44
44
  { input: "src/runtime/", outDir: `${outDir}/runtime`, ext: "mjs" }
45
45
  ],
46
46
  rollup: {
47
+ esbuild: {
48
+ target: "esnext"
49
+ },
47
50
  emitCJS: false,
48
51
  cjsBridge: true
49
52
  },
@@ -103,6 +106,7 @@ async function writeTypes(distDir, meta) {
103
106
  )
104
107
  );
105
108
  const isStub = moduleTypes.includes("export *");
109
+ const appShims = [];
106
110
  const schemaShims = [];
107
111
  const moduleImports = [];
108
112
  const hasTypeExport = (name) => isStub || typeExports.find((exp) => exp.names.includes(name));
@@ -115,6 +119,10 @@ async function writeTypes(distDir, meta) {
115
119
  moduleImports.push("ModuleHooks");
116
120
  schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
117
121
  }
122
+ if (hasTypeExport("RuntimeModuleHooks")) {
123
+ moduleImports.push("RuntimeModuleHooks");
124
+ appShims.push(" interface RuntimeNuxtHooks extends RuntimeModuleHooks {}");
125
+ }
118
126
  if (hasTypeExport("ModuleRuntimeConfig")) {
119
127
  moduleImports.push("ModuleRuntimeConfig");
120
128
  schemaShims.push(" interface RuntimeConfig extends ModuleRuntimeConfig {}");
@@ -124,8 +132,12 @@ async function writeTypes(distDir, meta) {
124
132
  schemaShims.push(" interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}");
125
133
  }
126
134
  const dtsContents = `
127
- import { ${moduleImports.join(", ")} } from './module'
135
+ import type { ${moduleImports.join(", ")} } from './module'
128
136
 
137
+ ${appShims.length ? `declare module '#app' {
138
+ ${appShims.join("\n")}
139
+ }
140
+ ` : ""}
129
141
  ${schemaShims.length ? `declare module '@nuxt/schema' {
130
142
  ${schemaShims.join("\n")}
131
143
  }
@@ -135,7 +147,7 @@ ${schemaShims.join("\n")}
135
147
  }
136
148
  ` : ""}
137
149
 
138
- export { ${typeExports[0].names.join(", ")} } from './module'
150
+ export type { ${typeExports[0].names.join(", ")} } from './module'
139
151
  `;
140
152
  await promises.writeFile(dtsFile, dtsContents, "utf8");
141
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.2";
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.2",
3
+ "version": "0.5.4",
4
4
  "repository": "nuxt/module-builder",
5
5
  "description": "Complete solution for building Nuxt modules",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "packageManager": "pnpm@8.8.0",
22
+ "packageManager": "pnpm@8.10.2",
23
23
  "dependencies": {
24
24
  "citty": "^0.1.4",
25
25
  "consola": "^3.2.3",
@@ -28,21 +28,21 @@
28
28
  "unbuild": "^2.0.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@nuxt/kit": "^3.7.4",
32
- "nuxi": "^3.9.0"
31
+ "@nuxt/kit": "^3.8.1",
32
+ "nuxi": "^3.9.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@nuxt/kit": "^3.7.4",
36
- "@nuxt/schema": "^3.7.4",
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.7.1",
39
- "@vitest/coverage-v8": "^0.34.5",
38
+ "@types/node": "^20.9.0",
39
+ "@vitest/coverage-v8": "^0.34.6",
40
40
  "changelogen": "^0.5.5",
41
- "eslint": "^8.50.0",
42
- "jiti": "^1.20.0",
43
- "nuxi": "^3.9.0",
44
- "nuxt": "^3.7.4",
45
- "vitest": "^0.34.5"
41
+ "eslint": "^8.53.0",
42
+ "jiti": "^1.21.0",
43
+ "nuxi": "^3.9.1",
44
+ "nuxt": "^3.8.1",
45
+ "vitest": "^0.34.6"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "unbuild",