@ossy/app 1.1.0 → 1.2.0
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 +26 -14
- package/cli/dev.js +9 -8
- package/cli/server.js +2 -2
- package/package.json +10 -10
package/cli/build.js
CHANGED
|
@@ -59,6 +59,8 @@ export const OSSY_GEN_TASKS_BASENAME = 'tasks.generated.js'
|
|
|
59
59
|
export const OSSY_PAGES_SERVER_BUNDLE = 'pages.bundle.js'
|
|
60
60
|
export const OSSY_API_SERVER_BUNDLE = 'api.bundle.js'
|
|
61
61
|
export const OSSY_TASKS_SERVER_BUNDLE = 'tasks.bundle.js'
|
|
62
|
+
export const OSSY_CONFIG_RUNTIME_BASENAME = 'config.runtime.js'
|
|
63
|
+
export const OSSY_MIDDLEWARE_RUNTIME_BASENAME = 'middleware.runtime.js'
|
|
62
64
|
|
|
63
65
|
/** Per-page client entries: `hydrate-<pageId>.jsx` under `.ossy/` */
|
|
64
66
|
const HYDRATE_STUB_PREFIX = 'hydrate-'
|
|
@@ -221,20 +223,30 @@ export async function bundleOssyNodeEntry ({ inputPath, outputFile, nodeEnv }) {
|
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
+
* Re-exports the resolved config and middleware via `file:` URLs so `src/config.js` can keep
|
|
227
|
+
* relative imports (copying those files into `build/` would break them).
|
|
226
228
|
*/
|
|
227
|
-
export function
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
229
|
+
export function writeAppRuntimeShims ({ configSourcePath, middlewareSourcePath, ossyDir }) {
|
|
230
|
+
const cfgHref = url.pathToFileURL(path.resolve(configSourcePath)).href
|
|
231
|
+
const mwHref = url.pathToFileURL(path.resolve(middlewareSourcePath)).href
|
|
232
|
+
fs.writeFileSync(
|
|
233
|
+
path.join(ossyDir, OSSY_CONFIG_RUNTIME_BASENAME),
|
|
234
|
+
`// Generated by @ossy/app — do not edit\nexport { default } from '${cfgHref}'\n`
|
|
235
|
+
)
|
|
236
|
+
fs.writeFileSync(
|
|
237
|
+
path.join(ossyDir, OSSY_MIDDLEWARE_RUNTIME_BASENAME),
|
|
238
|
+
`// Generated by @ossy/app — do not edit\nexport { default } from '${mwHref}'\n`
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Copies framework runtime into `build/`: server, worker entry, proxy.
|
|
244
|
+
* Config/middleware load via `./.ossy/config.runtime.js` and `middleware.runtime.js`.
|
|
245
|
+
*/
|
|
246
|
+
export function copyOssyAppRuntime ({ scriptDir, buildPath }) {
|
|
233
247
|
for (const name of ['server.js', 'proxy-internal.js']) {
|
|
234
248
|
fs.copyFileSync(path.join(scriptDir, name), path.join(buildPath, name))
|
|
235
249
|
}
|
|
236
|
-
fs.copyFileSync(middlewareSourcePath, path.join(buildPath, 'middleware.js'))
|
|
237
|
-
fs.copyFileSync(configSourcePath, path.join(buildPath, 'config.js'))
|
|
238
250
|
fs.copyFileSync(path.join(scriptDir, 'worker-entry.js'), path.join(buildPath, 'worker.js'))
|
|
239
251
|
fs.copyFileSync(path.join(scriptDir, 'worker-runtime.js'), path.join(buildPath, 'worker-runtime.js'))
|
|
240
252
|
}
|
|
@@ -658,12 +670,12 @@ export const build = async (cliArgs) => {
|
|
|
658
670
|
nodeEnv: 'production',
|
|
659
671
|
})
|
|
660
672
|
|
|
661
|
-
|
|
662
|
-
scriptDir,
|
|
663
|
-
buildPath,
|
|
664
|
-
middlewareSourcePath,
|
|
673
|
+
writeAppRuntimeShims({
|
|
665
674
|
configSourcePath,
|
|
675
|
+
middlewareSourcePath,
|
|
676
|
+
ossyDir,
|
|
666
677
|
})
|
|
678
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
667
679
|
|
|
668
680
|
const clientPlugins = createOssyClientRollupPlugins({
|
|
669
681
|
nodeEnv: 'production',
|
package/cli/dev.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
resetOssyBuildDir,
|
|
12
12
|
bundleOssyNodeEntry,
|
|
13
13
|
copyOssyAppRuntime,
|
|
14
|
+
writeAppRuntimeShims,
|
|
14
15
|
createOssyAppBundlePlugins,
|
|
15
16
|
createOssyClientRollupPlugins,
|
|
16
17
|
writePageHydrateStubs,
|
|
@@ -109,12 +110,12 @@ export const dev = async (cliArgs) => {
|
|
|
109
110
|
outputFile: tasksBundlePath,
|
|
110
111
|
nodeEnv: 'development',
|
|
111
112
|
})
|
|
112
|
-
|
|
113
|
-
scriptDir,
|
|
114
|
-
buildPath,
|
|
115
|
-
middlewareSourcePath,
|
|
113
|
+
writeAppRuntimeShims({
|
|
116
114
|
configSourcePath,
|
|
115
|
+
middlewareSourcePath,
|
|
116
|
+
ossyDir,
|
|
117
117
|
})
|
|
118
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
await runNodeBundles()
|
|
@@ -233,12 +234,12 @@ export const dev = async (cliArgs) => {
|
|
|
233
234
|
console.log(`[@ossy/app][dev] Built in ${event.duration}ms`)
|
|
234
235
|
}
|
|
235
236
|
if (event.code === 'END') {
|
|
236
|
-
|
|
237
|
-
scriptDir,
|
|
238
|
-
buildPath,
|
|
239
|
-
middlewareSourcePath,
|
|
237
|
+
writeAppRuntimeShims({
|
|
240
238
|
configSourcePath,
|
|
239
|
+
middlewareSourcePath,
|
|
240
|
+
ossyDir,
|
|
241
241
|
})
|
|
242
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
242
243
|
scheduleRestart()
|
|
243
244
|
}
|
|
244
245
|
})
|
package/cli/server.js
CHANGED
|
@@ -10,8 +10,8 @@ import cookieParser from 'cookie-parser'
|
|
|
10
10
|
|
|
11
11
|
import pages from './.ossy/pages.bundle.js'
|
|
12
12
|
import ApiRoutes from './.ossy/api.bundle.js'
|
|
13
|
-
import Middleware from '
|
|
14
|
-
import configModule from '
|
|
13
|
+
import Middleware from './.ossy/middleware.runtime.js'
|
|
14
|
+
import configModule from './.ossy/config.runtime.js'
|
|
15
15
|
|
|
16
16
|
const buildTimeConfig = configModule?.default ?? configModule ?? {}
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"@babel/eslint-parser": "^7.15.8",
|
|
28
28
|
"@babel/preset-react": "^7.26.3",
|
|
29
29
|
"@babel/register": "^7.25.9",
|
|
30
|
-
"@ossy/connected-components": "^1.
|
|
31
|
-
"@ossy/design-system": "^1.
|
|
32
|
-
"@ossy/pages": "^1.
|
|
33
|
-
"@ossy/router": "^1.
|
|
34
|
-
"@ossy/router-react": "^1.
|
|
35
|
-
"@ossy/sdk": "^1.
|
|
36
|
-
"@ossy/sdk-react": "^1.
|
|
37
|
-
"@ossy/themes": "^1.
|
|
30
|
+
"@ossy/connected-components": "^1.2.0",
|
|
31
|
+
"@ossy/design-system": "^1.2.0",
|
|
32
|
+
"@ossy/pages": "^1.2.0",
|
|
33
|
+
"@ossy/router": "^1.2.0",
|
|
34
|
+
"@ossy/router-react": "^1.2.0",
|
|
35
|
+
"@ossy/sdk": "^1.2.0",
|
|
36
|
+
"@ossy/sdk-react": "^1.2.0",
|
|
37
|
+
"@ossy/themes": "^1.2.0",
|
|
38
38
|
"@rollup/plugin-alias": "^6.0.0",
|
|
39
39
|
"@rollup/plugin-babel": "6.1.0",
|
|
40
40
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"README.md",
|
|
68
68
|
"tsconfig.json"
|
|
69
69
|
],
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "81441ed4d81a8ca000dc8c4a5c4634e860bfb22b"
|
|
71
71
|
}
|