@ossy/app 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/build.js +3 -0
- package/package.json +3 -2
- package/scripts/ensure-build-stubs.mjs +36 -0
package/cli/build.js
CHANGED
|
@@ -14,6 +14,7 @@ import copy from 'rollup-plugin-copy';
|
|
|
14
14
|
import replace from '@rollup/plugin-replace';
|
|
15
15
|
import remove from 'rollup-plugin-delete';
|
|
16
16
|
import arg from 'arg'
|
|
17
|
+
import { ensureBuildStubs } from '../scripts/ensure-build-stubs.mjs'
|
|
17
18
|
// import inject from '@rollup/plugin-inject'
|
|
18
19
|
|
|
19
20
|
const PAGE_FILE_PATTERN = /\.page\.(jsx?|tsx?)$/
|
|
@@ -293,5 +294,7 @@ export const build = async (cliArgs) => {
|
|
|
293
294
|
await bundle.write(options);
|
|
294
295
|
}
|
|
295
296
|
|
|
297
|
+
ensureBuildStubs(buildPath)
|
|
298
|
+
|
|
296
299
|
console.log('[@ossy/app][build] Finished');
|
|
297
300
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/app",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -61,9 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
63
|
"/cli",
|
|
64
|
+
"/scripts",
|
|
64
65
|
"/src",
|
|
65
66
|
"README.md",
|
|
66
67
|
"tsconfig.json"
|
|
67
68
|
],
|
|
68
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "5c689da5bbcfcdb39a81f7bed613a6559468464a"
|
|
69
70
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
|
|
5
|
+
const STUBS = [
|
|
6
|
+
['api.js', 'export default []\n'],
|
|
7
|
+
['middleware.js', 'export default []\n'],
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
/** Ensures build/api.js and build/middleware.js exist when Rollup omits empty chunks. */
|
|
11
|
+
export function ensureBuildStubs(buildDir) {
|
|
12
|
+
if (!fs.existsSync(buildDir)) {
|
|
13
|
+
console.warn(`[ensure-build-stubs] skip: ${buildDir} missing`)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
for (const [name, content] of STUBS) {
|
|
17
|
+
const filePath = path.join(buildDir, name)
|
|
18
|
+
if (!fs.existsSync(filePath)) {
|
|
19
|
+
fs.writeFileSync(filePath, content)
|
|
20
|
+
console.log(`[ensure-build-stubs] wrote ${name} (rollup omitted empty chunk)`)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const isMain =
|
|
26
|
+
process.argv[1] &&
|
|
27
|
+
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
28
|
+
|
|
29
|
+
if (isMain) {
|
|
30
|
+
const buildDir = path.join(process.cwd(), 'build')
|
|
31
|
+
if (!fs.existsSync(buildDir)) {
|
|
32
|
+
console.error('[ensure-build-stubs] build/ missing; run build first')
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
ensureBuildStubs(buildDir)
|
|
36
|
+
}
|