diff --git a/patches/nitro-nightly.patch b/patches/nitro-nightly.patch new file mode 100644 index 0000000000..c49f683e33 --- /dev/null +++ b/patches/nitro-nightly.patch @@ -0,0 +1,77 @@ +diff --git a/dist/core/index.mjs b/dist/core/index.mjs +index ceadc93d661a20bc0a7f25e0bdb838ab76b0f9cd..ebaf29d0eec258431056848493406aceee611228 100644 +--- a/dist/core/index.mjs ++++ b/dist/core/index.mjs +@@ -623,7 +623,7 @@ async function _loadUserConfig(configOverrides = {}, opts = {}) { + globalThis.defineNitroConfig = globalThis.defineNitroConfig || ((c) => c); + let compatibilityDate = configOverrides.compatibilityDate || opts.compatibilityDate || (process.env.NITRO_COMPATIBILITY_DATE || process.env.SERVER_COMPATIBILITY_DATE || process.env.COMPATIBILITY_DATE); + const { resolvePreset } = await import('nitro/presets'); +- const loadedConfig = await (opts.watch ? watchConfig : loadConfig)({ ++ const loadedConfig = await (opts.watch ? watchConfig : loadConfig)(klona({ + name: "nitro", + cwd: configOverrides.rootDir, + dotenv: configOverrides.dev, +@@ -657,15 +657,15 @@ async function _loadUserConfig(configOverrides = {}, opts = {}) { + }); + if (preset) { + return { +- config: preset ++ config: defu(preset) + }; + } + }, + ...opts.c12 +- }); ++ })); + const options = klona(loadedConfig.config); + options._config = configOverrides; +- options._c12 = loadedConfig; ++ options._c12 = loadedConfig ; + const _presetName = (loadedConfig.layers || []).find((l) => l.config?._meta?.name)?.config?._meta?.name || presetOverride; + options.preset = _presetName; + options.compatibilityDate = resolveCompatibilityDates( +diff --git a/dist/runtime/index.mjs b/dist/runtime/index.mjs +index f9a2a8f24cd06ab387f4935874192b069c7b8145..02e985497c04a0913f38baed58f6c01dfd390897 100644 +--- a/dist/runtime/index.mjs ++++ b/dist/runtime/index.mjs +@@ -15,3 +15,4 @@ export { + cachedFunction, + cachedEventHandler + } from "./internal/cache.mjs"; ++export { nitroAsyncNameStore } from "./internal/context.mjs"; +\ No newline at end of file +diff --git a/dist/runtime/internal/app.mjs b/dist/runtime/internal/app.mjs +index 42f434deff206d061fd5dbaff16fdb8e45531e4e..1294a495125571b75d3d292691b1cb85346b5b59 100644 +--- a/dist/runtime/internal/app.mjs ++++ b/dist/runtime/internal/app.mjs +@@ -127,7 +127,7 @@ function createNitroApp() { + const _handler = h3App.handler; + h3App.handler = (event) => { + const ctx = { event }; +- return nitroAsyncContext.callAsync(ctx, () => _handler(event)); ++ return nitroAsyncContext().callAsync(ctx, () => _handler(event)); + }; + } + const app = { +diff --git a/dist/runtime/internal/context.mjs b/dist/runtime/internal/context.mjs +index 7446d24ebaeb2828a9d18d22c82cb687a2ebaa43..734994b25fd66ddc7078a625c5d13499ce012a2b 100644 +--- a/dist/runtime/internal/context.mjs ++++ b/dist/runtime/internal/context.mjs +@@ -1,13 +1,15 @@ + import { AsyncLocalStorage } from "node:async_hooks"; + import { createError } from "h3"; + import { getContext } from "unctx"; +-export const nitroAsyncContext = getContext("nitro-app", { ++import { AsyncLocalStorage } from "node:async_hooks"; ++export const nitroAsyncNameStore = new AsyncLocalStorage() ++export const nitroAsyncContext = () => getContext(nitroAsyncNameStore.getStore() ?? "nitro-app", { + asyncContext: import.meta._asyncContext, + AsyncLocalStorage: import.meta._asyncContext ? AsyncLocalStorage : void 0 + }); + export function useEvent() { + try { +- return nitroAsyncContext.use().event; ++ return nitroAsyncContext().use().event; + } catch { + const hint = import.meta._asyncContext ? "Note: This is an experimental feature and might be broken on non-Node.js environments." : "Enable the experimental flag using `experimental.asyncContext: true`."; + throw createError({ diff --git a/test/fixtures/multiple-nuxt/loadNuxt.ts b/test/fixtures/multiple-nuxt/loadNuxt.ts new file mode 100644 index 0000000000..67ab46c4d8 --- /dev/null +++ b/test/fixtures/multiple-nuxt/loadNuxt.ts @@ -0,0 +1,13 @@ +import { loadNuxt } from "@nuxt/kit" + +import nuxtA from "./nuxt-a/nuxt.config" +import nuxtB from "./nuxt-b/nuxt.config" +import { resolve } from "path" + + + loadNuxt({ + cwd: resolve ('nuxt-a'), +}) + loadNuxt({ + cwd: resolve('nuxt-b'), +}) \ No newline at end of file diff --git a/test/fixtures/multiple-nuxt/nuxt-a/.gitignore b/test/fixtures/multiple-nuxt/nuxt-a/.gitignore new file mode 100644 index 0000000000..4a7f73a2ed --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/.gitignore @@ -0,0 +1,24 @@ +# Nuxt dev/build outputs +.output +.data +.nuxt +.nitro +.cache +dist + +# Node dependencies +node_modules + +# Logs +logs +*.log + +# Misc +.DS_Store +.fleet +.idea + +# Local env files +.env +.env.* +!.env.example diff --git a/test/fixtures/multiple-nuxt/nuxt-a/README.md b/test/fixtures/multiple-nuxt/nuxt-a/README.md new file mode 100644 index 0000000000..25b58212c9 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/README.md @@ -0,0 +1,75 @@ +# Nuxt Minimal Starter + +Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. + +## Setup + +Make sure to install dependencies: + +```bash +# npm +npm install + +# pnpm +pnpm install + +# yarn +yarn install + +# bun +bun install +``` + +## Development Server + +Start the development server on `http://localhost:3000`: + +```bash +# npm +npm run dev + +# pnpm +pnpm dev + +# yarn +yarn dev + +# bun +bun run dev +``` + +## Production + +Build the application for production: + +```bash +# npm +npm run build + +# pnpm +pnpm build + +# yarn +yarn build + +# bun +bun run build +``` + +Locally preview production build: + +```bash +# npm +npm run preview + +# pnpm +pnpm preview + +# yarn +yarn preview + +# bun +bun run preview +``` + +Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. diff --git a/test/fixtures/multiple-nuxt/nuxt-a/app.vue b/test/fixtures/multiple-nuxt/nuxt-a/app.vue new file mode 100644 index 0000000000..09f935bbb6 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/app.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/multiple-nuxt/nuxt-a/nuxt.config.ts b/test/fixtures/multiple-nuxt/nuxt-a/nuxt.config.ts new file mode 100644 index 0000000000..5b79f8a957 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/nuxt.config.ts @@ -0,0 +1,7 @@ +import { defineNuxtConfig} from "nuxt/config" + +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + compatibilityDate: '2024-11-01', + devtools: { enabled: true } +}) diff --git a/test/fixtures/multiple-nuxt/nuxt-a/package.json b/test/fixtures/multiple-nuxt/nuxt-a/package.json new file mode 100644 index 0000000000..12039e8605 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/package.json @@ -0,0 +1,17 @@ +{ + "name": "nuxt-app", + "private": true, + "type": "module", + "scripts": { + "build": "nuxt build", + "dev": "nuxt dev", + "generate": "nuxt generate", + "preview": "nuxt preview", + "postinstall": "nuxt prepare" + }, + "dependencies": { + "nuxt": "^3.15.1", + "vue": "latest", + "vue-router": "latest" + } +} diff --git a/test/fixtures/multiple-nuxt/nuxt-a/public/favicon.ico b/test/fixtures/multiple-nuxt/nuxt-a/public/favicon.ico new file mode 100644 index 0000000000..18993ad91c Binary files /dev/null and b/test/fixtures/multiple-nuxt/nuxt-a/public/favicon.ico differ diff --git a/test/fixtures/multiple-nuxt/nuxt-a/public/robots.txt b/test/fixtures/multiple-nuxt/nuxt-a/public/robots.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/public/robots.txt @@ -0,0 +1 @@ + diff --git a/test/fixtures/multiple-nuxt/nuxt-a/server/tsconfig.json b/test/fixtures/multiple-nuxt/nuxt-a/server/tsconfig.json new file mode 100644 index 0000000000..b9ed69c19e --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/server/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../.nuxt/tsconfig.server.json" +} diff --git a/test/fixtures/multiple-nuxt/nuxt-a/tsconfig.json b/test/fixtures/multiple-nuxt/nuxt-a/tsconfig.json new file mode 100644 index 0000000000..a746f2a70c --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-a/tsconfig.json @@ -0,0 +1,4 @@ +{ + // https://nuxt.com/docs/guide/concepts/typescript + "extends": "./.nuxt/tsconfig.json" +} diff --git a/test/fixtures/multiple-nuxt/nuxt-b/.gitignore b/test/fixtures/multiple-nuxt/nuxt-b/.gitignore new file mode 100644 index 0000000000..4a7f73a2ed --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/.gitignore @@ -0,0 +1,24 @@ +# Nuxt dev/build outputs +.output +.data +.nuxt +.nitro +.cache +dist + +# Node dependencies +node_modules + +# Logs +logs +*.log + +# Misc +.DS_Store +.fleet +.idea + +# Local env files +.env +.env.* +!.env.example diff --git a/test/fixtures/multiple-nuxt/nuxt-b/README.md b/test/fixtures/multiple-nuxt/nuxt-b/README.md new file mode 100644 index 0000000000..25b58212c9 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/README.md @@ -0,0 +1,75 @@ +# Nuxt Minimal Starter + +Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. + +## Setup + +Make sure to install dependencies: + +```bash +# npm +npm install + +# pnpm +pnpm install + +# yarn +yarn install + +# bun +bun install +``` + +## Development Server + +Start the development server on `http://localhost:3000`: + +```bash +# npm +npm run dev + +# pnpm +pnpm dev + +# yarn +yarn dev + +# bun +bun run dev +``` + +## Production + +Build the application for production: + +```bash +# npm +npm run build + +# pnpm +pnpm build + +# yarn +yarn build + +# bun +bun run build +``` + +Locally preview production build: + +```bash +# npm +npm run preview + +# pnpm +pnpm preview + +# yarn +yarn preview + +# bun +bun run preview +``` + +Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. diff --git a/test/fixtures/multiple-nuxt/nuxt-b/app.vue b/test/fixtures/multiple-nuxt/nuxt-b/app.vue new file mode 100644 index 0000000000..09f935bbb6 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/app.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/multiple-nuxt/nuxt-b/nuxt.config.ts b/test/fixtures/multiple-nuxt/nuxt-b/nuxt.config.ts new file mode 100644 index 0000000000..17d6c2e414 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/nuxt.config.ts @@ -0,0 +1,6 @@ +import { defineNuxtConfig} from "nuxt/config" +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + compatibilityDate: '2024-11-01', + devtools: { enabled: true } +}) diff --git a/test/fixtures/multiple-nuxt/nuxt-b/package.json b/test/fixtures/multiple-nuxt/nuxt-b/package.json new file mode 100644 index 0000000000..12039e8605 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/package.json @@ -0,0 +1,17 @@ +{ + "name": "nuxt-app", + "private": true, + "type": "module", + "scripts": { + "build": "nuxt build", + "dev": "nuxt dev", + "generate": "nuxt generate", + "preview": "nuxt preview", + "postinstall": "nuxt prepare" + }, + "dependencies": { + "nuxt": "^3.15.1", + "vue": "latest", + "vue-router": "latest" + } +} diff --git a/test/fixtures/multiple-nuxt/nuxt-b/public/favicon.ico b/test/fixtures/multiple-nuxt/nuxt-b/public/favicon.ico new file mode 100644 index 0000000000..18993ad91c Binary files /dev/null and b/test/fixtures/multiple-nuxt/nuxt-b/public/favicon.ico differ diff --git a/test/fixtures/multiple-nuxt/nuxt-b/public/robots.txt b/test/fixtures/multiple-nuxt/nuxt-b/public/robots.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/public/robots.txt @@ -0,0 +1 @@ + diff --git a/test/fixtures/multiple-nuxt/nuxt-b/server/tsconfig.json b/test/fixtures/multiple-nuxt/nuxt-b/server/tsconfig.json new file mode 100644 index 0000000000..b9ed69c19e --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/server/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../.nuxt/tsconfig.server.json" +} diff --git a/test/fixtures/multiple-nuxt/nuxt-b/tsconfig.json b/test/fixtures/multiple-nuxt/nuxt-b/tsconfig.json new file mode 100644 index 0000000000..a746f2a70c --- /dev/null +++ b/test/fixtures/multiple-nuxt/nuxt-b/tsconfig.json @@ -0,0 +1,4 @@ +{ + // https://nuxt.com/docs/guide/concepts/typescript + "extends": "./.nuxt/tsconfig.json" +}