@nuxt/module-builder 1.0.0-alpha.1 → 1.0.0-alpha.3

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,6 +1,6 @@
1
- import { promises, existsSync } from 'node:fs';
1
+ import { existsSync, promises } from 'node:fs';
2
2
  import { pathToFileURL } from 'node:url';
3
- import { resolve, basename, normalize, join, dirname } from 'pathe';
3
+ import { resolve, basename, normalize, extname, join, dirname } from 'pathe';
4
4
  import { filename } from 'pathe/utils';
5
5
  import { readPackageJSON } from 'pkg-types';
6
6
  import { parse } from 'tsconfck';
@@ -8,10 +8,10 @@ import { defu } from 'defu';
8
8
  import { createJiti } from 'jiti';
9
9
  import { createRegExp, anyOf } from 'magic-regexp';
10
10
  import { consola } from 'consola';
11
- import { resolvePath, findExports } from 'mlly';
11
+ import { resolvePath, findExports, findTypeExports } from 'mlly';
12
12
  import { defineCommand } from 'citty';
13
13
  import { convertCompilerOptionsFromJson } from 'typescript';
14
- import { n as name, v as version } from '../shared/module-builder.D3Pp640p.mjs';
14
+ import { v as version, n as name } from '../shared/module-builder.CwnXQdBM.mjs';
15
15
 
16
16
  const build = defineCommand({
17
17
  meta: {
@@ -124,9 +124,10 @@ const build = defineCommand({
124
124
  return;
125
125
  const normalizedId = normalize(resolved.id);
126
126
  for (const entry2 of runtimeEntries) {
127
- if (!normalizedId.includes(entry2.input))
127
+ if (!entry2.outDir || !normalizedId.includes(entry2.input))
128
128
  continue;
129
- const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry2.input, entry2.outDir)), filename(normalizedId)));
129
+ const name2 = filename(normalizedId) || basename(normalizedId, extname(normalizedId));
130
+ const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry2.input, entry2.outDir)), name2));
130
131
  if (distFile) {
131
132
  return {
132
133
  external: true,
@@ -167,14 +168,14 @@ const build = defineCommand({
167
168
  async "build:done"(ctx) {
168
169
  const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
169
170
  if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
170
- consola.warn(`\`@nuxt/module-builder\` no longer supports Node10 TypeScript module resolution and will no longer generate \`.d.ts\` declaration files. You can update these paths to use the \`.d.mts\` extension instead.`);
171
+ consola.warn(`\`@nuxt/module-builder\` will no longer generate \`.d.ts\` declaration files. You can update these paths to use the \`.d.mts\` extension instead.`);
171
172
  }
172
173
  if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) {
173
174
  consola.warn(`\`@nuxt/module-builder\` will no longer generate \`module.cjs\` as this is not required for Nuxt v3+. You can safely remove replace this with \`module.mjs\` in your \`package.json\`.`);
174
175
  }
175
176
  const pkg = await readPackageJSON(cwd);
176
177
  if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) {
177
- consola.warn(`Please remove the \`types\` field from package.json as it is no longer required for Bundler TypeScript module resolution.`);
178
+ consola.warn(`Please remove the \`types\` field from package.json as it is no longer required for Bundler TypeScript module resolution. Instead, you can use \`typesVersions\` to support subpath export types for Node10, if required.`);
178
179
  }
179
180
  }
180
181
  }
@@ -194,6 +195,9 @@ async function writeTypes(distDir, isStub) {
194
195
  for (const e of findExports(normalisedModuleTypes)) {
195
196
  moduleReExports.push(e);
196
197
  }
198
+ for (const i of findTypeExports(normalisedModuleTypes)) {
199
+ moduleReExports.push(i);
200
+ }
197
201
  }
198
202
  const appShims = [];
199
203
  const schemaShims = [];
@@ -238,8 +242,10 @@ ${schemaShims.join("\n")}
238
242
  ${moduleExports.length ? `
239
243
  ${moduleExports.join("\n")}` : ""}
240
244
  ${isStub ? 'export * from "./module.mjs"' : ""}
241
- ${moduleReExports[0] ? `
242
- export { ${moduleReExports[0].names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from './module.mjs'` : ""}
245
+ ${moduleReExports.filter((e) => e.type === "named" || e.type === "default").map((e) => `
246
+ export { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
247
+ ${moduleReExports.filter((e) => e.type === "star").map((e) => `
248
+ export * from '${e.specifier || "./module.mjs"}'`).join("\n")}
243
249
  `.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
244
250
  await promises.writeFile(dtsFile, dtsContents, "utf8");
245
251
  }
@@ -18,7 +18,7 @@ const prepare = defineCommand({
18
18
  }
19
19
  },
20
20
  async run(context) {
21
- const { runCommand } = await import('nuxi');
21
+ const { runCommand } = await import('@nuxt/cli');
22
22
  const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
23
23
  return runCommand("prepare", [cwd], {
24
24
  overrides: {
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.D3Pp640p.mjs';
4
+ import { v as version, d as description, n as name } from './shared/module-builder.CwnXQdBM.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
@@ -13,4 +13,4 @@ import 'consola';
13
13
  import 'mlly';
14
14
  import 'citty';
15
15
  import 'typescript';
16
- import './shared/module-builder.D3Pp640p.mjs';
16
+ import './shared/module-builder.CwnXQdBM.mjs';
@@ -1,5 +1,5 @@
1
1
  const name = "@nuxt/module-builder";
2
- const version = "1.0.0-alpha.1";
2
+ const version = "1.0.0-alpha.3";
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,17 +1,24 @@
1
1
  {
2
2
  "name": "@nuxt/module-builder",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "repository": "nuxt/module-builder",
5
5
  "description": "Complete solution for building Nuxt modules",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
9
- ".": {
10
- "import": "./dist/index.mjs"
11
- },
9
+ ".": "./dist/index.mjs",
12
10
  "./package.json": "./package.json"
13
11
  },
14
- "types": "./dist/index.d.ts",
12
+ "typesVersions": {
13
+ "*": {
14
+ "*": [
15
+ "./dist/*.d.mts"
16
+ ],
17
+ "package.json": [
18
+ "package.json"
19
+ ]
20
+ }
21
+ },
15
22
  "bin": {
16
23
  "nuxt-build-module": "./dist/cli.mjs",
17
24
  "nuxt-module-build": "./dist/cli.mjs"
@@ -19,52 +26,69 @@
19
26
  "files": [
20
27
  "dist"
21
28
  ],
29
+ "scripts": {
30
+ "build": "unbuild",
31
+ "dev:prepare": "unbuild --stub && pnpm -r dev:prepare",
32
+ "example:build": "pnpm nuxt-module-build build ./example",
33
+ "lint": "eslint .",
34
+ "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
35
+ "prepack": "pnpm build",
36
+ "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
37
+ "test": "pnpm vitest --coverage",
38
+ "test:attw": "attw --pack example && attw --pack .",
39
+ "test:publint": "cd example && publint",
40
+ "test:engines": "installed-check -d --no-workspaces",
41
+ "test:knip": "knip --exclude unresolved",
42
+ "test:types": "vue-tsc --noEmit && pnpm -r test:types"
43
+ },
44
+ "packageManager": "pnpm@10.7.1",
22
45
  "dependencies": {
23
46
  "citty": "^0.1.6",
24
- "consola": "^3.3.3",
47
+ "consola": "^3.4.2",
25
48
  "defu": "^6.1.4",
26
49
  "jiti": "^2.4.2",
27
50
  "magic-regexp": "^0.8.0",
28
- "mlly": "^1.7.3",
29
- "pathe": "^2.0.0",
30
- "pkg-types": "^1.3.0",
31
- "tsconfck": "^3.1.4",
32
- "unbuild": "^3.2.0"
51
+ "mkdist": "^2.3.0",
52
+ "mlly": "^1.7.4",
53
+ "pathe": "^2.0.3",
54
+ "pkg-types": "^2.1.0",
55
+ "tsconfck": "^3.1.5",
56
+ "unbuild": "^3.5.0",
57
+ "vue-sfc-transformer": "^0.1.2"
33
58
  },
34
59
  "peerDependencies": {
35
- "nuxi": "^3.18.2",
36
- "typescript": "^5.7.2"
60
+ "@nuxt/cli": "^3.24.1",
61
+ "typescript": "^5.8.2"
37
62
  },
38
63
  "devDependencies": {
39
- "@nuxt/eslint-config": "^0.7.4",
40
- "@nuxt/schema": "^3.15.1",
41
- "@types/node": "^22.10.5",
42
- "@vitest/coverage-v8": "^2.1.8",
43
- "changelogen": "^0.5.7",
44
- "eslint": "^9.17.0",
45
- "nuxi": "^3.18.2",
46
- "nuxt": "^3.15.1",
47
- "tinyexec": "^0.3.2",
48
- "typescript": "~5.7.2",
49
- "vitest": "^2.1.8",
64
+ "@arethetypeswrong/cli": "^0.17.4",
65
+ "@nuxt/cli": "^3.24.1",
66
+ "@nuxt/eslint-config": "^1.3.0",
67
+ "@nuxt/schema": "^3.16.2",
68
+ "@types/node": "^22.14.0",
69
+ "@vitest/coverage-v8": "^3.1.1",
70
+ "changelogen": "^0.6.1",
71
+ "eslint": "^9.23.0",
72
+ "installed-check": "^9.3.0",
73
+ "knip": "^5.46.5",
74
+ "nuxt": "^3.16.2",
75
+ "pkg-pr-new": "^0.0.42",
76
+ "publint": "^0.3.10",
77
+ "tinyexec": "^1.0.1",
78
+ "typescript": "~5.8.2",
79
+ "vitest": "^3.1.1",
50
80
  "vue": "^3.5.13",
51
- "vue-tsc": "^2.2.0"
81
+ "vue-tsc": "^2.2.8"
52
82
  },
53
83
  "resolutions": {
54
- "@nuxt/kit": "^3.15.1",
55
- "@nuxt/schema": "^3.15.1",
56
- "typescript": "^5.7.2",
84
+ "@nuxt/kit": "^3.16.2",
85
+ "@nuxt/module-builder": "workspace:*",
86
+ "@nuxt/schema": "^3.16.2",
87
+ "typescript": "~5.8.2",
57
88
  "vue": "^3.5.13",
58
- "vue-tsc": "^2.2.0"
89
+ "vue-tsc": "^2.2.8"
59
90
  },
60
- "scripts": {
61
- "build": "unbuild",
62
- "dev:prepare": "pnpm -r dev:prepare",
63
- "example:build": "pnpm nuxt-module-build build ./example",
64
- "lint": "eslint .",
65
- "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
66
- "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
67
- "test": "pnpm vitest --coverage",
68
- "test:types": "vue-tsc --noEmit && pnpm -r test:types"
91
+ "engines": {
92
+ "node": "^18.0.0 || >=20.0.0"
69
93
  }
70
- }
94
+ }