@nuxt/module-builder 0.1.1 → 0.1.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.
- package/CHANGELOG.md +7 -0
- package/package.json +4 -1
- package/.editorconfig +0 -15
- package/.eslintignore +0 -3
- package/.eslintrc +0 -5
- package/.github/workflows/ci.yml +0 -23
- package/build.config.ts +0 -9
- package/example/dist/module.cjs +0 -4
- package/example/dist/module.d.ts +0 -8
- package/example/dist/module.mjs +0 -15
- package/example/dist/types.d.ts +0 -9
- package/example/dist/utils.d.ts +0 -3
- package/example/dist/utils.mjs +0 -4
- package/example/package.json +0 -32
- package/renovate.json +0 -11
- package/src/build.ts +0 -84
- package/src/cli.ts +0 -17
- package/src/index.ts +0 -1
- package/tsconfig.json +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
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
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
|
+
|
|
5
12
|
### 0.1.1 (2021-12-23)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/module-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Complete solution to build Nuxt Modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"nuxt-build-module": "./dist/cli.mjs",
|
|
15
15
|
"nuxt-module-build": "./dist/cli.mjs"
|
|
16
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
17
20
|
"scripts": {
|
|
18
21
|
"build": "unbuild",
|
|
19
22
|
"example:build": "yarn nuxt-module-build ./example",
|
package/.editorconfig
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
root = true
|
|
2
|
-
|
|
3
|
-
[*]
|
|
4
|
-
end_of_line = lf
|
|
5
|
-
insert_final_newline = true
|
|
6
|
-
trim_trailing_whitespace = true
|
|
7
|
-
charset = utf-8
|
|
8
|
-
|
|
9
|
-
[*.js]
|
|
10
|
-
indent_style = space
|
|
11
|
-
indent_size = 2
|
|
12
|
-
|
|
13
|
-
[{package.json,*.yml,*.cjson}]
|
|
14
|
-
indent_style = space
|
|
15
|
-
indent_size = 2
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
package/.github/workflows/ci.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: ci
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
ci:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- uses: actions/setup-node@v2
|
|
17
|
-
with:
|
|
18
|
-
node-version: 16
|
|
19
|
-
cache: 'yarn'
|
|
20
|
-
- run: yarn install
|
|
21
|
-
- run: yarn lint
|
|
22
|
-
- run: yarn build
|
|
23
|
-
- run: yarn example:build
|
package/build.config.ts
DELETED
package/example/dist/module.cjs
DELETED
package/example/dist/module.d.ts
DELETED
package/example/dist/module.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
|
-
|
|
3
|
-
const module = defineNuxtModule({
|
|
4
|
-
meta: {
|
|
5
|
-
name: "my-module",
|
|
6
|
-
configKey2: "myModule"
|
|
7
|
-
},
|
|
8
|
-
defaults: {
|
|
9
|
-
apiKey: null
|
|
10
|
-
},
|
|
11
|
-
setup(_options, _nuxt) {
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export { module as default };
|
package/example/dist/types.d.ts
DELETED
package/example/dist/utils.d.ts
DELETED
package/example/dist/utils.mjs
DELETED
package/example/package.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "my-module",
|
|
3
|
-
"license": "MIT",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
"import": "./dist/module.mjs",
|
|
8
|
-
"require": "./dist/module.cjs"
|
|
9
|
-
},
|
|
10
|
-
"./utils": "./dist/utils.mjs"
|
|
11
|
-
},
|
|
12
|
-
"main": "./dist/module.cjs",
|
|
13
|
-
"types": "./dist/types.d.ts",
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"prepack": "npm run build"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@nuxt/kit": "npm:@nuxt/kit-edge@latest"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@nuxt/module-builder": "latest",
|
|
25
|
-
"nuxt3": "latest"
|
|
26
|
-
},
|
|
27
|
-
"build": {
|
|
28
|
-
"entries": [
|
|
29
|
-
"./src/utils"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
package/renovate.json
DELETED
package/src/build.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { existsSync, promises as fsp } from 'fs'
|
|
2
|
-
import { resolve } from 'pathe'
|
|
3
|
-
import consola from 'consola'
|
|
4
|
-
import type { ModuleMeta } from '@nuxt/schema'
|
|
5
|
-
|
|
6
|
-
export async function buildModule (rootDir: string) {
|
|
7
|
-
const { build } = await import('unbuild')
|
|
8
|
-
|
|
9
|
-
await build(rootDir, false, {
|
|
10
|
-
declaration: true,
|
|
11
|
-
entries: [
|
|
12
|
-
'src/module',
|
|
13
|
-
{ input: 'src/runtime/', outDir: 'dist/runtime', ext: 'mjs' }
|
|
14
|
-
],
|
|
15
|
-
rollup: {
|
|
16
|
-
emitCJS: false,
|
|
17
|
-
cjsBridge: true
|
|
18
|
-
},
|
|
19
|
-
externals: [
|
|
20
|
-
'@nuxt/schema',
|
|
21
|
-
'@nuxt/schema-edge',
|
|
22
|
-
'@nuxt/kit',
|
|
23
|
-
'@nuxt/kit-edge'
|
|
24
|
-
],
|
|
25
|
-
hooks: {
|
|
26
|
-
async 'rollup:done' (ctx) {
|
|
27
|
-
// Generate CommonJS stup
|
|
28
|
-
await writeCJSStub(ctx.options.outDir)
|
|
29
|
-
|
|
30
|
-
// Load module meta
|
|
31
|
-
const moduleEntryPath = resolve(ctx.options.outDir, 'module.mjs')
|
|
32
|
-
const moduleFn = await import(moduleEntryPath).then(r => r.default || r).catch((err) => {
|
|
33
|
-
consola.error(err)
|
|
34
|
-
consola.error('Cannot load module. Please check dist:', moduleEntryPath)
|
|
35
|
-
return null
|
|
36
|
-
})
|
|
37
|
-
if (!moduleFn) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
const moduleMeta = await moduleFn.getMeta()
|
|
41
|
-
|
|
42
|
-
// Generate types
|
|
43
|
-
await writeTypes(ctx.options.outDir, moduleMeta)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function writeTypes (distDir: string, meta: ModuleMeta) {
|
|
50
|
-
const dtsFile = resolve(distDir, 'types.d.ts')
|
|
51
|
-
if (existsSync(dtsFile)) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const schemaShims = []
|
|
56
|
-
if (meta.configKey) {
|
|
57
|
-
schemaShims.push(
|
|
58
|
-
` interface NuxtConfig { ['${meta.configKey}']?: Partial<ModuleOptions> }`,
|
|
59
|
-
` interface NuxtOptions { ['${meta.configKey}']?: ModuleOptions }`
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const dtsContents = `
|
|
64
|
-
import type { ModuleOptions } from './module'
|
|
65
|
-
|
|
66
|
-
${schemaShims.length ? `declare module '@nuxt/schema' {\n${schemaShims.join('\n')}\n}\n` : ''}
|
|
67
|
-
export * from './module'
|
|
68
|
-
`
|
|
69
|
-
|
|
70
|
-
await fsp.writeFile(dtsFile, dtsContents, 'utf8')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function writeCJSStub (distDir: string) {
|
|
74
|
-
const cjsStubFile = resolve(distDir, 'module.cjs')
|
|
75
|
-
if (existsSync(cjsStubFile)) {
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
const cjsStub = `module.exports = function(...args) {
|
|
79
|
-
return import('./module.mjs').then(m => m.default.call(this, ...args))
|
|
80
|
-
}
|
|
81
|
-
module.exports.meta = require('../package.json')
|
|
82
|
-
`
|
|
83
|
-
await fsp.writeFile(cjsStubFile, cjsStub, 'utf8')
|
|
84
|
-
}
|
package/src/cli.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
import mri from 'mri'
|
|
5
|
-
import { resolve } from 'pathe'
|
|
6
|
-
import { buildModule } from './build'
|
|
7
|
-
|
|
8
|
-
async function main () {
|
|
9
|
-
const args = mri(process.argv.slice(2))
|
|
10
|
-
const rootDir = resolve(args._[0] || '.')
|
|
11
|
-
await buildModule(rootDir)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
main().catch((err) => {
|
|
15
|
-
console.error(err)
|
|
16
|
-
process.exit(1)
|
|
17
|
-
})
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './build'
|
package/tsconfig.json
DELETED