@nuxt/module-builder 1.0.3 → 1.0.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.
@@ -0,0 +1,29 @@
1
+ import { resolve } from "pathe";
2
+ // \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, flags) => {
5
+ let target = Object.setPrototypeOf({}, null);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return flags & 2 ? target : Object.preventExtensions(target);
12
+ };
13
+ // src/commands/_shared.ts
14
+ const sharedArgs = {
15
+ cwd: {
16
+ type: "string",
17
+ valueHint: "directory",
18
+ description: "Specify the working directory, this takes precedence over ROOTDIR (default: `.`)",
19
+ default: void 0
20
+ },
21
+ rootDir: {
22
+ type: "positional",
23
+ description: "Specifies the working directory (default: `.`)",
24
+ required: false,
25
+ default: "."
26
+ }
27
+ };
28
+ const resolveCwdArg = (args) => resolve(args.cwd || args.rootDir || ".");
29
+ export { sharedArgs as n, __exportAll as r, resolveCwdArg as t };
@@ -1,6 +1,5 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { n as name, r as version } from "./package-1Cra3U-o.mjs";
3
- import { n as sharedArgs, t as resolveCwdArg } from "./_shared-CfHVT2WD.mjs";
1
+ import { t as package_default } from "./package-DWT6Tk83.mjs";
2
+ import { n as sharedArgs, r as __exportAll, t as resolveCwdArg } from "./_shared-D4Ti9utg.mjs";
4
3
  import { defineCommand } from "citty";
5
4
  import { consola } from "consola";
6
5
  import { existsSync, promises } from "node:fs";
@@ -8,14 +7,15 @@ import { pathToFileURL } from "node:url";
8
7
  import { basename, dirname, extname, join, normalize, resolve } from "pathe";
9
8
  import { filename } from "pathe/utils";
10
9
  import { readPackageJSON } from "pkg-types";
11
- import { parse } from "tsconfck";
10
+ import { createPathsMatcher, getTsconfig } from "get-tsconfig";
12
11
  import { defu } from "defu";
13
12
  import { createJiti } from "jiti";
14
13
  import { anyOf, createRegExp } from "magic-regexp";
15
14
  import { findExports, findTypeExports, resolvePath } from "mlly";
16
15
  import { convertCompilerOptionsFromJson } from "typescript";
17
- //#region src/commands/build.ts
16
+ // src/commands/build.ts
18
17
  var build_exports = /* @__PURE__ */ __exportAll({ default: () => build_default });
18
+ const { name, version } = package_default;
19
19
  var build_default = defineCommand({
20
20
  meta: {
21
21
  name: "build",
@@ -89,19 +89,20 @@ var build_default = defineCommand({
89
89
  ],
90
90
  hooks: {
91
91
  async "mkdist:entry:options"(_ctx, entry, options) {
92
- options.typescript = defu(options.typescript, { compilerOptions: await loadTSCompilerOptions(entry.input) });
92
+ options.typescript = defu(options.typescript, { compilerOptions: loadTSCompilerOptions(entry.input) });
93
93
  },
94
94
  async "rollup:options"(ctx, options) {
95
95
  const [entry] = ctx.buildEntries;
96
96
  const mergedCompilerOptions = defu({
97
97
  noEmit: false,
98
98
  paths: { "#app/nuxt": ["./node_modules/nuxt/dist/app/nuxt"] }
99
- }, ctx.options.rollup.dts.compilerOptions, await loadTSCompilerOptions(entry.path));
99
+ }, ctx.options.rollup.dts.compilerOptions, loadTSCompilerOptions(entry.path));
100
100
  ctx.options.rollup.dts.compilerOptions = convertCompilerOptionsFromJson(mergedCompilerOptions, entry.path).options;
101
101
  options.plugins ||= [];
102
102
  if (!Array.isArray(options.plugins)) options.plugins = [options.plugins];
103
103
  const runtimeEntries = ctx.options.entries.filter((entry) => entry.builder === "mkdist");
104
- const RUNTIME_RE = createRegExp(anyOf(...runtimeEntries.map((entry) => basename(entry.input))).and(anyOf("/", "\\")));
104
+ const runtimeDirs = runtimeEntries.map((entry) => basename(entry.input));
105
+ const RUNTIME_RE = createRegExp(anyOf(...runtimeDirs).and(anyOf("/", "\\")));
105
106
  options.plugins.unshift({
106
107
  name: "nuxt-module-builder:runtime-externals",
107
108
  async resolveId(id, importer) {
@@ -112,7 +113,7 @@ var build_default = defineCommand({
112
113
  for (const entry of runtimeEntries) {
113
114
  if (!entry.outDir || !normalizedId.includes(entry.input)) continue;
114
115
  const name = filename(normalizedId) || basename(normalizedId, extname(normalizedId));
115
- const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry.input, entry.outDir)), name));
116
+ const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId.replace(entry.input, entry.outDir)).href), name));
116
117
  if (distFile) return {
117
118
  external: true,
118
119
  id: distFile
@@ -141,6 +142,7 @@ var build_default = defineCommand({
141
142
  const metaFile = resolve(ctx.options.outDir, "module.json");
142
143
  await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
143
144
  await writeTypes(ctx.options.outDir, ctx.options.stub);
145
+ if (!ctx.options.stub) await rewriteRuntimeTypeAliases(resolve(ctx.options.outDir, "runtime"));
144
146
  },
145
147
  async "build:done"(ctx) {
146
148
  const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
@@ -204,14 +206,23 @@ ${moduleReExports.filter((e) => e.type === "star").map((e) => `\nexport * from '
204
206
  `.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
205
207
  await promises.writeFile(dtsFile, dtsContents, "utf8");
206
208
  }
207
- async function loadTSCompilerOptions(path) {
208
- const config = await parse(path);
209
- const resolvedCompilerOptions = config?.tsconfig.compilerOptions || {};
210
- for (const { tsconfig, tsconfigFile } of config.extended || []) for (const alias in tsconfig.compilerOptions?.paths || {}) resolvedCompilerOptions.paths[alias] = resolvedCompilerOptions.paths[alias].map((p) => {
211
- if (!/^\.{1,2}(?:\/|$)/.test(p)) return p;
212
- return resolve(dirname(tsconfigFile), p);
213
- });
214
- return resolvedCompilerOptions;
209
+ const DECLARATION_RE = /\.d\.[^/]*ts$/;
210
+ async function rewriteRuntimeTypeAliases(runtimeDir) {
211
+ if (!existsSync(runtimeDir)) return;
212
+ const entries = await promises.readdir(runtimeDir, { recursive: true });
213
+ await Promise.all(entries.map(async (entry) => {
214
+ if (!DECLARATION_RE.test(entry)) return;
215
+ const file = join(runtimeDir, entry);
216
+ const contents = await promises.readFile(file, "utf8");
217
+ const rewritten = contents.replace(/import\("#app(?:\/[^"]*)?"\)/g, "import(\"nuxt/app\")").replace(/(\bfrom\s*)(['"])#app(?:\/[^'"]*)?\2/g, "$1$2nuxt/app$2");
218
+ if (rewritten !== contents) await promises.writeFile(file, rewritten, "utf8");
219
+ }));
220
+ }
221
+ function loadTSCompilerOptions(path) {
222
+ const tsconfig = getTsconfig(path);
223
+ const compilerOptions = tsconfig?.config.compilerOptions ?? {};
224
+ const matchPath = tsconfig && createPathsMatcher(tsconfig);
225
+ if (matchPath && compilerOptions.paths) for (const alias in compilerOptions.paths) compilerOptions.paths[alias] = matchPath(alias);
226
+ return compilerOptions;
215
227
  }
216
- //#endregion
217
228
  export { build_exports as n, build_default as t };
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.mjs CHANGED
@@ -1,18 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { n as name, r as version, t as description } from "./package-1Cra3U-o.mjs";
2
+ import { t as package_default } from "./package-DWT6Tk83.mjs";
3
3
  import { defineCommand, runMain } from "citty";
4
4
  import { consola } from "consola";
5
- //#region src/cli.ts
5
+ // src/cli.ts
6
+ const { name, description, version } = package_default;
6
7
  const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
7
- runMain(defineCommand({
8
+ const main = defineCommand({
8
9
  meta: {
9
10
  name,
10
11
  description,
11
12
  version
12
13
  },
13
14
  subCommands: {
14
- prepare: () => import("./prepare-DSOOmWt_.mjs").then((n) => n.n).then(_rDefault),
15
- build: () => import("./build-Ach6kRrL.mjs").then((n) => n.n).then(_rDefault)
15
+ prepare: () => import("./prepare-BOY08ZER.mjs").then((n) => n.n).then(_rDefault),
16
+ build: () => import("./build-CwsnoCho.mjs").then((n) => n.n).then(_rDefault)
16
17
  },
17
18
  setup(context) {
18
19
  const firstArg = context.rawArgs[0];
@@ -21,6 +22,6 @@ runMain(defineCommand({
21
22
  context.rawArgs.unshift("build");
22
23
  }
23
24
  }
24
- }));
25
- //#endregion
25
+ });
26
+ runMain(main);
26
27
  export {};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/commands/build.d.ts
2
1
  declare const _default: import("citty").CommandDef<{
3
2
  readonly outDir: {
4
3
  readonly type: "string";
@@ -28,8 +27,6 @@ declare const _default: import("citty").CommandDef<{
28
27
  readonly default: ".";
29
28
  };
30
29
  }>;
31
- //#endregion
32
- //#region src/commands/prepare.d.ts
33
30
  declare const _default$1: import("citty").CommandDef<{
34
31
  readonly cwd: {
35
32
  readonly type: "string";
@@ -44,5 +41,4 @@ declare const _default$1: import("citty").CommandDef<{
44
41
  readonly default: ".";
45
42
  };
46
43
  }>;
47
- //#endregion
48
44
  export { _default as build, _default$1 as prepare };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as build_default } from "./build-Ach6kRrL.mjs";
2
- import { t as prepare_default } from "./prepare-DSOOmWt_.mjs";
1
+ import { t as build_default } from "./build-CwsnoCho.mjs";
2
+ import { t as prepare_default } from "./prepare-BOY08ZER.mjs";
3
3
  export { build_default as build, prepare_default as prepare };
@@ -0,0 +1,92 @@
1
+ // package.json
2
+ var package_default = {
3
+ name: "@nuxt/module-builder",
4
+ version: "1.0.4",
5
+ repository: "nuxt/module-builder",
6
+ description: "Complete solution for building Nuxt modules",
7
+ license: "MIT",
8
+ type: "module",
9
+ exports: {
10
+ ".": "./dist/index.mjs",
11
+ "./package.json": "./package.json"
12
+ },
13
+ typesVersions: { "*": {
14
+ "*": ["./dist/*.d.mts"],
15
+ "package.json": ["package.json"]
16
+ } },
17
+ bin: {
18
+ "nuxt-build-module": "./dist/cli.mjs",
19
+ "nuxt-module-build": "./dist/cli.mjs"
20
+ },
21
+ files: ["dist"],
22
+ scripts: {
23
+ "build": "tsdown",
24
+ "dev:prepare": "pnpm -r dev:prepare",
25
+ "example:build": "pnpm nuxt-module-build build ./example",
26
+ "example:stub": "pnpm nuxt-module-build build --stub ./example",
27
+ "lint": "eslint .",
28
+ "nuxt-module-build": "node ./src/cli.ts",
29
+ "prepack": "pnpm build",
30
+ "test": "pnpm vitest --coverage",
31
+ "test:attw": "pnpm -C example pack --out ../.temp-attw/example.tgz && attw .temp-attw/example.tgz",
32
+ "test:publint": "cd example && publint",
33
+ "test:engines": "installed-check -d --no-workspaces --ignore @nuxt/cli",
34
+ "test:knip": "knip --exclude unresolved",
35
+ "test:types": "vue-tsc --noEmit && pnpm -r test:types"
36
+ },
37
+ devEngines: {
38
+ "runtime": {
39
+ "name": "node",
40
+ "version": "^26.13.0",
41
+ "onFail": "download"
42
+ },
43
+ "packageManager": {
44
+ "name": "pnpm",
45
+ "version": "12.18.0",
46
+ "onFail": "download"
47
+ }
48
+ },
49
+ dependencies: {
50
+ "citty": "^0.2.2",
51
+ "consola": "^3.4.2",
52
+ "defu": "^6.1.7",
53
+ "get-tsconfig": "^4.14.3",
54
+ "jiti": "^2.7.0",
55
+ "magic-regexp": "^0.11.2",
56
+ "mkdist": "^2.4.1",
57
+ "mlly": "^1.8.2",
58
+ "pathe": "^2.0.3",
59
+ "pkg-types": "^2.4.0",
60
+ "unbuild": "^3.6.1",
61
+ "vue-sfc-transformer": "^0.3.1"
62
+ },
63
+ peerDependencies: {
64
+ "@nuxt/cli": "^3.37.0 || ^4.0.0",
65
+ "typescript": "^5.9.3"
66
+ },
67
+ devDependencies: {
68
+ "@arethetypeswrong/cli": "^0.18.5",
69
+ "@arethetypeswrong/core": "^0.18.5",
70
+ "@nuxt/cli": "^4.0.3",
71
+ "@nuxt/eslint-config": "^1.17.0",
72
+ "@nuxt/schema": "~4.6.4",
73
+ "@types/node": "^26.6.6",
74
+ "@vitest/coverage-v8": "^5.1.0",
75
+ "eslint": "^10.14.0",
76
+ "installed-check": "^11.0.0",
77
+ "knip": "^6.44.2",
78
+ "nuxt": "~4.6.4",
79
+ "ofetch": "^1.5.1",
80
+ "pkg-pr-new": "^0.0.93",
81
+ "publint": "^0.3.25",
82
+ "tinyexec": "^1.3.1",
83
+ "tsdown": "^0.23.7",
84
+ "typescript": "~5.9.3",
85
+ "verkit": "^0.5.0",
86
+ "vitest": "^5.1.0",
87
+ "vue": "^3.5.45",
88
+ "vue-tsc": "^3.3.14"
89
+ },
90
+ engines: { "node": "^18.0.0 || >=20.0.0" }
91
+ };
92
+ export { package_default as t };
@@ -1,8 +1,7 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { n as sharedArgs, t as resolveCwdArg } from "./_shared-CfHVT2WD.mjs";
1
+ import { n as sharedArgs, r as __exportAll, t as resolveCwdArg } from "./_shared-D4Ti9utg.mjs";
3
2
  import { defineCommand } from "citty";
4
3
  import { resolve } from "pathe";
5
- //#region src/commands/prepare.ts
4
+ // src/commands/prepare.ts
6
5
  var prepare_exports = /* @__PURE__ */ __exportAll({ default: () => prepare_default });
7
6
  var prepare_default = defineCommand({
8
7
  meta: {
@@ -25,5 +24,4 @@ var prepare_default = defineCommand({
25
24
  } });
26
25
  }
27
26
  });
28
- //#endregion
29
27
  export { prepare_exports as n, prepare_default as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/module-builder",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "nuxt/module-builder"
@@ -29,46 +29,58 @@
29
29
  "files": [
30
30
  "dist"
31
31
  ],
32
+ "devEngines": {
33
+ "runtime": {
34
+ "name": "node",
35
+ "version": "^26.13.0",
36
+ "onFail": "download"
37
+ },
38
+ "packageManager": {
39
+ "name": "pnpm",
40
+ "version": "12.18.0",
41
+ "onFail": "download"
42
+ }
43
+ },
32
44
  "dependencies": {
33
45
  "citty": "^0.2.2",
34
46
  "consola": "^3.4.2",
35
47
  "defu": "^6.1.7",
48
+ "get-tsconfig": "^4.14.3",
36
49
  "jiti": "^2.7.0",
37
- "magic-regexp": "^0.11.0",
50
+ "magic-regexp": "^0.11.2",
38
51
  "mkdist": "^2.4.1",
39
52
  "mlly": "^1.8.2",
40
53
  "pathe": "^2.0.3",
41
- "pkg-types": "^2.3.1",
42
- "tsconfck": "^3.1.6",
54
+ "pkg-types": "^2.4.0",
43
55
  "unbuild": "^3.6.1",
44
- "vue-sfc-transformer": "^0.2.3"
56
+ "vue-sfc-transformer": "^0.3.1"
45
57
  },
46
58
  "peerDependencies": {
47
- "@nuxt/cli": "^3.37.0",
59
+ "@nuxt/cli": "^3.37.0 || ^4.0.0",
48
60
  "typescript": "^5.9.3"
49
61
  },
50
62
  "devDependencies": {
51
63
  "@arethetypeswrong/cli": "^0.18.5",
52
- "@nuxt/cli": "^3.37.0",
53
- "@nuxt/eslint-config": "^1.16.0",
54
- "@nuxt/schema": "~4.4.8",
55
- "@types/node": "^24.13.3",
56
- "@types/semver": "^7.7.1",
57
- "@vitest/coverage-v8": "^4.1.10",
58
- "eslint": "^10.7.0",
59
- "installed-check": "^10.0.1",
60
- "knip": "^6.27.0",
61
- "nuxt": "~4.4.8",
64
+ "@arethetypeswrong/core": "^0.18.5",
65
+ "@nuxt/cli": "^4.0.3",
66
+ "@nuxt/eslint-config": "^1.17.0",
67
+ "@nuxt/schema": "~4.6.4",
68
+ "@types/node": "^26.6.6",
69
+ "@vitest/coverage-v8": "^5.1.0",
70
+ "eslint": "^10.14.0",
71
+ "installed-check": "^11.0.0",
72
+ "knip": "^6.44.2",
73
+ "nuxt": "~4.6.4",
62
74
  "ofetch": "^1.5.1",
63
- "pkg-pr-new": "^0.0.78",
64
- "publint": "^0.3.21",
65
- "semver": "^7.8.5",
66
- "tinyexec": "^1.2.4",
67
- "tsdown": "^0.22.12",
75
+ "pkg-pr-new": "^0.0.93",
76
+ "publint": "^0.3.25",
77
+ "tinyexec": "^1.3.1",
78
+ "tsdown": "^0.23.7",
68
79
  "typescript": "~5.9.3",
69
- "vitest": "^4.1.10",
70
- "vue": "^3.5.40",
71
- "vue-tsc": "^3.3.7"
80
+ "verkit": "^0.5.0",
81
+ "vitest": "^5.1.0",
82
+ "vue": "^3.5.45",
83
+ "vue-tsc": "^3.3.14"
72
84
  },
73
85
  "engines": {
74
86
  "node": "^18.0.0 || >=20.0.0"
@@ -79,11 +91,11 @@
79
91
  "example:build": "pnpm nuxt-module-build build ./example",
80
92
  "example:stub": "pnpm nuxt-module-build build --stub ./example",
81
93
  "lint": "eslint .",
82
- "nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
94
+ "nuxt-module-build": "node ./src/cli.ts",
83
95
  "test": "pnpm vitest --coverage",
84
- "test:attw": "attw --pack example && attw --pack .",
96
+ "test:attw": "pnpm -C example pack --out ../.temp-attw/example.tgz && attw .temp-attw/example.tgz",
85
97
  "test:publint": "cd example && publint",
86
- "test:engines": "installed-check -d --no-workspaces",
98
+ "test:engines": "installed-check -d --no-workspaces --ignore @nuxt/cli",
87
99
  "test:knip": "knip --exclude unresolved",
88
100
  "test:types": "vue-tsc --noEmit && pnpm -r test:types"
89
101
  }
@@ -1,19 +0,0 @@
1
- import { resolve } from "pathe";
2
- //#region src/commands/_shared.ts
3
- const sharedArgs = {
4
- cwd: {
5
- type: "string",
6
- valueHint: "directory",
7
- description: "Specify the working directory, this takes precedence over ROOTDIR (default: `.`)",
8
- default: void 0
9
- },
10
- rootDir: {
11
- type: "positional",
12
- description: "Specifies the working directory (default: `.`)",
13
- required: false,
14
- default: "."
15
- }
16
- };
17
- const resolveCwdArg = (args) => resolve(args.cwd || args.rootDir || ".");
18
- //#endregion
19
- export { sharedArgs as n, resolveCwdArg as t };
@@ -1,6 +0,0 @@
1
- //#region package.json
2
- var name = "@nuxt/module-builder";
3
- var version = "1.0.3";
4
- var description = "Complete solution for building Nuxt modules";
5
- //#endregion
6
- export { name as n, version as r, description as t };
@@ -1,13 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
5
- for (var name in all) __defProp(target, name, {
6
- get: all[name],
7
- enumerable: true
8
- });
9
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
- return target;
11
- };
12
- //#endregion
13
- export { __exportAll as t };