|
13 | 13 | - Unified build with [unjs/unbuild](https://github.com/unjs/unbuild)
|
14 | 14 | - Automated build config using last module spec
|
15 | 15 | - Typescript and ESM support
|
16 |
| -- Auto generated CommonJS stubs |
17 | 16 | - Auto generated types and shims for `@nuxt/schema`
|
18 | 17 |
|
19 | 18 | We recommend to checkout the [Nuxt modules author guide](https://nuxt.com/docs/guide/going-further/modules) before starting with the module-builder.
|
20 | 19 |
|
21 | 20 | ## Requirements
|
22 | 21 |
|
23 | 22 | For a user to use a module generated from module-builder, it's recommended they have:
|
24 |
| -- Node.js >= 16.x. _Latest Node LTS preferred_ |
25 |
| -- Nuxt 3 or Nuxt Bridge. _Nuxt 2 is functional but not advised_ |
| 23 | +- Node.js >= 18.x. _Latest Node LTS preferred_ |
| 24 | +- Nuxt 3+. |
26 | 25 |
|
27 | 26 | ## Quick start
|
28 | 27 |
|
29 | 28 | Get started with our [module starter](https://github.com/nuxt/starter/tree/module):
|
30 | 29 |
|
31 | 30 | ```bash
|
32 |
| -npx nuxi init -t module my-module |
| 31 | +npm create nuxt -- -t module my-module |
33 | 32 | ```
|
34 | 33 |
|
35 | 34 | ## Project structure
|
@@ -100,21 +99,26 @@ A minimum `package.json` should look like this:
|
100 | 99 | "version": "1.0.0",
|
101 | 100 | "exports": {
|
102 | 101 | ".": {
|
103 |
| - "types": "./dist/types.d.ts", |
104 |
| - "import": "./dist/module.mjs", |
105 |
| - "require": "./dist/module.cjs" |
| 102 | + "types": "./dist/types.d.mts", |
| 103 | + "import": "./dist/module.mjs" |
| 104 | + } |
| 105 | + }, |
| 106 | + "main": "./dist/module.mjs", |
| 107 | + "typesVersions": { |
| 108 | + "*": { |
| 109 | + ".": [ |
| 110 | + "./dist/types.d.mts" |
| 111 | + ] |
106 | 112 | }
|
107 | 113 | },
|
108 |
| - "main": "./dist/module.cjs", |
109 |
| - "types": "./dist/types.d.ts", |
110 | 114 | "files": [
|
111 | 115 | "dist"
|
112 | 116 | ],
|
113 | 117 | "scripts": {
|
114 | 118 | "prepack": "nuxt-module-build build"
|
115 | 119 | },
|
116 | 120 | "dependencies": {
|
117 |
| - "@nuxt/kit": "npm:@nuxt/kit-edge@latest" |
| 121 | + "@nuxt/kit": "latest" |
118 | 122 | },
|
119 | 123 | "devDependencies": {
|
120 | 124 | "@nuxt/module-builder": "latest"
|
@@ -142,8 +146,7 @@ Module builder generates dist files in `dist/` directory:
|
142 | 146 |
|
143 | 147 | - `module.mjs`: Module entrypoint build from `src/module`
|
144 | 148 | - `module.json`: Module meta extracted from `module.mjs` + `package.json`
|
145 |
| -- `module.cjs`: ESM proxy to allow require module in CommonJS context |
146 |
| -- `types.d.ts`: Exported types in addition to shims for `nuxt.config` auto completion. |
| 149 | +- `types.d.mts`: Exported types in addition to shims for `nuxt.config` auto completion. |
147 | 150 | - `runtime/*`: Individually transformed files using [unjs/mkdist](https://github.com/unjs/mkdist)
|
148 | 151 | - Javascript and `.ts` files will be transformed to `.js` with extracted types on `.d.ts` file with same name
|
149 | 152 | - `.vue` files will be transformed with extracted `.d.ts` file
|
|
0 commit comments