From 698a3103e010549c99d2739374d927416d0039e3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 11 Jan 2023 20:51:49 +0000 Subject: [PATCH] fix(nuxt): include components `runtime` dir in build output (#10046) --- packages/nuxt/build.config.ts | 1 + packages/nuxt/src/components/loader.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/build.config.ts b/packages/nuxt/build.config.ts index 3c3e409a67..a727c4586d 100644 --- a/packages/nuxt/build.config.ts +++ b/packages/nuxt/build.config.ts @@ -12,6 +12,7 @@ export default defineBuildConfig({ ...[ 'core', 'head', + 'components', 'pages' ].map(name => ({ input: `src/${name}/runtime/`, outDir: `dist/${name}/runtime`, format: 'esm' } as BuildEntry)) ], diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index d0c81c939d..32bad878ec 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -1,10 +1,12 @@ -import { fileURLToPath, pathToFileURL } from 'node:url' +import { pathToFileURL } from 'node:url' import { createUnplugin } from 'unplugin' import { parseQuery, parseURL } from 'ufo' import type { Component, ComponentsOptions } from '@nuxt/schema' import { genDynamicImport, genImport } from 'knitwork' import MagicString from 'magic-string' import { pascalCase } from 'scule' +import { resolve } from 'pathe' +import { distDir } from '../dirs' interface LoaderOptions { getComponents (): Component[] @@ -44,7 +46,7 @@ function isVueTemplate (id: string) { export const loaderPlugin = createUnplugin((options: LoaderOptions) => { const exclude = options.transform?.exclude || [] 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 { name: 'nuxt:components-loader',