From 677fa40e33c1b7c483f950a7edcccfba47924551 Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Thu, 4 Jun 2026 05:28:54 +0200 Subject: [PATCH 1/4] fix: fix runtime path in typescript config --- src/commands/prepare.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/prepare.ts b/src/commands/prepare.ts index 50a227ad..d6135b4c 100644 --- a/src/commands/prepare.ts +++ b/src/commands/prepare.ts @@ -26,7 +26,7 @@ export default defineCommand({ autoImport: false, }, modules: [ - resolve(cwd, './src/module'), + resolve(cwd, './src'), function (_options, nuxt) { nuxt.hooks.hook('app:templates', (app) => { for (const template of app.templates) { From 839e401ec622ad804f044bd1a5d491f89f2eaa74 Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Thu, 4 Jun 2026 05:49:31 +0200 Subject: [PATCH 2/4] chore: create test --- test/prepare.spec.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/prepare.spec.ts diff --git a/test/prepare.spec.ts b/test/prepare.spec.ts new file mode 100644 index 00000000..7ef643a0 --- /dev/null +++ b/test/prepare.spec.ts @@ -0,0 +1,33 @@ +import { fileURLToPath } from 'node:url' +import { cp, mkdir, readFile, rm } from 'node:fs/promises' +import { beforeAll, describe, expect, it } from 'vitest' +import { exec } from 'tinyexec' +import { dirname, join } from 'pathe' + +describe('module builder', () => { + const workspaceDir = fileURLToPath(new URL('..', import.meta.url)) + const exampleDir = fileURLToPath(new URL('../example', import.meta.url)) + const prepareRootDir = exampleDir.replace('example', '.temp-example-prepare') + + beforeAll(async () => { + await mkdir(dirname(prepareRootDir), { recursive: true }) + await rm(prepareRootDir, { force: true, recursive: true }) + await cp(exampleDir, prepareRootDir, { recursive: true }) + + await exec('pnpm', ['nuxt-module-build', 'prepare', prepareRootDir], { + nodeOptions: { cwd: workspaceDir }, + }) + }, 120 * 1000) + + it('includes module runtime in generated server tsconfig', async () => { + const serverTsconfig = await readFile(join(prepareRootDir, '.nuxt/tsconfig.server.json'), 'utf-8') + const parsed = JSON.parse(serverTsconfig) as { include?: unknown } + const include = Array.isArray(parsed.include) ? parsed.include : [] + + expect( + include.some( + value => typeof value === 'string' && value.includes('../src/runtime'), + ), + ).toBe(true) + }) +}) From 3f0671d0a36b36be9d8753acb6cd190fe8db0fa3 Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Thu, 4 Jun 2026 06:05:56 +0200 Subject: [PATCH 3/4] chore: put server plugin into example dir --- example/src/runtime/server/plugins/plugin.ts | 1 + test/prepare.spec.ts | 21 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 example/src/runtime/server/plugins/plugin.ts diff --git a/example/src/runtime/server/plugins/plugin.ts b/example/src/runtime/server/plugins/plugin.ts new file mode 100644 index 00000000..9dbec430 --- /dev/null +++ b/example/src/runtime/server/plugins/plugin.ts @@ -0,0 +1 @@ +export default defineNitroPlugin(() => {}) diff --git a/test/prepare.spec.ts b/test/prepare.spec.ts index 7ef643a0..47f00954 100644 --- a/test/prepare.spec.ts +++ b/test/prepare.spec.ts @@ -1,5 +1,6 @@ import { fileURLToPath } from 'node:url' -import { cp, mkdir, readFile, rm } from 'node:fs/promises' +import { cp, mkdir, rm, writeFile } from 'node:fs/promises' +import ts from 'typescript' import { beforeAll, describe, expect, it } from 'vitest' import { exec } from 'tinyexec' import { dirname, join } from 'pathe' @@ -15,19 +16,15 @@ describe('module builder', () => { await cp(exampleDir, prepareRootDir, { recursive: true }) await exec('pnpm', ['nuxt-module-build', 'prepare', prepareRootDir], { - nodeOptions: { cwd: workspaceDir }, + nodeOptions: { cwd: workspaceDir }, }) }, 120 * 1000) - it('includes module runtime in generated server tsconfig', async () => { - const serverTsconfig = await readFile(join(prepareRootDir, '.nuxt/tsconfig.server.json'), 'utf-8') - const parsed = JSON.parse(serverTsconfig) as { include?: unknown } - const include = Array.isArray(parsed.include) ? parsed.include : [] - - expect( - include.some( - value => typeof value === 'string' && value.includes('../src/runtime'), - ), - ).toBe(true) + it('includes runtime server plugin in resolved tsconfig files', async () => { + const serverTsconfigPath = join(prepareRootDir, '.nuxt/tsconfig.server.json') + const sourceFile = ts.readJsonConfigFile(serverTsconfigPath, ts.sys.readFile) + const parsed = ts.parseJsonSourceFileConfigFileContent(sourceFile, ts.sys, dirname(serverTsconfigPath)) + const expectedPluginPath = join(prepareRootDir, 'src/runtime/server/plugins/plugin.ts') + expect(parsed.fileNames).toContain(expectedPluginPath) }) }) From 20eeca77beeac895651f5b263e45376fbdc4c49b Mon Sep 17 00:00:00 2001 From: Sebastian Landwehr Date: Thu, 4 Jun 2026 06:08:03 +0200 Subject: [PATCH 4/4] chore: lint --- test/prepare.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/prepare.spec.ts b/test/prepare.spec.ts index 47f00954..527961a3 100644 --- a/test/prepare.spec.ts +++ b/test/prepare.spec.ts @@ -1,5 +1,5 @@ import { fileURLToPath } from 'node:url' -import { cp, mkdir, rm, writeFile } from 'node:fs/promises' +import { cp, mkdir, rm } from 'node:fs/promises' import ts from 'typescript' import { beforeAll, describe, expect, it } from 'vitest' import { exec } from 'tinyexec'