Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/content/1.guide/5.nuxt/1.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: ''

# Nuxt Setup

Since version 2.0.0 the module supports **Nuxt 3.14+ and Nuxt 4**.

## Installation

::alert{type=warning}
Expand Down Expand Up @@ -110,3 +112,17 @@ export default defineNuxtConfig({
})

````

## Dependency Optimization

The module automatically adds `pinia-orm` to vite's `optimizeDeps.include`, so the dev server pre-bundles it and you don't get "new dependencies optimized — reloading" restarts when the first repository is used. If you want to handle dependency optimization yourself, disable it:

````ts
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@pinia/nuxt', '@pinia-orm/nuxt'],
piniaOrm: {
optimizeDeps: false,
},
})
````
12 changes: 6 additions & 6 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
"@pinia/nuxt": ">=0.10.0"
},
"dependencies": {
"@nuxt/kit": "^3.15.4",
"@nuxt/kit": "^4.5.0",
"pinia-orm": "workspace:*"
},
"devDependencies": {
"@nuxt/devtools": "^2.1.3",
"@nuxt/eslint-config": "^1.1.0",
"@nuxt/module-builder": "^0.8.4",
"@nuxt/schema": "^3.15.4",
"@pinia/nuxt": "^0.10.1",
"@nuxt/module-builder": "^1.0.2",
"@nuxt/schema": "^4.5.0",
"@pinia/nuxt": "^1.0.1",
"@types/prettier": "^3.0.0",
"eslint": "^9.21.0",
"nuxt": "^3.15.4",
"pinia": "^3.0.1",
"nuxt": "^4.5.0",
"pinia": "^4.0.2",
"prettier": "^3.3.2",
"std-env": "^3.7.0",
"typescript": "^5.8.2",
Expand Down
22 changes: 22 additions & 0 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ export interface PiniaOrmNuxtOptions extends InstallOptions {
*
*/
autoImports?: Array<string | [string, string]>
/**
* Add pinia-orm packages to vite's `optimizeDeps.include` so the dev
* server pre-bundles them and avoids "new dependency optimized" reloads.
* @default true
*/
optimizeDeps?: boolean
}

export default defineNuxtModule<PiniaOrmNuxtOptions>({
meta: {
name: 'pinia-orm',
configKey: 'piniaOrm',
compatibility: {
nuxt: '>=3.14.0',
},
},
defaults: {
autoImports: [],
optimizeDeps: true,
...CONFIG_DEFAULTS,
},
setup (options, nuxt) {
Expand All @@ -37,6 +47,18 @@ export default defineNuxtModule<PiniaOrmNuxtOptions>({
// Transpile runtime
nuxt.options.build.transpile.push(resolver.resolve('./runtime'))

if (options.optimizeDeps) {
// Pre-bundle pinia-orm so vite doesn't restart the dev server with
// "new dependencies optimized" once the first repository is used.
nuxt.options.vite.optimizeDeps ||= {}
nuxt.options.vite.optimizeDeps.include ||= []
for (const dep of ['pinia-orm', 'pinia-orm > @pinia-orm/normalizr']) {
if (!nuxt.options.vite.optimizeDeps.include.includes(dep)) {
nuxt.options.vite.optimizeDeps.include.push(dep)
}
}
}

nuxt.hook('devtools:customTabs', (tabs) => {
tabs.push({
name: 'pinia-orm',
Expand Down
10 changes: 5 additions & 5 deletions playgrounds/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"devDependencies": {
"@pinia-orm/axios": "workspace:*",
"@pinia-orm/nuxt": "workspace:*",
"@pinia/nuxt": "^0.11.0",
"nuxt": "^3.16.2",
"pinia": "^3.0.2",
"@pinia/nuxt": "^1.0.1",
"nuxt": "^4.5.0",
"pinia": "^4.0.2",
"pinia-orm": "workspace:*"
},
"dependencies": {
"axios": "^1.7.2",
"nanoid": "^4.0.0",
"uuid": "^8.3.2"
"nanoid": "^5.1.0",
"uuid": "^11.1.1"
}
}
Loading
Loading