Skip to content

Commit

Permalink
feat: transform as module (#37)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
farnabaz and atinux authored Apr 3, 2024
1 parent dc8f203 commit add1a3d
Show file tree
Hide file tree
Showing 34 changed files with 472 additions and 254 deletions.
2 changes: 1 addition & 1 deletion .nuxtrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# imports.autoImport=false
imports.autoImport=false
typescript.includeWorkspace=true

# enable TypeScript bundler module resolution - https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ npx nypm@latest add @nuxthub/core
npx nypm@latest add -D wrangler
```

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

```js
export default defineNuxtConfig({
extends: [
modules: [
'@nuxthub/core'
]
})
Expand Down
1 change: 1 addition & 0 deletions docs/.nuxtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imports.autoImport=true
8 changes: 4 additions & 4 deletions docs/content/docs/1.getting-started/2.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npx nuxthub init my-app

## Add to a Nuxt project

1. Install the NuxtHub package to your project:
1. Install the NuxtHub module to your project:

::code-group

Expand Down Expand Up @@ -61,11 +61,11 @@ bun add --dev wrangler

::

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

```ts [nuxt.config.ts]
export default defineNuxtConfig({
extends: ['@nuxthub/core']
modules: ['@nuxthub/core']
})
```

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

```ts [nuxt.config.ts]
export default defineNuxtConfig({
extends: ['@nuxthub/core'],
modules: ['@nuxthub/core'],
hub: {
// NuxtHub options
}
Expand Down
7 changes: 0 additions & 7 deletions nuxt.config.ts

This file was deleted.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"license": "Apache-2.0",
"type": "module",
"main": "./nuxt.config.ts",
"main": "./dist/module.cjs",
"module": "./dist/module.mjs",
"homepage": "https://hub.nuxt.com",
"files": [
"src",
"nuxt.config.ts"
"dist"
],
"keywords": [
"nuxt",
Expand All @@ -24,7 +24,8 @@
"blob"
],
"scripts": {
"dev:prepare": "nuxi prepare playground",
"prepack": "nuxt-module-build build",
"dev:prepare": "nuxt-module-build build --stub; nuxi prepare playground",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"docs": "PORT=4000 nuxi dev docs",
Expand Down Expand Up @@ -60,6 +61,7 @@
"devDependencies": {
"@nuxt/devtools": "^1.1.4",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.5",
"@nuxt/schema": "^3.11.1",
"@nuxt/test-utils": "^3.12.0",
"@types/node": "^20.11.30",
Expand All @@ -70,4 +72,4 @@
"vitest": "^1.4.0",
"wrangler": "^3.39.0"
}
}
}
1 change: 1 addition & 0 deletions playground/.nuxtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imports.autoImport=true
8 changes: 4 additions & 4 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import module from '../src/module'

export default defineNuxtConfig({
devtools: { enabled: true },
extends: [
'../'
],
modules: [
'@nuxt/ui',
'@kgierke/nuxt-basic-auth'
'@kgierke/nuxt-basic-auth',
module
],
ui: {
icons: ['heroicons', 'simple-icons']
Expand Down
Loading

0 comments on commit add1a3d

Please sign in to comment.