@nuxt/module-builder 1.0.0-alpha.0 → 1.0.0-alpha.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.
@@ -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,9 +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
- import { n as name, v as version } from '../shared/module-builder.B6wMX_h6.mjs';
13
+ import { convertCompilerOptionsFromJson } from 'typescript';
14
+ import { v as version, n as name } from '../shared/module-builder.Contvvct.mjs';
14
15
 
15
16
  const build = defineCommand({
16
17
  meta: {
@@ -54,6 +55,13 @@ const build = defineCommand({
54
55
  outDir: `${outDir}/runtime`,
55
56
  addRelativeDeclarationExtensions: true,
56
57
  ext: "js",
58
+ pattern: [
59
+ "**",
60
+ "!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
61
+ // ignore storybook files
62
+ "!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
63
+ // ignore tests
64
+ ],
57
65
  esbuild: {
58
66
  jsxImportSource: "vue",
59
67
  jsx: "automatic",
@@ -76,6 +84,8 @@ const build = defineCommand({
76
84
  "@nuxt/kit",
77
85
  "@nuxt/kit-nightly",
78
86
  "@nuxt/kit-edge",
87
+ "#app",
88
+ "#app/nuxt",
79
89
  "nuxt",
80
90
  "nuxt-nightly",
81
91
  "nuxt-edge",
@@ -90,11 +100,19 @@ const build = defineCommand({
90
100
  });
91
101
  },
92
102
  async "rollup:options"(ctx, options) {
103
+ const [entry] = ctx.buildEntries;
104
+ const mergedCompilerOptions = defu({
105
+ noEmit: false,
106
+ paths: {
107
+ "#app/nuxt": ["./node_modules/nuxt/dist/app/nuxt"]
108
+ }
109
+ }, ctx.options.rollup.dts.compilerOptions, await loadTSCompilerOptions(entry.path));
110
+ ctx.options.rollup.dts.compilerOptions = convertCompilerOptionsFromJson(mergedCompilerOptions, entry.path).options;
93
111
  options.plugins ||= [];
94
112
  if (!Array.isArray(options.plugins))
95
113
  options.plugins = [options.plugins];
96
- const runtimeEntries = ctx.options.entries.filter((entry) => entry.builder === "mkdist");
97
- const runtimeDirs = runtimeEntries.map((entry) => basename(entry.input));
114
+ const runtimeEntries = ctx.options.entries.filter((entry2) => entry2.builder === "mkdist");
115
+ const runtimeDirs = runtimeEntries.map((entry2) => basename(entry2.input));
98
116
  const RUNTIME_RE = createRegExp(anyOf(...runtimeDirs).and(anyOf("/", "\\")));
99
117
  options.plugins.unshift({
100
118
  name: "nuxt-module-builder:runtime-externals",
@@ -105,10 +123,11 @@ const build = defineCommand({
105
123
  if (!resolved)
106
124
  return;
107
125
  const normalizedId = normalize(resolved.id);
108
- for (const entry of runtimeEntries) {
109
- if (!normalizedId.includes(entry.input))
126
+ for (const entry2 of runtimeEntries) {
127
+ if (!entry2.outDir || !normalizedId.includes(entry2.input))
110
128
  continue;
111
- const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry.input, entry.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));
112
131
  if (distFile) {
113
132
  return {
114
133
  external: true,
@@ -149,14 +168,14 @@ const build = defineCommand({
149
168
  async "build:done"(ctx) {
150
169
  const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
151
170
  if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
152
- 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.`);
153
172
  }
154
173
  if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) {
155
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\`.`);
156
175
  }
157
176
  const pkg = await readPackageJSON(cwd);
158
177
  if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) {
159
- 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.`);
160
179
  }
161
180
  }
162
181
  }
@@ -176,6 +195,9 @@ async function writeTypes(distDir, isStub) {
176
195
  for (const e of findExports(normalisedModuleTypes)) {
177
196
  moduleReExports.push(e);
178
197
  }
198
+ for (const i of findTypeExports(normalisedModuleTypes)) {
199
+ moduleReExports.push(i);
200
+ }
179
201
  }
180
202
  const appShims = [];
181
203
  const schemaShims = [];
@@ -220,8 +242,8 @@ ${schemaShims.join("\n")}
220
242
  ${moduleExports.length ? `
221
243
  ${moduleExports.join("\n")}` : ""}
222
244
  ${isStub ? 'export * from "./module.mjs"' : ""}
223
- ${moduleReExports[0] ? `
224
- export { ${moduleReExports[0].names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from './module.mjs'` : ""}
245
+ ${moduleReExports.map((e) => `
246
+ export { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
225
247
  `.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
226
248
  await promises.writeFile(dtsFile, dtsContents, "utf8");
227
249
  }
@@ -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.B6wMX_h6.mjs';
4
+ import { v as version, d as description, n as name } from './shared/module-builder.Contvvct.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
@@ -12,4 +12,5 @@ import 'magic-regexp';
12
12
  import 'consola';
13
13
  import 'mlly';
14
14
  import 'citty';
15
- import './shared/module-builder.B6wMX_h6.mjs';
15
+ import 'typescript';
16
+ import './shared/module-builder.Contvvct.mjs';
@@ -1,5 +1,5 @@
1
1
  const name = "@nuxt/module-builder";
2
- const version = "1.0.0-alpha.0";
2
+ const version = "1.0.0-alpha.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,17 +1,24 @@
1
1
  {
2
2
  "name": "@nuxt/module-builder",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.2",
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"
@@ -21,50 +28,67 @@
21
28
  ],
22
29
  "scripts": {
23
30
  "build": "unbuild",
24
- "dev:prepare": "pnpm -r dev:prepare",
31
+ "dev:prepare": "unbuild --stub && pnpm -r dev:prepare",
25
32
  "example:build": "pnpm nuxt-module-build build ./example",
26
33
  "lint": "eslint .",
27
34
  "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
28
35
  "prepack": "pnpm build",
29
36
  "release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
30
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",
31
42
  "test:types": "vue-tsc --noEmit && pnpm -r test:types"
32
43
  },
33
- "packageManager": "pnpm@9.15.0",
44
+ "packageManager": "pnpm@10.7.1",
34
45
  "dependencies": {
35
46
  "citty": "^0.1.6",
36
- "consola": "^3.2.3",
47
+ "consola": "^3.4.2",
37
48
  "defu": "^6.1.4",
38
- "jiti": "^2.4.1",
49
+ "jiti": "^2.4.2",
39
50
  "magic-regexp": "^0.8.0",
40
- "mlly": "^1.7.3",
41
- "pathe": "^1.1.2",
42
- "pkg-types": "^1.2.1",
43
- "tsconfck": "^3.1.4",
44
- "unbuild": "^3.0.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"
45
58
  },
46
59
  "peerDependencies": {
47
- "nuxi": "^3.16.0"
60
+ "@nuxt/cli": "^3.24.1",
61
+ "typescript": "^5.8.2"
48
62
  },
49
63
  "devDependencies": {
50
- "@nuxt/eslint-config": "^0.7.3",
51
- "@nuxt/schema": "^3.14.1592",
52
- "@types/node": "^22.10.2",
53
- "@vitest/coverage-v8": "^2.1.8",
54
- "changelogen": "^0.5.7",
55
- "eslint": "^9.16.0",
56
- "nuxi": "^3.16.0",
57
- "nuxt": "^3.14.1592",
58
- "tinyexec": "^0.3.1",
59
- "typescript": "~5.6.3",
60
- "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",
61
80
  "vue": "^3.5.13",
62
- "vue-tsc": "^2.1.10"
81
+ "vue-tsc": "^2.2.8"
63
82
  },
64
83
  "resolutions": {
65
- "@nuxt/kit": "^3.14.1592",
66
- "@nuxt/schema": "^3.14.1592",
67
- "typescript": "~5.6.3",
68
- "vue": "^3.5.13"
84
+ "@nuxt/kit": "^3.16.2",
85
+ "@nuxt/module-builder": "workspace:*",
86
+ "@nuxt/schema": "^3.16.2",
87
+ "typescript": "~5.8.2",
88
+ "vue": "^3.5.13",
89
+ "vue-tsc": "^2.2.8"
90
+ },
91
+ "engines": {
92
+ "node": "^18.0.0 || >=20.0.0"
69
93
  }
70
94
  }