Skip to content

Commit add1a3d

Browse files
farnabazatinux
andauthored
feat: transform as module (#37)
* refactor: convert to module * cleanup * fix: missing imports * Update docs/content/docs/1.getting-started/2.installation.md * chore: add prepack script * Create .nuxtrc --------- Co-authored-by: Sébastien Chopin <[email protected]>
1 parent dc8f203 commit add1a3d

34 files changed

+472
-254
lines changed

.nuxtrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# imports.autoImport=false
1+
imports.autoImport=false
22
typescript.includeWorkspace=true
33

44
# enable TypeScript bundler module resolution - https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ npx nypm@latest add @nuxthub/core
3838
npx nypm@latest add -D wrangler
3939
```
4040

41-
3. Add `@nuxthub/core` to the `extends` section of `nuxt.config.ts`
41+
3. Add `@nuxthub/core` to the `modules` section of `nuxt.config.ts`
4242

4343
```js
4444
export default defineNuxtConfig({
45-
extends: [
45+
modules: [
4646
'@nuxthub/core'
4747
]
4848
})

docs/.nuxtrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imports.autoImport=true

docs/content/docs/1.getting-started/2.installation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npx nuxthub init my-app
1717

1818
## Add to a Nuxt project
1919

20-
1. Install the NuxtHub package to your project:
20+
1. Install the NuxtHub module to your project:
2121

2222
::code-group
2323

@@ -61,11 +61,11 @@ bun add --dev wrangler
6161

6262
::
6363

64-
3. Add `@nuxthub/core` to your `extends` section in your `nuxt.config`:
64+
3. Add `@nuxthub/core` to your `modules` section in your `nuxt.config`:
6565

6666
```ts [nuxt.config.ts]
6767
export default defineNuxtConfig({
68-
extends: ['@nuxthub/core']
68+
modules: ['@nuxthub/core']
6969
})
7070
```
7171

@@ -81,7 +81,7 @@ Configure options in your `nuxt.config.ts` as such:
8181

8282
```ts [nuxt.config.ts]
8383
export default defineNuxtConfig({
84-
extends: ['@nuxthub/core'],
84+
modules: ['@nuxthub/core'],
8585
hub: {
8686
// NuxtHub options
8787
}

nuxt.config.ts

-7
This file was deleted.

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
},
1010
"license": "Apache-2.0",
1111
"type": "module",
12-
"main": "./nuxt.config.ts",
12+
"main": "./dist/module.cjs",
13+
"module": "./dist/module.mjs",
1314
"homepage": "https://hub.nuxt.com",
1415
"files": [
15-
"src",
16-
"nuxt.config.ts"
16+
"dist"
1717
],
1818
"keywords": [
1919
"nuxt",
@@ -24,7 +24,8 @@
2424
"blob"
2525
],
2626
"scripts": {
27-
"dev:prepare": "nuxi prepare playground",
27+
"prepack": "nuxt-module-build build",
28+
"dev:prepare": "nuxt-module-build build --stub; nuxi prepare playground",
2829
"dev": "nuxi dev playground",
2930
"dev:build": "nuxi build playground",
3031
"docs": "PORT=4000 nuxi dev docs",
@@ -60,6 +61,7 @@
6061
"devDependencies": {
6162
"@nuxt/devtools": "^1.1.4",
6263
"@nuxt/eslint-config": "^0.2.0",
64+
"@nuxt/module-builder": "^0.5.5",
6365
"@nuxt/schema": "^3.11.1",
6466
"@nuxt/test-utils": "^3.12.0",
6567
"@types/node": "^20.11.30",
@@ -70,4 +72,4 @@
7072
"vitest": "^1.4.0",
7173
"wrangler": "^3.39.0"
7274
}
73-
}
75+
}

playground/.nuxtrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imports.autoImport=true

playground/nuxt.config.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import module from '../src/module'
2+
13
export default defineNuxtConfig({
24
devtools: { enabled: true },
3-
extends: [
4-
'../'
5-
],
65
modules: [
76
'@nuxt/ui',
8-
'@kgierke/nuxt-basic-auth'
7+
'@kgierke/nuxt-basic-auth',
8+
module
99
],
1010
ui: {
1111
icons: ['heroicons', 'simple-icons']

0 commit comments

Comments
 (0)