@nuxt/module-builder 1.0.1 → 1.0.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.
- package/README.md +3 -3
- package/dist/_shared-CfHVT2WD.mjs +19 -0
- package/dist/build-Ach6kRrL.mjs +217 -0
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +24 -23
- package/dist/index.d.mts +46 -34
- package/dist/index.mjs +3 -16
- package/dist/package-1Cra3U-o.mjs +6 -0
- package/dist/prepare-DSOOmWt_.mjs +29 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +41 -43
- package/dist/chunks/build.mjs +0 -266
- package/dist/chunks/prepare.mjs +0 -47
- package/dist/cli.d.ts +0 -1
- package/dist/index.d.ts +0 -36
- package/dist/shared/module-builder.yvjrH2kb.mjs +0 -5
package/README.md
CHANGED
|
@@ -164,10 +164,10 @@ Module builder generates dist files in `dist/` directory:
|
|
|
164
164
|
[MIT](./LICENSE) - Made with 💚
|
|
165
165
|
|
|
166
166
|
<!-- Badges -->
|
|
167
|
-
[npm-version-src]: https://
|
|
168
|
-
[npm-version-href]: https://
|
|
167
|
+
[npm-version-src]: https://npmx.dev/api/registry/badge/version/@nuxt/module-builder
|
|
168
|
+
[npm-version-href]: https://npmx.dev/package/@nuxt/module-builder
|
|
169
169
|
|
|
170
|
-
[npm-downloads-src]: https://
|
|
170
|
+
[npm-downloads-src]: https://npmx.dev/api/registry/badge/downloads/@nuxt/module-builder
|
|
171
171
|
[npm-downloads-href]: https://npm.chart.dev/@nuxt/module-builder
|
|
172
172
|
|
|
173
173
|
[license-src]: https://img.shields.io/github/license/nuxt/module-builder.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
@@ -0,0 +1,19 @@
|
|
|
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 };
|
|
@@ -0,0 +1,217 @@
|
|
|
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";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
import { consola } from "consola";
|
|
6
|
+
import { existsSync, promises } from "node:fs";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { basename, dirname, extname, join, normalize, resolve } from "pathe";
|
|
9
|
+
import { filename } from "pathe/utils";
|
|
10
|
+
import { readPackageJSON } from "pkg-types";
|
|
11
|
+
import { parse } from "tsconfck";
|
|
12
|
+
import { defu } from "defu";
|
|
13
|
+
import { createJiti } from "jiti";
|
|
14
|
+
import { anyOf, createRegExp } from "magic-regexp";
|
|
15
|
+
import { findExports, findTypeExports, resolvePath } from "mlly";
|
|
16
|
+
import { convertCompilerOptionsFromJson } from "typescript";
|
|
17
|
+
//#region src/commands/build.ts
|
|
18
|
+
var build_exports = /* @__PURE__ */ __exportAll({ default: () => build_default });
|
|
19
|
+
var build_default = defineCommand({
|
|
20
|
+
meta: {
|
|
21
|
+
name: "build",
|
|
22
|
+
description: "Build module for distribution"
|
|
23
|
+
},
|
|
24
|
+
args: {
|
|
25
|
+
...sharedArgs,
|
|
26
|
+
outDir: {
|
|
27
|
+
type: "string",
|
|
28
|
+
default: "dist",
|
|
29
|
+
description: "Build directory"
|
|
30
|
+
},
|
|
31
|
+
sourcemap: {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
default: false,
|
|
34
|
+
description: "Generate sourcemaps"
|
|
35
|
+
},
|
|
36
|
+
stub: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
default: false,
|
|
39
|
+
description: "Stub dist instead of actually building it for development"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
async run(context) {
|
|
43
|
+
const { build } = await import("unbuild");
|
|
44
|
+
const cwd = resolveCwdArg(context.args);
|
|
45
|
+
const jiti = createJiti(cwd);
|
|
46
|
+
await build(cwd, false, {
|
|
47
|
+
declaration: "node16",
|
|
48
|
+
sourcemap: context.args.sourcemap,
|
|
49
|
+
stub: context.args.stub,
|
|
50
|
+
stubOptions: { absoluteJitiPath: true },
|
|
51
|
+
outDir: context.args.outDir,
|
|
52
|
+
entries: ["src/module", {
|
|
53
|
+
input: "src/runtime/",
|
|
54
|
+
outDir: `${context.args.outDir}/runtime`,
|
|
55
|
+
addRelativeDeclarationExtensions: true,
|
|
56
|
+
ext: "js",
|
|
57
|
+
pattern: [
|
|
58
|
+
"**",
|
|
59
|
+
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
|
60
|
+
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
|
61
|
+
],
|
|
62
|
+
esbuild: {
|
|
63
|
+
jsxImportSource: "vue",
|
|
64
|
+
jsx: "automatic",
|
|
65
|
+
jsxFactory: "h"
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
rollup: {
|
|
69
|
+
esbuild: { target: "esnext" },
|
|
70
|
+
emitCJS: false,
|
|
71
|
+
cjsBridge: false
|
|
72
|
+
},
|
|
73
|
+
externals: [
|
|
74
|
+
/dist[\\/]runtime[\\/]/,
|
|
75
|
+
"@nuxt/schema",
|
|
76
|
+
"@nuxt/schema-nightly",
|
|
77
|
+
"@nuxt/schema-edge",
|
|
78
|
+
"@nuxt/kit",
|
|
79
|
+
"@nuxt/kit-nightly",
|
|
80
|
+
"@nuxt/kit-edge",
|
|
81
|
+
"#app",
|
|
82
|
+
"#app/nuxt",
|
|
83
|
+
"nuxt",
|
|
84
|
+
"nuxt-nightly",
|
|
85
|
+
"nuxt-edge",
|
|
86
|
+
"nuxt3",
|
|
87
|
+
"vue",
|
|
88
|
+
"vue-demi"
|
|
89
|
+
],
|
|
90
|
+
hooks: {
|
|
91
|
+
async "mkdist:entry:options"(_ctx, entry, options) {
|
|
92
|
+
options.typescript = defu(options.typescript, { compilerOptions: await loadTSCompilerOptions(entry.input) });
|
|
93
|
+
},
|
|
94
|
+
async "rollup:options"(ctx, options) {
|
|
95
|
+
const [entry] = ctx.buildEntries;
|
|
96
|
+
const mergedCompilerOptions = defu({
|
|
97
|
+
noEmit: false,
|
|
98
|
+
paths: { "#app/nuxt": ["./node_modules/nuxt/dist/app/nuxt"] }
|
|
99
|
+
}, ctx.options.rollup.dts.compilerOptions, await loadTSCompilerOptions(entry.path));
|
|
100
|
+
ctx.options.rollup.dts.compilerOptions = convertCompilerOptionsFromJson(mergedCompilerOptions, entry.path).options;
|
|
101
|
+
options.plugins ||= [];
|
|
102
|
+
if (!Array.isArray(options.plugins)) options.plugins = [options.plugins];
|
|
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("/", "\\")));
|
|
105
|
+
options.plugins.unshift({
|
|
106
|
+
name: "nuxt-module-builder:runtime-externals",
|
|
107
|
+
async resolveId(id, importer) {
|
|
108
|
+
if (!RUNTIME_RE.test(id)) return;
|
|
109
|
+
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
110
|
+
if (!resolved) return;
|
|
111
|
+
const normalizedId = normalize(resolved.id);
|
|
112
|
+
for (const entry of runtimeEntries) {
|
|
113
|
+
if (!entry.outDir || !normalizedId.includes(entry.input)) continue;
|
|
114
|
+
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
|
+
if (distFile) return {
|
|
117
|
+
external: true,
|
|
118
|
+
id: distFile
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
async "rollup:done"(ctx) {
|
|
125
|
+
const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
|
|
126
|
+
const moduleFn = await jiti.import(pathToFileURL(moduleEntryPath).toString(), { default: true }).catch((err) => {
|
|
127
|
+
consola.error(err);
|
|
128
|
+
consola.error("Cannot load module. Please check dist:", moduleEntryPath);
|
|
129
|
+
return null;
|
|
130
|
+
});
|
|
131
|
+
if (!moduleFn) return;
|
|
132
|
+
const moduleMeta = await moduleFn.getMeta?.() || {};
|
|
133
|
+
if (ctx.pkg) {
|
|
134
|
+
if (!moduleMeta.name) moduleMeta.name = ctx.pkg.name;
|
|
135
|
+
if (!moduleMeta.version) moduleMeta.version = ctx.pkg.version;
|
|
136
|
+
}
|
|
137
|
+
moduleMeta.builder = {
|
|
138
|
+
[name]: version,
|
|
139
|
+
unbuild: await readPackageJSON("unbuild").then((r) => r.version).catch(() => "unknown")
|
|
140
|
+
};
|
|
141
|
+
const metaFile = resolve(ctx.options.outDir, "module.json");
|
|
142
|
+
await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
|
|
143
|
+
await writeTypes(ctx.options.outDir, ctx.options.stub);
|
|
144
|
+
},
|
|
145
|
+
async "build:done"(ctx) {
|
|
146
|
+
const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
|
|
147
|
+
if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) 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.`);
|
|
148
|
+
if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) 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\`.`);
|
|
149
|
+
const pkg = await readPackageJSON(cwd);
|
|
150
|
+
if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) 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.`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
async function writeTypes(distDir, isStub) {
|
|
157
|
+
const dtsFile = resolve(distDir, "types.d.mts");
|
|
158
|
+
if (existsSync(dtsFile)) return;
|
|
159
|
+
const moduleReExports = [];
|
|
160
|
+
if (!isStub) {
|
|
161
|
+
const moduleTypesFile = resolve(distDir, "module.d.mts");
|
|
162
|
+
const normalisedModuleTypes = (await promises.readFile(moduleTypesFile, "utf8").catch(() => "")).replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
|
|
163
|
+
for (const e of findExports(normalisedModuleTypes)) moduleReExports.push(e);
|
|
164
|
+
for (const i of findTypeExports(normalisedModuleTypes)) moduleReExports.push(i);
|
|
165
|
+
}
|
|
166
|
+
const appShims = [];
|
|
167
|
+
const schemaShims = [];
|
|
168
|
+
const moduleImports = [];
|
|
169
|
+
const schemaImports = [];
|
|
170
|
+
const moduleExports = [];
|
|
171
|
+
const hasTypeExport = (name) => isStub || moduleReExports.find((exp) => exp.names?.includes(name));
|
|
172
|
+
if (!hasTypeExport("ModuleOptions")) {
|
|
173
|
+
schemaImports.push("NuxtModule");
|
|
174
|
+
moduleImports.push("default as Module");
|
|
175
|
+
moduleExports.push(`export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`);
|
|
176
|
+
}
|
|
177
|
+
if (hasTypeExport("ModuleHooks")) {
|
|
178
|
+
moduleImports.push("ModuleHooks");
|
|
179
|
+
schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
|
|
180
|
+
}
|
|
181
|
+
if (hasTypeExport("ModuleRuntimeHooks")) {
|
|
182
|
+
moduleImports.push("ModuleRuntimeHooks");
|
|
183
|
+
appShims.push(` interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}`);
|
|
184
|
+
}
|
|
185
|
+
if (hasTypeExport("ModuleRuntimeConfig")) {
|
|
186
|
+
moduleImports.push("ModuleRuntimeConfig");
|
|
187
|
+
schemaShims.push(" interface RuntimeConfig extends ModuleRuntimeConfig {}");
|
|
188
|
+
}
|
|
189
|
+
if (hasTypeExport("ModulePublicRuntimeConfig")) {
|
|
190
|
+
moduleImports.push("ModulePublicRuntimeConfig");
|
|
191
|
+
schemaShims.push(" interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}");
|
|
192
|
+
}
|
|
193
|
+
const dtsContents = `
|
|
194
|
+
${schemaImports.length ? `import type { ${schemaImports.join(", ")} } from '@nuxt/schema'` : ""}
|
|
195
|
+
|
|
196
|
+
${moduleImports.length ? `import type { ${moduleImports.join(", ")} } from './module.mjs'` : ""}
|
|
197
|
+
|
|
198
|
+
${appShims.length ? `declare module '#app' {\n${appShims.join("\n")}\n}\n` : ""}
|
|
199
|
+
${schemaShims.length ? `declare module '@nuxt/schema' {\n${schemaShims.join("\n")}\n}\n` : ""}
|
|
200
|
+
${moduleExports.length ? `\n${moduleExports.join("\n")}` : ""}
|
|
201
|
+
${isStub ? "export * from \"./module.mjs\"" : ""}
|
|
202
|
+
${moduleReExports.filter((e) => e.type === "named" || e.type === "default").map((e) => `\nexport { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
|
203
|
+
${moduleReExports.filter((e) => e.type === "star").map((e) => `\nexport * from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
|
204
|
+
`.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
|
|
205
|
+
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
|
206
|
+
}
|
|
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;
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { build_exports as n, build_default as t };
|
package/dist/cli.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { n as name, r as version, t as description } from "./package-1Cra3U-o.mjs";
|
|
3
|
+
import { defineCommand, runMain } from "citty";
|
|
4
|
+
import { consola } from "consola";
|
|
5
|
+
//#region src/cli.ts
|
|
6
6
|
const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
|
7
|
+
runMain(defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name,
|
|
10
|
+
description,
|
|
11
|
+
version
|
|
12
|
+
},
|
|
13
|
+
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)
|
|
16
|
+
},
|
|
17
|
+
setup(context) {
|
|
18
|
+
const firstArg = context.rawArgs[0];
|
|
19
|
+
if (context.cmd.subCommands && !(firstArg && firstArg in context.cmd.subCommands)) {
|
|
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.");
|
|
21
|
+
context.rawArgs.unshift("build");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
//#endregion
|
|
26
|
+
export {};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,36 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
//#region src/commands/build.d.ts
|
|
2
|
+
declare const _default: import("citty").CommandDef<{
|
|
3
|
+
readonly outDir: {
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
readonly default: "dist";
|
|
6
|
+
readonly description: "Build directory";
|
|
7
|
+
};
|
|
8
|
+
readonly sourcemap: {
|
|
9
|
+
readonly type: "boolean";
|
|
10
|
+
readonly default: false;
|
|
11
|
+
readonly description: "Generate sourcemaps";
|
|
12
|
+
};
|
|
13
|
+
readonly stub: {
|
|
14
|
+
readonly type: "boolean";
|
|
15
|
+
readonly default: false;
|
|
16
|
+
readonly description: "Stub dist instead of actually building it for development";
|
|
17
|
+
};
|
|
18
|
+
readonly cwd: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly valueHint: "directory";
|
|
21
|
+
readonly description: "Specify the working directory, this takes precedence over ROOTDIR (default: `.`)";
|
|
22
|
+
readonly default: undefined;
|
|
23
|
+
};
|
|
24
|
+
readonly rootDir: {
|
|
25
|
+
readonly type: "positional";
|
|
26
|
+
readonly description: "Specifies the working directory (default: `.`)";
|
|
27
|
+
readonly required: false;
|
|
28
|
+
readonly default: ".";
|
|
29
|
+
};
|
|
22
30
|
}>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/commands/prepare.d.ts
|
|
33
|
+
declare const _default$1: import("citty").CommandDef<{
|
|
34
|
+
readonly cwd: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly valueHint: "directory";
|
|
37
|
+
readonly description: "Specify the working directory, this takes precedence over ROOTDIR (default: `.`)";
|
|
38
|
+
readonly default: undefined;
|
|
39
|
+
};
|
|
40
|
+
readonly rootDir: {
|
|
41
|
+
readonly type: "positional";
|
|
42
|
+
readonly description: "Specifies the working directory (default: `.`)";
|
|
43
|
+
readonly required: false;
|
|
44
|
+
readonly default: ".";
|
|
45
|
+
};
|
|
34
46
|
}>;
|
|
35
|
-
|
|
36
|
-
export { _default
|
|
47
|
+
//#endregion
|
|
48
|
+
export { _default as build, _default$1 as prepare };
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'node:url';
|
|
5
|
-
import 'pathe';
|
|
6
|
-
import 'pathe/utils';
|
|
7
|
-
import 'pkg-types';
|
|
8
|
-
import 'tsconfck';
|
|
9
|
-
import 'defu';
|
|
10
|
-
import 'jiti';
|
|
11
|
-
import 'magic-regexp';
|
|
12
|
-
import 'consola';
|
|
13
|
-
import 'mlly';
|
|
14
|
-
import 'citty';
|
|
15
|
-
import 'typescript';
|
|
16
|
-
import './shared/module-builder.yvjrH2kb.mjs';
|
|
1
|
+
import { t as build_default } from "./build-Ach6kRrL.mjs";
|
|
2
|
+
import { t as prepare_default } from "./prepare-DSOOmWt_.mjs";
|
|
3
|
+
export { build_default as build, prepare_default as prepare };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as sharedArgs, t as resolveCwdArg } from "./_shared-CfHVT2WD.mjs";
|
|
3
|
+
import { defineCommand } from "citty";
|
|
4
|
+
import { resolve } from "pathe";
|
|
5
|
+
//#region src/commands/prepare.ts
|
|
6
|
+
var prepare_exports = /* @__PURE__ */ __exportAll({ default: () => prepare_default });
|
|
7
|
+
var prepare_default = defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "prepare",
|
|
10
|
+
description: "Prepare @nuxt/module-builder environment by writing types and stubs"
|
|
11
|
+
},
|
|
12
|
+
args: { ...sharedArgs },
|
|
13
|
+
async run(context) {
|
|
14
|
+
const { runCommand } = await import("@nuxt/cli");
|
|
15
|
+
const cwd = resolveCwdArg(context.args);
|
|
16
|
+
return runCommand("prepare", [cwd], { overrides: {
|
|
17
|
+
compatibilityDate: "2024-04-03",
|
|
18
|
+
typescript: { builder: "shared" },
|
|
19
|
+
imports: { autoImport: false },
|
|
20
|
+
modules: [resolve(cwd, "./src/module"), function(_options, nuxt) {
|
|
21
|
+
nuxt.hooks.hook("app:templates", (app) => {
|
|
22
|
+
for (const template of app.templates) template.write = true;
|
|
23
|
+
});
|
|
24
|
+
}]
|
|
25
|
+
} });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { prepare_exports as n, prepare_default as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "nuxt/module-builder"
|
|
7
|
+
},
|
|
5
8
|
"description": "Complete solution for building Nuxt modules",
|
|
6
9
|
"license": "MIT",
|
|
7
10
|
"type": "module",
|
|
@@ -27,61 +30,56 @@
|
|
|
27
30
|
"dist"
|
|
28
31
|
],
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"citty": "^0.
|
|
33
|
+
"citty": "^0.2.2",
|
|
31
34
|
"consola": "^3.4.2",
|
|
32
|
-
"defu": "^6.1.
|
|
33
|
-
"jiti": "^2.
|
|
34
|
-
"magic-regexp": "^0.
|
|
35
|
-
"mkdist": "^2.
|
|
36
|
-
"mlly": "^1.
|
|
35
|
+
"defu": "^6.1.7",
|
|
36
|
+
"jiti": "^2.7.0",
|
|
37
|
+
"magic-regexp": "^0.11.0",
|
|
38
|
+
"mkdist": "^2.4.1",
|
|
39
|
+
"mlly": "^1.8.2",
|
|
37
40
|
"pathe": "^2.0.3",
|
|
38
|
-
"pkg-types": "^2.1
|
|
39
|
-
"tsconfck": "^3.1.
|
|
40
|
-
"unbuild": "^3.
|
|
41
|
-
"vue-sfc-transformer": "^0.
|
|
41
|
+
"pkg-types": "^2.3.1",
|
|
42
|
+
"tsconfck": "^3.1.6",
|
|
43
|
+
"unbuild": "^3.6.1",
|
|
44
|
+
"vue-sfc-transformer": "^0.2.3"
|
|
42
45
|
},
|
|
43
46
|
"peerDependencies": {
|
|
44
|
-
"@nuxt/cli": "^3.
|
|
45
|
-
"typescript": "^5.
|
|
47
|
+
"@nuxt/cli": "^3.37.0",
|
|
48
|
+
"typescript": "^5.9.3"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
|
-
"@arethetypeswrong/cli": "^0.
|
|
49
|
-
"@nuxt/cli": "^3.
|
|
50
|
-
"@nuxt/eslint-config": "^1.
|
|
51
|
-
"@nuxt/schema": "
|
|
52
|
-
"@types/node": "^
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"eslint": "^
|
|
56
|
-
"installed-check": "^
|
|
57
|
-
"knip": "^
|
|
58
|
-
"nuxt": "
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"@nuxt/module-builder": "workspace:*",
|
|
70
|
-
"@nuxt/schema": "^3.16.2",
|
|
71
|
-
"typescript": "~5.8.3",
|
|
72
|
-
"vue": "^3.5.13",
|
|
73
|
-
"vue-tsc": "^2.2.8"
|
|
51
|
+
"@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",
|
|
62
|
+
"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",
|
|
68
|
+
"typescript": "~5.9.3",
|
|
69
|
+
"vitest": "^4.1.10",
|
|
70
|
+
"vue": "^3.5.40",
|
|
71
|
+
"vue-tsc": "^3.3.7"
|
|
74
72
|
},
|
|
75
73
|
"engines": {
|
|
76
74
|
"node": "^18.0.0 || >=20.0.0"
|
|
77
75
|
},
|
|
78
76
|
"scripts": {
|
|
79
|
-
"build": "
|
|
80
|
-
"dev:prepare": "
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"dev:prepare": "pnpm -r dev:prepare",
|
|
81
79
|
"example:build": "pnpm nuxt-module-build build ./example",
|
|
80
|
+
"example:stub": "pnpm nuxt-module-build build --stub ./example",
|
|
82
81
|
"lint": "eslint .",
|
|
83
82
|
"nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
|
|
84
|
-
"release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
85
83
|
"test": "pnpm vitest --coverage",
|
|
86
84
|
"test:attw": "attw --pack example && attw --pack .",
|
|
87
85
|
"test:publint": "cd example && publint",
|
package/dist/chunks/build.mjs
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { existsSync, promises } from 'node:fs';
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
3
|
-
import { resolve, basename, normalize, extname, join, dirname } from 'pathe';
|
|
4
|
-
import { filename } from 'pathe/utils';
|
|
5
|
-
import { readPackageJSON } from 'pkg-types';
|
|
6
|
-
import { parse } from 'tsconfck';
|
|
7
|
-
import { defu } from 'defu';
|
|
8
|
-
import { createJiti } from 'jiti';
|
|
9
|
-
import { createRegExp, anyOf } from 'magic-regexp';
|
|
10
|
-
import { consola } from 'consola';
|
|
11
|
-
import { resolvePath, findExports, findTypeExports } from 'mlly';
|
|
12
|
-
import { defineCommand } from 'citty';
|
|
13
|
-
import { convertCompilerOptionsFromJson } from 'typescript';
|
|
14
|
-
import { v as version, n as name } from '../shared/module-builder.yvjrH2kb.mjs';
|
|
15
|
-
|
|
16
|
-
const build = defineCommand({
|
|
17
|
-
meta: {
|
|
18
|
-
name: "build",
|
|
19
|
-
description: "Build module for distribution"
|
|
20
|
-
},
|
|
21
|
-
args: {
|
|
22
|
-
cwd: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Current working directory"
|
|
25
|
-
},
|
|
26
|
-
rootDir: {
|
|
27
|
-
type: "positional",
|
|
28
|
-
description: "Root directory",
|
|
29
|
-
required: false
|
|
30
|
-
},
|
|
31
|
-
outDir: {
|
|
32
|
-
type: "string"
|
|
33
|
-
},
|
|
34
|
-
sourcemap: {
|
|
35
|
-
type: "boolean"
|
|
36
|
-
},
|
|
37
|
-
stub: {
|
|
38
|
-
type: "boolean"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
async run(context) {
|
|
42
|
-
const { build } = await import('unbuild');
|
|
43
|
-
const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
|
|
44
|
-
const jiti = createJiti(cwd);
|
|
45
|
-
const outDir = context.args.outDir || "dist";
|
|
46
|
-
await build(cwd, false, {
|
|
47
|
-
declaration: "node16",
|
|
48
|
-
sourcemap: context.args.sourcemap,
|
|
49
|
-
stub: context.args.stub,
|
|
50
|
-
outDir,
|
|
51
|
-
entries: [
|
|
52
|
-
"src/module",
|
|
53
|
-
{
|
|
54
|
-
input: "src/runtime/",
|
|
55
|
-
outDir: `${outDir}/runtime`,
|
|
56
|
-
addRelativeDeclarationExtensions: true,
|
|
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
|
-
],
|
|
65
|
-
esbuild: {
|
|
66
|
-
jsxImportSource: "vue",
|
|
67
|
-
jsx: "automatic",
|
|
68
|
-
jsxFactory: "h"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
rollup: {
|
|
73
|
-
esbuild: {
|
|
74
|
-
target: "esnext"
|
|
75
|
-
},
|
|
76
|
-
emitCJS: false,
|
|
77
|
-
cjsBridge: false
|
|
78
|
-
},
|
|
79
|
-
externals: [
|
|
80
|
-
/dist[\\/]runtime[\\/]/,
|
|
81
|
-
"@nuxt/schema",
|
|
82
|
-
"@nuxt/schema-nightly",
|
|
83
|
-
"@nuxt/schema-edge",
|
|
84
|
-
"@nuxt/kit",
|
|
85
|
-
"@nuxt/kit-nightly",
|
|
86
|
-
"@nuxt/kit-edge",
|
|
87
|
-
"#app",
|
|
88
|
-
"#app/nuxt",
|
|
89
|
-
"nuxt",
|
|
90
|
-
"nuxt-nightly",
|
|
91
|
-
"nuxt-edge",
|
|
92
|
-
"nuxt3",
|
|
93
|
-
"vue",
|
|
94
|
-
"vue-demi"
|
|
95
|
-
],
|
|
96
|
-
hooks: {
|
|
97
|
-
async "mkdist:entry:options"(_ctx, entry, options) {
|
|
98
|
-
options.typescript = defu(options.typescript, {
|
|
99
|
-
compilerOptions: await loadTSCompilerOptions(entry.input)
|
|
100
|
-
});
|
|
101
|
-
},
|
|
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;
|
|
111
|
-
options.plugins ||= [];
|
|
112
|
-
if (!Array.isArray(options.plugins))
|
|
113
|
-
options.plugins = [options.plugins];
|
|
114
|
-
const runtimeEntries = ctx.options.entries.filter((entry2) => entry2.builder === "mkdist");
|
|
115
|
-
const runtimeDirs = runtimeEntries.map((entry2) => basename(entry2.input));
|
|
116
|
-
const RUNTIME_RE = createRegExp(anyOf(...runtimeDirs).and(anyOf("/", "\\")));
|
|
117
|
-
options.plugins.unshift({
|
|
118
|
-
name: "nuxt-module-builder:runtime-externals",
|
|
119
|
-
async resolveId(id, importer) {
|
|
120
|
-
if (!RUNTIME_RE.test(id))
|
|
121
|
-
return;
|
|
122
|
-
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
123
|
-
if (!resolved)
|
|
124
|
-
return;
|
|
125
|
-
const normalizedId = normalize(resolved.id);
|
|
126
|
-
for (const entry2 of runtimeEntries) {
|
|
127
|
-
if (!entry2.outDir || !normalizedId.includes(entry2.input))
|
|
128
|
-
continue;
|
|
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));
|
|
131
|
-
if (distFile) {
|
|
132
|
-
return {
|
|
133
|
-
external: true,
|
|
134
|
-
id: distFile
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
async "rollup:done"(ctx) {
|
|
142
|
-
const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
|
|
143
|
-
const moduleFn = await jiti.import(pathToFileURL(moduleEntryPath).toString(), { default: true }).catch((err) => {
|
|
144
|
-
consola.error(err);
|
|
145
|
-
consola.error("Cannot load module. Please check dist:", moduleEntryPath);
|
|
146
|
-
return null;
|
|
147
|
-
});
|
|
148
|
-
if (!moduleFn) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const moduleMeta = await moduleFn.getMeta?.() || {};
|
|
152
|
-
if (ctx.pkg) {
|
|
153
|
-
if (!moduleMeta.name) {
|
|
154
|
-
moduleMeta.name = ctx.pkg.name;
|
|
155
|
-
}
|
|
156
|
-
if (!moduleMeta.version) {
|
|
157
|
-
moduleMeta.version = ctx.pkg.version;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
moduleMeta.builder = {
|
|
161
|
-
[name]: version,
|
|
162
|
-
unbuild: await readPackageJSON("unbuild").then((r) => r.version).catch(() => "unknown")
|
|
163
|
-
};
|
|
164
|
-
const metaFile = resolve(ctx.options.outDir, "module.json");
|
|
165
|
-
await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
|
|
166
|
-
await writeTypes(ctx.options.outDir, ctx.options.stub);
|
|
167
|
-
},
|
|
168
|
-
async "build:done"(ctx) {
|
|
169
|
-
const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
|
|
170
|
-
if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
|
|
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.`);
|
|
172
|
-
}
|
|
173
|
-
if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) {
|
|
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\`.`);
|
|
175
|
-
}
|
|
176
|
-
const pkg = await readPackageJSON(cwd);
|
|
177
|
-
if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) {
|
|
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.`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
async function writeTypes(distDir, isStub) {
|
|
186
|
-
const dtsFile = resolve(distDir, "types.d.mts");
|
|
187
|
-
if (existsSync(dtsFile)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const moduleReExports = [];
|
|
191
|
-
if (!isStub) {
|
|
192
|
-
const moduleTypesFile = resolve(distDir, "module.d.mts");
|
|
193
|
-
const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
|
|
194
|
-
const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
|
|
195
|
-
for (const e of findExports(normalisedModuleTypes)) {
|
|
196
|
-
moduleReExports.push(e);
|
|
197
|
-
}
|
|
198
|
-
for (const i of findTypeExports(normalisedModuleTypes)) {
|
|
199
|
-
moduleReExports.push(i);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
const appShims = [];
|
|
203
|
-
const schemaShims = [];
|
|
204
|
-
const moduleImports = [];
|
|
205
|
-
const schemaImports = [];
|
|
206
|
-
const moduleExports = [];
|
|
207
|
-
const hasTypeExport = (name2) => isStub || moduleReExports.find((exp) => exp.names?.includes(name2));
|
|
208
|
-
if (!hasTypeExport("ModuleOptions")) {
|
|
209
|
-
schemaImports.push("NuxtModule");
|
|
210
|
-
moduleImports.push("default as Module");
|
|
211
|
-
moduleExports.push(`export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`);
|
|
212
|
-
}
|
|
213
|
-
if (hasTypeExport("ModuleHooks")) {
|
|
214
|
-
moduleImports.push("ModuleHooks");
|
|
215
|
-
schemaShims.push(" interface NuxtHooks extends ModuleHooks {}");
|
|
216
|
-
}
|
|
217
|
-
if (hasTypeExport("ModuleRuntimeHooks")) {
|
|
218
|
-
moduleImports.push("ModuleRuntimeHooks");
|
|
219
|
-
appShims.push(` interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}`);
|
|
220
|
-
}
|
|
221
|
-
if (hasTypeExport("ModuleRuntimeConfig")) {
|
|
222
|
-
moduleImports.push("ModuleRuntimeConfig");
|
|
223
|
-
schemaShims.push(" interface RuntimeConfig extends ModuleRuntimeConfig {}");
|
|
224
|
-
}
|
|
225
|
-
if (hasTypeExport("ModulePublicRuntimeConfig")) {
|
|
226
|
-
moduleImports.push("ModulePublicRuntimeConfig");
|
|
227
|
-
schemaShims.push(" interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}");
|
|
228
|
-
}
|
|
229
|
-
const dtsContents = `
|
|
230
|
-
${schemaImports.length ? `import type { ${schemaImports.join(", ")} } from '@nuxt/schema'` : ""}
|
|
231
|
-
|
|
232
|
-
${moduleImports.length ? `import type { ${moduleImports.join(", ")} } from './module.mjs'` : ""}
|
|
233
|
-
|
|
234
|
-
${appShims.length ? `declare module '#app' {
|
|
235
|
-
${appShims.join("\n")}
|
|
236
|
-
}
|
|
237
|
-
` : ""}
|
|
238
|
-
${schemaShims.length ? `declare module '@nuxt/schema' {
|
|
239
|
-
${schemaShims.join("\n")}
|
|
240
|
-
}
|
|
241
|
-
` : ""}
|
|
242
|
-
${moduleExports.length ? `
|
|
243
|
-
${moduleExports.join("\n")}` : ""}
|
|
244
|
-
${isStub ? 'export * 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")}
|
|
249
|
-
`.trim().replace(/[\n\r]{3,}/g, "\n\n") + "\n";
|
|
250
|
-
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
|
251
|
-
}
|
|
252
|
-
async function loadTSCompilerOptions(path) {
|
|
253
|
-
const config = await parse(path);
|
|
254
|
-
const resolvedCompilerOptions = config?.tsconfig.compilerOptions || {};
|
|
255
|
-
for (const { tsconfig, tsconfigFile } of config.extended || []) {
|
|
256
|
-
for (const alias in tsconfig.compilerOptions?.paths || {}) {
|
|
257
|
-
resolvedCompilerOptions.paths[alias] = resolvedCompilerOptions.paths[alias].map((p) => {
|
|
258
|
-
if (!/^\.{1,2}(?:\/|$)/.test(p)) return p;
|
|
259
|
-
return resolve(dirname(tsconfigFile), p);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return resolvedCompilerOptions;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export { build as default };
|
package/dist/chunks/prepare.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from 'citty';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
3
|
-
|
|
4
|
-
const prepare = defineCommand({
|
|
5
|
-
meta: {
|
|
6
|
-
name: "prepare",
|
|
7
|
-
description: "Prepare @nuxt/module-builder environment by writing types and stubs"
|
|
8
|
-
},
|
|
9
|
-
args: {
|
|
10
|
-
cwd: {
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "Current working directory"
|
|
13
|
-
},
|
|
14
|
-
rootDir: {
|
|
15
|
-
type: "positional",
|
|
16
|
-
description: "Root directory",
|
|
17
|
-
required: false
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
async run(context) {
|
|
21
|
-
const { runCommand } = await import('@nuxt/cli');
|
|
22
|
-
const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
|
|
23
|
-
return runCommand("prepare", [cwd], {
|
|
24
|
-
overrides: {
|
|
25
|
-
compatibilityDate: "2024-04-03",
|
|
26
|
-
typescript: {
|
|
27
|
-
builder: "shared"
|
|
28
|
-
},
|
|
29
|
-
imports: {
|
|
30
|
-
autoImport: false
|
|
31
|
-
},
|
|
32
|
-
modules: [
|
|
33
|
-
resolve(cwd, "./src/module"),
|
|
34
|
-
function(_options, nuxt) {
|
|
35
|
-
nuxt.hooks.hook("app:templates", (app) => {
|
|
36
|
-
for (const template of app.templates) {
|
|
37
|
-
template.write = true;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export { prepare as default };
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as citty from 'citty';
|
|
2
|
-
|
|
3
|
-
declare const _default$1: citty.CommandDef<{
|
|
4
|
-
cwd: {
|
|
5
|
-
type: "string";
|
|
6
|
-
description: string;
|
|
7
|
-
};
|
|
8
|
-
rootDir: {
|
|
9
|
-
type: "positional";
|
|
10
|
-
description: string;
|
|
11
|
-
required: false;
|
|
12
|
-
};
|
|
13
|
-
outDir: {
|
|
14
|
-
type: "string";
|
|
15
|
-
};
|
|
16
|
-
sourcemap: {
|
|
17
|
-
type: "boolean";
|
|
18
|
-
};
|
|
19
|
-
stub: {
|
|
20
|
-
type: "boolean";
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
23
|
-
|
|
24
|
-
declare const _default: citty.CommandDef<{
|
|
25
|
-
cwd: {
|
|
26
|
-
type: "string";
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
rootDir: {
|
|
30
|
-
type: "positional";
|
|
31
|
-
description: string;
|
|
32
|
-
required: false;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
|
|
36
|
-
export { _default$1 as build, _default as prepare };
|