Skip to content

Commit

Permalink
chore: add guard for docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 25, 2022
1 parent ebfe437 commit f62713e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion interactive/package.json
Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions 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('<NuxtPage/> found in the entry file, the components are probably not registed correctly')
7 changes: 6 additions & 1 deletion interactive/tsconfig.json
Expand Up @@ -4,7 +4,12 @@
"strict": true,
"strictNullChecks": true,
"types": [
"node",
"vite/client"
]
}
},
"exclude": [
"node_modules",
"dist"
]
}

0 comments on commit f62713e

Please sign in to comment.