test: add old patch + fixtures

This commit is contained in:
Julien Huang 2025-01-09 15:07:37 +01:00
parent 186be43db1
commit 6ef28c993a
20 changed files with 363 additions and 0 deletions

View File

@ -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({

13
test/fixtures/multiple-nuxt/loadNuxt.ts vendored Normal file
View File

@ -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'),
})

View File

@ -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

View File

@ -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.

View File

@ -0,0 +1,6 @@
<template>
<div>
<NuxtRouteAnnouncer />
<NuxtWelcome />
</div>
</template>

View File

@ -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 }
})

View File

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}

View File

@ -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

View File

@ -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.

View File

@ -0,0 +1,6 @@
<template>
<div>
<NuxtRouteAnnouncer />
<NuxtWelcome />
</div>
</template>

View File

@ -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 }
})

View File

@ -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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}