@nuxt/module-builder 0.5.5 → 0.6.0

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.
@@ -1,9 +1,12 @@
1
- import { promises, existsSync } from 'fs';
2
- import { pathToFileURL } from 'url';
3
- import { resolve } from 'pathe';
1
+ import { promises, existsSync } from 'node:fs';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { resolve, dirname } from 'pathe';
4
+ import { readPackageJSON, readTSConfig } from 'pkg-types';
5
+ import { defu } from 'defu';
4
6
  import { consola } from 'consola';
5
7
  import { findExports } from 'mlly';
6
8
  import { defineCommand } from 'citty';
9
+ import { n as name, v as version } from '../shared/module-builder.342fba3e.mjs';
7
10
 
8
11
  const build = defineCommand({
9
12
  meta: {
@@ -41,7 +44,16 @@ const build = defineCommand({
41
44
  outDir,
42
45
  entries: [
43
46
  "src/module",
44
- { input: "src/runtime/", outDir: `${outDir}/runtime`, ext: "mjs" }
47
+ {
48
+ input: "src/runtime/",
49
+ outDir: `${outDir}/runtime`,
50
+ ext: "mjs",
51
+ esbuild: {
52
+ jsxImportSource: "vue",
53
+ jsx: "automatic",
54
+ jsxFactory: "h"
55
+ }
56
+ }
45
57
  ],
46
58
  rollup: {
47
59
  esbuild: {
@@ -51,17 +63,26 @@ const build = defineCommand({
51
63
  cjsBridge: true
52
64
  },
53
65
  externals: [
66
+ /src\/runtime/,
54
67
  "@nuxt/schema",
68
+ "@nuxt/schema-nightly",
55
69
  "@nuxt/schema-edge",
56
70
  "@nuxt/kit",
71
+ "@nuxt/kit-nightly",
57
72
  "@nuxt/kit-edge",
58
73
  "nuxt",
74
+ "nuxt-nightly",
59
75
  "nuxt-edge",
60
76
  "nuxt3",
61
77
  "vue",
62
78
  "vue-demi"
63
79
  ],
64
80
  hooks: {
81
+ async "mkdist:entry:options"(_ctx, _entry, options) {
82
+ options.typescript = defu(options.typescript, {
83
+ compilerOptions: await loadTSCompilerOptions(cwd)
84
+ });
85
+ },
65
86
  async "rollup:done"(ctx) {
66
87
  await writeCJSStub(ctx.options.outDir);
67
88
  const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
@@ -82,6 +103,10 @@ const build = defineCommand({
82
103
  moduleMeta.version = ctx.pkg.version;
83
104
  }
84
105
  }
106
+ moduleMeta.builder = {
107
+ [name]: version,
108
+ unbuild: await readPackageJSON("unbuild").then((r) => r.version).catch(() => "unknown")
109
+ };
85
110
  const metaFile = resolve(ctx.options.outDir, "module.json");
86
111
  await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
87
112
  await writeTypes(ctx.options.outDir, moduleMeta);
@@ -109,7 +134,7 @@ async function writeTypes(distDir, meta) {
109
134
  const appShims = [];
110
135
  const schemaShims = [];
111
136
  const moduleImports = [];
112
- const hasTypeExport = (name) => isStub || typeExports.find((exp) => exp.names.includes(name));
137
+ const hasTypeExport = (name2) => isStub || typeExports.find((exp) => exp.names.includes(name2));
113
138
  if (meta.configKey && hasTypeExport("ModuleOptions")) {
114
139
  moduleImports.push("ModuleOptions");
115
140
  schemaShims.push(` interface NuxtConfig { ['${meta.configKey}']?: Partial<ModuleOptions> }`);
@@ -119,12 +144,8 @@ async function writeTypes(distDir, meta) {
119
144
  moduleImports.push("ModuleHooks");
120
145
  schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
121
146
  }
122
- if (hasTypeExport("RuntimeModuleHooks") || hasTypeExport("ModuleRuntimeHooks")) {
147
+ if (hasTypeExport("ModuleRuntimeHooks")) {
123
148
  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
149
  if (hasTypeExport("ModuleRuntimeHooks")) {
129
150
  runtimeHooksInterfaces.push("ModuleRuntimeHooks");
130
151
  }
@@ -154,12 +175,12 @@ ${schemaShims.length ? `declare module 'nuxt/schema' {
154
175
  ${schemaShims.join("\n")}
155
176
  }
156
177
  ` : ""}
157
-
158
- export type { ${typeExports[0].names.join(", ")} } from './module'
178
+ ${typeExports[0] ? `
179
+ export type { ${typeExports[0].names.join(", ")} } from './module'` : ""}
159
180
  `;
160
181
  await promises.writeFile(dtsFile, dtsContents, "utf8");
161
182
  if (!existsSync(dtsFileMts)) {
162
- await promises.writeFile(dtsFileMts, dtsContents.replaceAll("./module", "./module.js"), "utf8");
183
+ await promises.writeFile(dtsFileMts, dtsContents.replace(/\.\/module/g, "./module.js"), "utf8");
163
184
  }
164
185
  }
165
186
  async function writeCJSStub(distDir) {
@@ -175,5 +196,21 @@ module.exports.getMeta = () => Promise.resolve(_meta)
175
196
  `;
176
197
  await promises.writeFile(cjsStubFile, cjsStub, "utf8");
177
198
  }
199
+ async function loadTSCompilerOptions(path) {
200
+ const config = await readTSConfig(path).catch(() => {
201
+ });
202
+ if (!config)
203
+ return [];
204
+ config.compilerOptions || (config.compilerOptions = {});
205
+ for (const alias in config.compilerOptions.paths || {}) {
206
+ config.compilerOptions.paths[alias] = config.compilerOptions.paths[alias].map((p) => {
207
+ if (!/^\.{1,2}(\/|$)/.test(p))
208
+ return p;
209
+ return resolve(path, p);
210
+ });
211
+ }
212
+ const files = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
213
+ return defu(config.compilerOptions, ...await Promise.all(files.map((file) => loadTSCompilerOptions(dirname(resolve(path, file))))));
214
+ }
178
215
 
179
216
  export { build as default };
package/dist/cli.mjs CHANGED
@@ -1,12 +1,9 @@
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.342fba3e.mjs';
4
5
 
5
- const name = "@nuxt/module-builder";
6
- const version = "0.5.5";
7
- const description = "Complete solution for building Nuxt modules";
8
-
9
- const _rDefault = (r) => r.default || r;
6
+ const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
10
7
  const main = defineCommand({
11
8
  meta: {
12
9
  name,
@@ -19,7 +16,7 @@ const main = defineCommand({
19
16
  },
20
17
  setup(context) {
21
18
  const firstArg = context.rawArgs[0];
22
- if (context.cmd.subCommands && !(firstArg in context.cmd.subCommands)) {
19
+ if (context.cmd.subCommands && !(firstArg && firstArg in context.cmd.subCommands)) {
23
20
  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
21
  context.rawArgs.unshift("build");
25
22
  }
package/dist/index.mjs CHANGED
@@ -1,8 +1,11 @@
1
1
  export { default as build } from './chunks/build.mjs';
2
2
  export { default as prepare } from './chunks/prepare.mjs';
3
- import 'fs';
4
- import 'url';
3
+ import 'node:fs';
4
+ import 'node:url';
5
5
  import 'pathe';
6
+ import 'pkg-types';
7
+ import 'defu';
6
8
  import 'consola';
7
9
  import 'mlly';
8
10
  import 'citty';
11
+ import './shared/module-builder.342fba3e.mjs';
@@ -0,0 +1,5 @@
1
+ const name = "@nuxt/module-builder";
2
+ const version = "0.6.0";
3
+ const description = "Complete solution for building Nuxt modules";
4
+
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.5.5",
3
+ "version": "0.6.0",
4
4
  "repository": "nuxt/module-builder",
5
5
  "description": "Complete solution for building Nuxt modules",
6
6
  "license": "MIT",
@@ -19,38 +19,50 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "packageManager": "pnpm@8.12.1",
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.0.6",
23
34
  "dependencies": {
24
- "citty": "^0.1.5",
35
+ "citty": "^0.1.6",
25
36
  "consola": "^3.2.3",
26
- "mlly": "^1.4.2",
27
- "pathe": "^1.1.1",
37
+ "defu": "^6.1.4",
38
+ "mlly": "^1.6.1",
39
+ "pathe": "^1.1.2",
40
+ "pkg-types": "^1.1.0",
28
41
  "unbuild": "^2.0.0"
29
42
  },
30
43
  "peerDependencies": {
31
- "@nuxt/kit": "^3.8.2",
32
- "nuxi": "^3.10.0"
44
+ "@nuxt/kit": "^3.11.2",
45
+ "nuxi": "^3.11.1"
33
46
  },
34
47
  "devDependencies": {
35
- "@nuxt/kit": "^3.8.2",
36
- "@nuxt/schema": "^3.8.2",
37
- "@nuxtjs/eslint-config-typescript": "^12.1.0",
38
- "@types/node": "^20.10.5",
39
- "@vitest/coverage-v8": "^1.1.0",
48
+ "@nuxt/eslint-config": "^0.3.10",
49
+ "@nuxt/kit": "^3.11.2",
50
+ "@nuxt/schema": "^3.11.2",
51
+ "@types/node": "^20.12.7",
52
+ "@vitest/coverage-v8": "^1.5.2",
40
53
  "changelogen": "^0.5.5",
41
- "eslint": "^8.56.0",
54
+ "eslint": "^9.1.1",
42
55
  "jiti": "^1.21.0",
43
- "nuxi": "^3.10.0",
44
- "nuxt": "^3.8.2",
45
- "vitest": "^1.1.0"
56
+ "nuxi": "^3.11.1",
57
+ "nuxt": "^3.11.2",
58
+ "typescript": "^5.4.5",
59
+ "vitest": "^1.5.2",
60
+ "vue": "^3.4.25",
61
+ "vue-tsc": "^2.0.14"
46
62
  },
47
- "scripts": {
48
- "build": "unbuild",
49
- "example:build": "pnpm nuxt-module-build build ./example",
50
- "lint": "eslint --ext .ts,.js,.mjs .",
51
- "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
52
- "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
53
- "test": "pnpm vitest",
54
- "test:types": "tsc --noEmit && pnpm -r test:types"
63
+ "resolutions": {
64
+ "@nuxt/kit": "^3.11.2",
65
+ "@nuxt/schema": "^3.11.2",
66
+ "vue": "^3.4.25"
55
67
  }
56
- }
68
+ }