@nuxt/module-builder 0.8.0 → 0.8.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.
@@ -9,7 +9,7 @@ import { createRegExp, anyOf } from 'magic-regexp';
9
9
  import { consola } from 'consola';
10
10
  import { resolvePath, findExports } from 'mlly';
11
11
  import { defineCommand } from 'citty';
12
- import { n as name, v as version } from '../shared/module-builder.297ff45d.mjs';
12
+ import { n as name, v as version } from '../shared/module-builder.026bb30a.mjs';
13
13
 
14
14
  const build = defineCommand({
15
15
  meta: {
@@ -142,28 +142,27 @@ const build = defineCommand({
142
142
  };
143
143
  const metaFile = resolve(ctx.options.outDir, "module.json");
144
144
  await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
145
- await writeTypes(ctx.options.outDir);
145
+ await writeTypes(ctx.options.outDir, ctx.options.stub);
146
146
  }
147
147
  }
148
148
  });
149
149
  }
150
150
  });
151
- async function writeTypes(distDir) {
151
+ async function writeTypes(distDir, isStub) {
152
152
  const dtsFile = resolve(distDir, "types.d.ts");
153
153
  const dtsFileMts = resolve(distDir, "types.d.mts");
154
154
  if (existsSync(dtsFile)) {
155
155
  return;
156
156
  }
157
- const moduleTypesFile = resolve(distDir, "module.d.ts");
158
- const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
159
- const moduleReExports = findExports(
160
- // Replace `export { type Foo }` with `export { Foo }`
161
- moduleTypes.replace(
162
- /export\s*\{.*?\}/gs,
163
- (match) => match.replace(/\b(type|interface)\b/g, "")
164
- )
165
- );
166
- const isStub = moduleTypes.includes("export *");
157
+ const moduleReExports = [];
158
+ if (!isStub) {
159
+ const moduleTypesFile = resolve(distDir, "module.d.ts");
160
+ const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
161
+ const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
162
+ for (const e of findExports(normalisedModuleTypes)) {
163
+ moduleReExports.push(e);
164
+ }
165
+ }
167
166
  const appShims = [];
168
167
  const schemaShims = [];
169
168
  const moduleImports = [];
@@ -180,12 +179,8 @@ async function writeTypes(distDir) {
180
179
  schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
181
180
  }
182
181
  if (hasTypeExport("ModuleRuntimeHooks")) {
183
- const runtimeHooksInterfaces = [];
184
- if (hasTypeExport("ModuleRuntimeHooks")) {
185
- runtimeHooksInterfaces.push("ModuleRuntimeHooks");
186
- }
187
- moduleImports.push(...runtimeHooksInterfaces);
188
- appShims.push(` interface RuntimeNuxtHooks extends ${runtimeHooksInterfaces.join(", ")} {}`);
182
+ moduleImports.push("ModuleRuntimeHooks");
183
+ appShims.push(` interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}`);
189
184
  }
190
185
  if (hasTypeExport("ModuleRuntimeConfig")) {
191
186
  moduleImports.push("ModuleRuntimeConfig");
@@ -214,6 +209,7 @@ ${schemaShims.join("\n")}
214
209
  ` : ""}
215
210
  ${moduleExports.length ? `
216
211
  ${moduleExports.join("\n")}` : ""}
212
+ ${isStub ? 'export * from "./module"' : ""}
217
213
  ${moduleReExports[0] ? `
218
214
  export { ${moduleReExports[0].names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from './module'` : ""}
219
215
  `.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
@@ -22,6 +22,7 @@ const prepare = defineCommand({
22
22
  const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
23
23
  return runCommand("prepare", [cwd], {
24
24
  overrides: {
25
+ compatibilityDate: "2024-04-03",
25
26
  typescript: {
26
27
  builder: "shared"
27
28
  },
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
  import { consola } from 'consola';
4
- import { n as name, d as description, v as version } from './shared/module-builder.297ff45d.mjs';
4
+ import { n as name, d as description, v as version } from './shared/module-builder.026bb30a.mjs';
5
5
 
6
6
  const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
7
7
  const main = defineCommand({
package/dist/index.mjs CHANGED
@@ -11,4 +11,4 @@ import 'magic-regexp';
11
11
  import 'consola';
12
12
  import 'mlly';
13
13
  import 'citty';
14
- import './shared/module-builder.297ff45d.mjs';
14
+ import './shared/module-builder.026bb30a.mjs';
@@ -1,5 +1,5 @@
1
1
  const name = "@nuxt/module-builder";
2
- const version = "0.8.0";
2
+ const version = "0.8.2";
3
3
  const description = "Complete solution for building Nuxt modules";
4
4
 
5
5
  export { description as d, name as n, version as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/module-builder",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "repository": "nuxt/module-builder",
5
5
  "description": "Complete solution for building Nuxt modules",
6
6
  "license": "MIT",
@@ -19,18 +19,6 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "scripts": {
23
- "build": "unbuild",
24
- "dev:prepare": "pnpm -r dev:prepare",
25
- "example:build": "pnpm nuxt-module-build build ./example",
26
- "lint": "eslint .",
27
- "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
28
- "prepack": "pnpm build",
29
- "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
30
- "test": "pnpm vitest",
31
- "test:types": "vue-tsc --noEmit && pnpm -r test:types"
32
- },
33
- "packageManager": "pnpm@9.4.0",
34
22
  "dependencies": {
35
23
  "citty": "^0.1.6",
36
24
  "consola": "^3.2.3",
@@ -38,33 +26,43 @@
38
26
  "magic-regexp": "^0.8.0",
39
27
  "mlly": "^1.7.1",
40
28
  "pathe": "^1.1.2",
41
- "pkg-types": "^1.1.1",
42
- "tsconfck": "^3.1.0",
29
+ "pkg-types": "^1.1.3",
30
+ "tsconfck": "^3.1.1",
43
31
  "unbuild": "^2.0.0"
44
32
  },
45
33
  "peerDependencies": {
46
- "@nuxt/kit": "^3.12.2",
34
+ "@nuxt/kit": "^3.12.4",
47
35
  "nuxi": "^3.12.0"
48
36
  },
49
37
  "devDependencies": {
50
- "@nuxt/eslint-config": "^0.3.13",
51
- "@nuxt/kit": "^3.12.2",
52
- "@nuxt/schema": "^3.12.2",
53
- "@types/node": "^20.14.5",
54
- "@vitest/coverage-v8": "^1.6.0",
38
+ "@nuxt/eslint-config": "^0.5.0",
39
+ "@nuxt/kit": "^3.12.4",
40
+ "@nuxt/schema": "^3.12.4",
41
+ "@types/node": "^20.14.15",
42
+ "@vitest/coverage-v8": "^2.0.5",
55
43
  "changelogen": "^0.5.5",
56
- "eslint": "^9.5.0",
44
+ "eslint": "^9.9.0",
57
45
  "jiti": "^1.21.6",
58
46
  "nuxi": "^3.12.0",
59
- "nuxt": "^3.12.2",
60
- "typescript": "^5.4.5",
61
- "vitest": "^1.6.0",
62
- "vue": "^3.4.29",
63
- "vue-tsc": "^2.0.21"
47
+ "nuxt": "^3.12.4",
48
+ "typescript": "^5.5.4",
49
+ "vitest": "^2.0.5",
50
+ "vue": "^3.4.37",
51
+ "vue-tsc": "^2.0.29"
64
52
  },
65
53
  "resolutions": {
66
- "@nuxt/kit": "^3.12.2",
67
- "@nuxt/schema": "^3.12.2",
68
- "vue": "^3.4.29"
54
+ "@nuxt/kit": "^3.12.4",
55
+ "@nuxt/schema": "^3.12.4",
56
+ "vue": "^3.4.37"
57
+ },
58
+ "scripts": {
59
+ "build": "unbuild",
60
+ "dev:prepare": "pnpm -r dev:prepare",
61
+ "example:build": "pnpm nuxt-module-build build ./example",
62
+ "lint": "eslint .",
63
+ "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
64
+ "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
65
+ "test": "pnpm vitest",
66
+ "test:types": "vue-tsc --noEmit && pnpm -r test:types"
69
67
  }
70
- }
68
+ }