mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix: resolve ids to support pnpm (#8671)
This commit is contained in:
parent
253c8f7ee0
commit
9eb6a62471
@ -1,11 +1,11 @@
|
|||||||
import type { Nuxt, NuxtApp, NuxtTemplate } from '@nuxt/schema'
|
import type { Nuxt, NuxtApp, NuxtTemplate } from '@nuxt/schema'
|
||||||
import { genArrayFromRaw, genDynamicImport, genExport, genImport, genObjectFromRawEntries, genString, genSafeVariableName } from 'knitwork'
|
import { genArrayFromRaw, genDynamicImport, genExport, genImport, genObjectFromRawEntries, genString, genSafeVariableName } from 'knitwork'
|
||||||
|
|
||||||
import { isAbsolute, join, relative, resolve } from 'pathe'
|
import { isAbsolute, join, relative, resolve } from 'pathe'
|
||||||
import { resolveSchema, generateTypes } from 'untyped'
|
import { resolveSchema, generateTypes } from 'untyped'
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
import { hash } from 'ohash'
|
import { hash } from 'ohash'
|
||||||
import { camelCase } from 'scule'
|
import { camelCase } from 'scule'
|
||||||
|
import { resolvePath } from 'mlly'
|
||||||
|
|
||||||
export interface TemplateContext {
|
export interface TemplateContext {
|
||||||
nuxt: Nuxt
|
nuxt: Nuxt
|
||||||
@ -206,9 +206,9 @@ declare module '@nuxt/schema' {
|
|||||||
export const appConfigTemplate: NuxtTemplate = {
|
export const appConfigTemplate: NuxtTemplate = {
|
||||||
filename: 'app.config.mjs',
|
filename: 'app.config.mjs',
|
||||||
write: true,
|
write: true,
|
||||||
getContents: ({ app, nuxt }) => {
|
getContents: async ({ app, nuxt }) => {
|
||||||
return `
|
return `
|
||||||
import { defuFn } from 'defu'
|
import { defuFn } from '${await _resolveId('defu')}'
|
||||||
|
|
||||||
const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
|
const inlineConfig = ${JSON.stringify(nuxt.options.appConfig, null, 2)}
|
||||||
|
|
||||||
@ -221,9 +221,9 @@ export default defuFn(${app.configs.map((_id: string, index: number) => `cfg${in
|
|||||||
|
|
||||||
export const publicPathTemplate: NuxtTemplate = {
|
export const publicPathTemplate: NuxtTemplate = {
|
||||||
filename: 'paths.mjs',
|
filename: 'paths.mjs',
|
||||||
getContents ({ nuxt }) {
|
async getContents ({ nuxt }) {
|
||||||
return [
|
return [
|
||||||
'import { joinURL } from \'ufo\'',
|
`import { joinURL } from '${await _resolveId('ufo')}'`,
|
||||||
!nuxt.options.dev && 'import { useRuntimeConfig } from \'#internal/nitro\'',
|
!nuxt.options.dev && 'import { useRuntimeConfig } from \'#internal/nitro\'',
|
||||||
|
|
||||||
nuxt.options.dev
|
nuxt.options.dev
|
||||||
@ -256,3 +256,17 @@ export const nuxtConfigTemplate = {
|
|||||||
return Object.entries(ctx.nuxt.options.app).map(([k, v]) => `export const ${camelCase('app-' + k)} = ${JSON.stringify(v)}`).join('\n\n')
|
return Object.entries(ctx.nuxt.options.app).map(([k, v]) => `export const ${camelCase('app-' + k)} = ${JSON.stringify(v)}`).join('\n\n')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move to kit
|
||||||
|
function _resolveId (id: string) {
|
||||||
|
return resolvePath(id, {
|
||||||
|
url: [
|
||||||
|
// @ts-ignore
|
||||||
|
global.__NUXT_PREPATHS__,
|
||||||
|
import.meta.url,
|
||||||
|
process.cwd(),
|
||||||
|
// @ts-ignore
|
||||||
|
global.__NUXT_PATHS__
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user