@nuxt/module-builder 0.1.2 → 0.1.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 +14 -0
- package/dist/chunks/build.mjs +15 -3
- package/dist/cli.mjs +2 -1
- package/dist/index.mjs +1 -0
- package/package.json +6 -6
- package/CHANGELOG.md +0 -23
package/README.md
CHANGED
|
@@ -85,6 +85,20 @@ A minimum `package.json` should look like this:
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
## Dist files
|
|
89
|
+
|
|
90
|
+
Module builder generates dist files in `dist/` directory:
|
|
91
|
+
|
|
92
|
+
- `module.mjs`: Module entrypoint build from `src/module`
|
|
93
|
+
- `module.json`: Module meta extracted from `module.mjs` + `package.json`
|
|
94
|
+
- `module.cjs`: ESM proxy to allow require module in CommonJS context
|
|
95
|
+
- `types.d.ts`: Exported types in addition to shims for `nuxt.config` auto completion.
|
|
96
|
+
- `runtime/*`: Individually transformed files using [unjs/mkdist](https://github.com/unjs/mkdist)
|
|
97
|
+
- Javascript and `.ts` files will be transformed to `.mjs` with extracted types on `.d.ts` file with same name
|
|
98
|
+
- `.vue` files will be transformed with extracted `.d.ts` file
|
|
99
|
+
- Other files will be copied as as
|
|
100
|
+
|
|
101
|
+
|
|
88
102
|
|
|
89
103
|
## 💻 Development
|
|
90
104
|
|
package/dist/chunks/build.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { promises, existsSync } from 'fs';
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
2
3
|
import { resolve } from 'pathe';
|
|
3
4
|
import consola from 'consola';
|
|
4
5
|
|
|
@@ -24,7 +25,7 @@ async function buildModule(rootDir) {
|
|
|
24
25
|
async "rollup:done"(ctx) {
|
|
25
26
|
await writeCJSStub(ctx.options.outDir);
|
|
26
27
|
const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
|
|
27
|
-
const moduleFn = await import(moduleEntryPath).then((r) => r.default || r).catch((err) => {
|
|
28
|
+
const moduleFn = await import(pathToFileURL(moduleEntryPath).toString()).then((r) => r.default || r).catch((err) => {
|
|
28
29
|
consola.error(err);
|
|
29
30
|
consola.error("Cannot load module. Please check dist:", moduleEntryPath);
|
|
30
31
|
return null;
|
|
@@ -33,6 +34,16 @@ async function buildModule(rootDir) {
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
const moduleMeta = await moduleFn.getMeta();
|
|
37
|
+
if (ctx.pkg) {
|
|
38
|
+
if (!moduleMeta.name) {
|
|
39
|
+
moduleMeta.name = ctx.pkg.name;
|
|
40
|
+
}
|
|
41
|
+
if (!moduleMeta.version) {
|
|
42
|
+
moduleMeta.version = ctx.pkg.version;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const metaFile = resolve(ctx.options.outDir, "module.json");
|
|
46
|
+
await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
|
|
36
47
|
await writeTypes(ctx.options.outDir, moduleMeta);
|
|
37
48
|
}
|
|
38
49
|
}
|
|
@@ -66,7 +77,8 @@ async function writeCJSStub(distDir) {
|
|
|
66
77
|
const cjsStub = `module.exports = function(...args) {
|
|
67
78
|
return import('./module.mjs').then(m => m.default.call(this, ...args))
|
|
68
79
|
}
|
|
69
|
-
module.exports.meta = require('
|
|
80
|
+
const _meta = module.exports.meta = require('./meta.json')
|
|
81
|
+
module.exports.getMeta = () => Promise.resolve(_meta)
|
|
70
82
|
`;
|
|
71
83
|
await promises.writeFile(cjsStubFile, cjsStub, "utf8");
|
|
72
84
|
}
|
package/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Complete solution to build Nuxt Modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
|
|
37
37
|
"@nuxt/schema": "npm:@nuxt/schema-edge@latest",
|
|
38
|
-
"@nuxtjs/eslint-config-typescript": "
|
|
39
|
-
"@types/mri": "
|
|
40
|
-
"eslint": "
|
|
41
|
-
"jiti": "
|
|
42
|
-
"standard-version": "
|
|
38
|
+
"@nuxtjs/eslint-config-typescript": "latest",
|
|
39
|
+
"@types/mri": "latest",
|
|
40
|
+
"eslint": "latest",
|
|
41
|
+
"jiti": "latest",
|
|
42
|
+
"standard-version": "latest"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [0.1.2](https://github.com/nuxt/module-builder/compare/v0.1.1...v0.1.2) (2021-12-23)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* **pkg:** only include dist ([d2ff7e4](https://github.com/nuxt/module-builder/commit/d2ff7e4168363dd4e8a93dc9c909e6f6e07765ff))
|
|
11
|
-
|
|
12
|
-
### 0.1.1 (2021-12-23)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Features
|
|
16
|
-
|
|
17
|
-
* poc for schema types generation ([4991907](https://github.com/nuxt/module-builder/commit/49919078806b95e8d9bde64b708cb430a3bb09cf))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Bug Fixes
|
|
21
|
-
|
|
22
|
-
* emit cjs stub before validation ([0154bc5](https://github.com/nuxt/module-builder/commit/0154bc51db2246217287c0fba4d9be42955fa306))
|
|
23
|
-
* improve types generation ([68c02e6](https://github.com/nuxt/module-builder/commit/68c02e60ab4f504c6b7d078c7e8e5fb13cb81e37))
|