@nuxt/module-builder 0.4.0 → 0.5.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.
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -25
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +36 -2
- package/package.json +27 -28
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { }
|
package/dist/cli.mjs
CHANGED
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import mri from 'mri';
|
|
3
3
|
import { resolve } from 'pathe';
|
|
4
|
-
import { buildModule } from './index.mjs';
|
|
4
|
+
import { prepareModule, buildModule } from './index.mjs';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'url';
|
|
7
7
|
import 'consola';
|
|
8
8
|
import 'mlly';
|
|
9
9
|
|
|
10
|
-
async function prepareModule(options) {
|
|
11
|
-
const { runCommand } = await import('nuxi');
|
|
12
|
-
return runCommand("prepare", [options.rootDir], {
|
|
13
|
-
overrides: {
|
|
14
|
-
typescript: {
|
|
15
|
-
builder: "shared"
|
|
16
|
-
},
|
|
17
|
-
imports: {
|
|
18
|
-
autoImport: false
|
|
19
|
-
},
|
|
20
|
-
modules: [
|
|
21
|
-
resolve(options.rootDir, "./src/module"),
|
|
22
|
-
function(_options, nuxt) {
|
|
23
|
-
nuxt.hooks.hook("app:templates", (app) => {
|
|
24
|
-
for (const template of app.templates) {
|
|
25
|
-
template.write = true;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
10
|
function main() {
|
|
35
11
|
const args = mri(process.argv.slice(2));
|
|
36
12
|
if (args._[0] === "prepare") {
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface BuildModuleOptions {
|
|
2
|
+
rootDir: string;
|
|
3
|
+
stub?: boolean;
|
|
4
|
+
outDir?: string;
|
|
5
|
+
}
|
|
6
|
+
declare function buildModule(opts: BuildModuleOptions): Promise<void>;
|
|
7
|
+
|
|
8
|
+
interface PrepareModuleOptions {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
}
|
|
11
|
+
declare function prepareModule(options: PrepareModuleOptions): Promise<void>;
|
|
12
|
+
|
|
13
|
+
export { type BuildModuleOptions, type PrepareModuleOptions, buildModule, prepareModule };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,9 @@ interface BuildModuleOptions {
|
|
|
5
5
|
}
|
|
6
6
|
declare function buildModule(opts: BuildModuleOptions): Promise<void>;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface PrepareModuleOptions {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
}
|
|
11
|
+
declare function prepareModule(options: PrepareModuleOptions): Promise<void>;
|
|
12
|
+
|
|
13
|
+
export { type BuildModuleOptions, type PrepareModuleOptions, buildModule, prepareModule };
|
package/dist/index.mjs
CHANGED
|
@@ -60,12 +60,19 @@ async function buildModule(opts) {
|
|
|
60
60
|
}
|
|
61
61
|
async function writeTypes(distDir, meta) {
|
|
62
62
|
const dtsFile = resolve(distDir, "types.d.ts");
|
|
63
|
+
const dtsFileMts = resolve(distDir, "types.d.mts");
|
|
63
64
|
if (existsSync(dtsFile)) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
const moduleTypesFile = resolve(distDir, "module.d.ts");
|
|
67
68
|
const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
|
|
68
|
-
const typeExports = findExports(
|
|
69
|
+
const typeExports = findExports(
|
|
70
|
+
// Replace `export { type Foo }` with `export { Foo }`
|
|
71
|
+
moduleTypes.replace(
|
|
72
|
+
/export\s*{.*?}/sg,
|
|
73
|
+
(match) => match.replace(/\btype\b/g, "")
|
|
74
|
+
)
|
|
75
|
+
);
|
|
69
76
|
const isStub = moduleTypes.includes("export *");
|
|
70
77
|
const schemaShims = [];
|
|
71
78
|
const moduleImports = [];
|
|
@@ -102,6 +109,9 @@ ${schemaShims.join("\n")}
|
|
|
102
109
|
export { ${typeExports[0].names.join(", ")} } from './module'
|
|
103
110
|
`;
|
|
104
111
|
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
|
112
|
+
if (!existsSync(dtsFileMts)) {
|
|
113
|
+
await promises.writeFile(dtsFileMts, dtsContents, "utf8");
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
async function writeCJSStub(distDir) {
|
|
107
117
|
const cjsStubFile = resolve(distDir, "module.cjs");
|
|
@@ -117,4 +127,28 @@ module.exports.getMeta = () => Promise.resolve(_meta)
|
|
|
117
127
|
await promises.writeFile(cjsStubFile, cjsStub, "utf8");
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
|
|
130
|
+
async function prepareModule(options) {
|
|
131
|
+
const { runCommand } = await import('nuxi');
|
|
132
|
+
return runCommand("prepare", [options.rootDir], {
|
|
133
|
+
overrides: {
|
|
134
|
+
typescript: {
|
|
135
|
+
builder: "shared"
|
|
136
|
+
},
|
|
137
|
+
imports: {
|
|
138
|
+
autoImport: false
|
|
139
|
+
},
|
|
140
|
+
modules: [
|
|
141
|
+
resolve(options.rootDir, "./src/module"),
|
|
142
|
+
function(_options, nuxt) {
|
|
143
|
+
nuxt.hooks.hook("app:templates", (app) => {
|
|
144
|
+
for (const template of app.templates) {
|
|
145
|
+
template.write = true;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { buildModule, prepareModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"repository": "nuxt/module-builder",
|
|
5
5
|
"description": "Complete solution to build Nuxt Modules",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,39 +19,38 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
-
"
|
|
23
|
-
"build": "unbuild",
|
|
24
|
-
"example:build": "pnpm nuxt-module-build ./example",
|
|
25
|
-
"lint": "eslint --ext .ts,.js,.mjs .",
|
|
26
|
-
"nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
|
|
27
|
-
"prepack": "pnpm build",
|
|
28
|
-
"release": "pnpm test && standard-version && git push --follow-tags && npm publish",
|
|
29
|
-
"test": "pnpm vitest"
|
|
30
|
-
},
|
|
31
|
-
"packageManager": "pnpm@8.5.1",
|
|
22
|
+
"packageManager": "pnpm@8.7.0",
|
|
32
23
|
"dependencies": {
|
|
33
|
-
"consola": "^3.
|
|
34
|
-
"mlly": "^1.
|
|
24
|
+
"consola": "^3.2.3",
|
|
25
|
+
"mlly": "^1.4.1",
|
|
35
26
|
"mri": "^1.2.0",
|
|
36
|
-
"pathe": "^1.1.
|
|
37
|
-
"unbuild": "^
|
|
27
|
+
"pathe": "^1.1.1",
|
|
28
|
+
"unbuild": "^2.0.0"
|
|
38
29
|
},
|
|
39
30
|
"peerDependencies": {
|
|
40
|
-
"@nuxt/kit": "^3.
|
|
41
|
-
"nuxi": "^3.
|
|
31
|
+
"@nuxt/kit": "^3.7.0",
|
|
32
|
+
"nuxi": "^3.7.2"
|
|
42
33
|
},
|
|
43
34
|
"devDependencies": {
|
|
44
|
-
"@nuxt/kit": "^3.
|
|
45
|
-
"@nuxt/schema": "^3.
|
|
35
|
+
"@nuxt/kit": "^3.7.0",
|
|
36
|
+
"@nuxt/schema": "^3.7.0",
|
|
46
37
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
47
38
|
"@types/mri": "^1.1.1",
|
|
48
|
-
"@types/node": "^20.
|
|
49
|
-
"@vitest/coverage-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"vitest": "^0.
|
|
39
|
+
"@types/node": "^20.5.7",
|
|
40
|
+
"@vitest/coverage-v8": "^0.34.3",
|
|
41
|
+
"changelogen": "^0.5.5",
|
|
42
|
+
"eslint": "^8.48.0",
|
|
43
|
+
"jiti": "^1.19.3",
|
|
44
|
+
"nuxi": "^3.7.2",
|
|
45
|
+
"nuxt": "^3.7.0",
|
|
46
|
+
"vitest": "^0.34.3"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "unbuild",
|
|
50
|
+
"example:build": "pnpm nuxt-module-build ./example",
|
|
51
|
+
"lint": "eslint --ext .ts,.js,.mjs .",
|
|
52
|
+
"nuxt-module-build": "JITI_ESM_RESOLVE=1 jiti ./src/cli.ts",
|
|
53
|
+
"release": "pnpm vitest run && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
54
|
+
"test": "pnpm vitest"
|
|
56
55
|
}
|
|
57
|
-
}
|
|
56
|
+
}
|