Skip to content

Commit c7095a4

Browse files
committed
generate files if not existent
1 parent d88c3dc commit c7095a4

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

packages/nuxt/build.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { defineBuildConfig } from 'unbuild';
22

33
// Build Config for the Nuxt Module Builder: https://github.com/nuxt/module-builder
4-
export default defineBuildConfig({
5-
failOnWarn: false,
6-
});
4+
export default defineBuildConfig({});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# The Nuxt package is built in 2 steps and the nuxt-module-builder shows a warning if one of the files specified in the package.json is missing.
2+
# unbuild checks for this: https://github.com/unjs/unbuild/blob/8c647ec005a02f852e56aeef6076a35eede17df1/src/validate.ts#L81
3+
4+
# The runtime folder (which is built with the nuxt-module-builder) is separate from the rest of the package and therefore we can ignore those warnings
5+
# as those files are generated in the other build step.
6+
7+
# Create the directories if they do not exist
8+
mkdir -p build/cjs
9+
mkdir -p build/esm
10+
mkdir -p build/types
11+
12+
# Write files if they do not exist
13+
[ ! -f build/cjs/index.server.js ] && echo "module.exports = {}" > build/cjs/index.server.js
14+
[ ! -f build/cjs/index.client.js ] && echo "module.exports = {}" > build/cjs/index.client.js
15+
[ ! -f build/esm/index.server.js ] && echo "export {}" > build/esm/index.server.js
16+
[ ! -f build/esm/index.client.js ] && echo "export {}" > build/esm/index.client.js
17+
[ ! -f build/types/index.types.d.ts ] && echo "export {}" > build/types/index.types.d.ts
18+
19+
echo "Created build stubs for missing files"

packages/nuxt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"scripts": {
5959
"build": "run-s build:types build:transpile",
6060
"build:dev": "yarn build",
61-
"build:nuxt-module": "nuxt-module-build build --outDir build/module",
61+
"build:nuxt-module": "bash ./generate-build-stubs.bash && nuxt-module-build build --outDir build/module",
6262
"build:transpile": "rollup -c rollup.npm.config.mjs && yarn build:nuxt-module",
6363
"build:types": "tsc -p tsconfig.types.json",
6464
"build:watch": "run-p build:transpile:watch build:types:watch",

0 commit comments

Comments
 (0)