fix(nuxt): include components runtime dir in build output (#10046)

This commit is contained in:
Daniel Roe 2023-01-11 20:51:49 +00:00 committed by GitHub
parent 72bfcdfd69
commit 698a3103e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -12,6 +12,7 @@ export default defineBuildConfig({
...[ ...[
'core', 'core',
'head', 'head',
'components',
'pages' 'pages'
].map(name => ({ input: `src/${name}/runtime/`, outDir: `dist/${name}/runtime`, format: 'esm' } as BuildEntry)) ].map(name => ({ input: `src/${name}/runtime/`, outDir: `dist/${name}/runtime`, format: 'esm' } as BuildEntry))
], ],

View File

@ -1,10 +1,12 @@
import { fileURLToPath, pathToFileURL } from 'node:url' import { pathToFileURL } from 'node:url'
import { createUnplugin } from 'unplugin' import { createUnplugin } from 'unplugin'
import { parseQuery, parseURL } from 'ufo' import { parseQuery, parseURL } from 'ufo'
import type { Component, ComponentsOptions } from '@nuxt/schema' import type { Component, ComponentsOptions } from '@nuxt/schema'
import { genDynamicImport, genImport } from 'knitwork' import { genDynamicImport, genImport } from 'knitwork'
import MagicString from 'magic-string' import MagicString from 'magic-string'
import { pascalCase } from 'scule' import { pascalCase } from 'scule'
import { resolve } from 'pathe'
import { distDir } from '../dirs'
interface LoaderOptions { interface LoaderOptions {
getComponents (): Component[] getComponents (): Component[]
@ -44,7 +46,7 @@ function isVueTemplate (id: string) {
export const loaderPlugin = createUnplugin((options: LoaderOptions) => { export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
const exclude = options.transform?.exclude || [] const exclude = options.transform?.exclude || []
const include = options.transform?.include || [] const include = options.transform?.include || []
const serverComponentRuntime = fileURLToPath(new URL('./runtime/server-component', import.meta.url)) const serverComponentRuntime = resolve(distDir, 'components/runtime/server-component')
return { return {
name: 'nuxt:components-loader', name: 'nuxt:components-loader',