diff --git a/interactive/package.json b/interactive/package.json index ea32773f53..9e7770c586 100644 --- a/interactive/package.json +++ b/interactive/package.json @@ -3,7 +3,7 @@ "type": "module", "private": true, "scripts": { - "build": "nuxi generate .", + "build": "nuxi generate . && esno scripts/verify-build.ts", "dev": "nuxi dev .", "start": "node .output/server/index.mjs", "postinstall": "esno scripts/prepare.ts", diff --git a/interactive/scripts/verify-build.ts b/interactive/scripts/verify-build.ts new file mode 100644 index 0000000000..3e628e18d6 --- /dev/null +++ b/interactive/scripts/verify-build.ts @@ -0,0 +1,24 @@ +import { dirname, join } from 'path' +import { fileURLToPath } from 'url' +import { promises as fs } from 'fs' +import fg from 'fast-glob' + +const dir = dirname(fileURLToPath(import.meta.url)) + +const files = await fg('entry-*.mjs', { + cwd: join(dir, '../dist/_nuxt'), + absolute: true, + onlyFiles: true, +}) + +if (!files.length) + throw new Error('No entry file found under dist/_nuxt/') + +if (files.length !== 1) + throw new Error('Multiple entry files found under dist/_nuxt/') + +const file = files[0] +const content = await fs.readFile(file, 'utf8') + +if (content.includes('NuxtPage')) + throw new Error(' found in the entry file, the components are probably not registed correctly') diff --git a/interactive/tsconfig.json b/interactive/tsconfig.json index cceda096dc..7854ab1ca3 100644 --- a/interactive/tsconfig.json +++ b/interactive/tsconfig.json @@ -4,7 +4,12 @@ "strict": true, "strictNullChecks": true, "types": [ + "node", "vite/client" ] - } + }, + "exclude": [ + "node_modules", + "dist" + ] }