@ossy/app 1.0.9 → 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 +114 -87
- package/cli/dev.js +91 -37
- package/cli/server.js +5 -5
- package/cli/worker-entry.js +1 -1
- package/package.json +10 -10
package/cli/build.js
CHANGED
|
@@ -11,7 +11,6 @@ import nodeExternals from 'rollup-plugin-node-externals'
|
|
|
11
11
|
import copy from 'rollup-plugin-copy';
|
|
12
12
|
import replace from '@rollup/plugin-replace';
|
|
13
13
|
import arg from 'arg'
|
|
14
|
-
import { ensureBuildStubs } from '../scripts/ensure-build-stubs.mjs'
|
|
15
14
|
|
|
16
15
|
export const PAGE_FILE_PATTERN = /\.page\.(jsx?|tsx?)$/
|
|
17
16
|
export const API_FILE_PATTERN = /\.api\.(mjs|cjs|js)$/
|
|
@@ -56,6 +55,13 @@ export const OSSY_GEN_PAGES_BASENAME = 'pages.generated.jsx'
|
|
|
56
55
|
export const OSSY_GEN_API_BASENAME = 'api.generated.js'
|
|
57
56
|
export const OSSY_GEN_TASKS_BASENAME = 'tasks.generated.js'
|
|
58
57
|
|
|
58
|
+
/** Bundled Node entries consumed by copied `build/server.js` / `build/worker.js`. */
|
|
59
|
+
export const OSSY_PAGES_SERVER_BUNDLE = 'pages.bundle.js'
|
|
60
|
+
export const OSSY_API_SERVER_BUNDLE = 'api.bundle.js'
|
|
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'
|
|
64
|
+
|
|
59
65
|
/** Per-page client entries: `hydrate-<pageId>.jsx` under `.ossy/` */
|
|
60
66
|
const HYDRATE_STUB_PREFIX = 'hydrate-'
|
|
61
67
|
const HYDRATE_STUB_SUFFIX = '.jsx'
|
|
@@ -143,65 +149,55 @@ export function writeResourceTemplatesBarrelIfPresent ({ cwd = process.cwd(), lo
|
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
/**
|
|
146
|
-
*
|
|
147
|
-
* Server builds pass `nodeExternals: true` so `dependencies` stay importable from Node at runtime.
|
|
152
|
+
* Rollup plugins for Node-side bundles (pages / API / tasks): externals + Babel JSX.
|
|
148
153
|
*/
|
|
149
|
-
export function
|
|
150
|
-
|
|
151
|
-
apiSourcePath,
|
|
152
|
-
middlewareSourcePath,
|
|
153
|
-
configSourcePath,
|
|
154
|
-
nodeEnv,
|
|
155
|
-
preferBuiltins = true,
|
|
156
|
-
copyPublicFrom,
|
|
157
|
-
buildPath,
|
|
158
|
-
}) {
|
|
159
|
-
const plugins = [
|
|
160
|
-
replace({
|
|
161
|
-
preventAssignment: true,
|
|
162
|
-
delimiters: ['%%', '%%'],
|
|
163
|
-
'@ossy/pages/source-file': pagesGeneratedPath,
|
|
164
|
-
}),
|
|
154
|
+
export function createOssyAppBundlePlugins ({ nodeEnv }) {
|
|
155
|
+
return [
|
|
165
156
|
replace({
|
|
166
157
|
preventAssignment: true,
|
|
167
|
-
|
|
168
|
-
'@ossy/api/source-file': apiSourcePath,
|
|
158
|
+
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
169
159
|
}),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
json(),
|
|
161
|
+
nodeExternals({
|
|
162
|
+
deps: true,
|
|
163
|
+
devDeps: false,
|
|
164
|
+
peerDeps: true,
|
|
165
|
+
packagePath: path.join(process.cwd(), 'package.json'),
|
|
174
166
|
}),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
'
|
|
167
|
+
resolveCommonJsDependencies(),
|
|
168
|
+
resolveDependencies({ preferBuiltins: true }),
|
|
169
|
+
babel({
|
|
170
|
+
babelHelpers: 'bundled',
|
|
171
|
+
extensions: ['.jsx', '.tsx'],
|
|
172
|
+
presets: ['@babel/preset-react'],
|
|
179
173
|
}),
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Rollup plugins for browser hydrate bundles.
|
|
179
|
+
*/
|
|
180
|
+
export function createOssyClientRollupPlugins ({ nodeEnv, copyPublicFrom, buildPath }) {
|
|
181
|
+
const plugins = [
|
|
180
182
|
replace({
|
|
181
183
|
preventAssignment: true,
|
|
182
184
|
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
183
185
|
}),
|
|
184
186
|
json(),
|
|
185
|
-
]
|
|
186
|
-
|
|
187
|
-
plugins.push(
|
|
188
187
|
nodeExternals({
|
|
189
188
|
deps: true,
|
|
190
189
|
devDeps: false,
|
|
191
190
|
peerDeps: true,
|
|
192
191
|
packagePath: path.join(process.cwd(), 'package.json'),
|
|
193
|
-
})
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
plugins.push(
|
|
192
|
+
}),
|
|
197
193
|
resolveCommonJsDependencies(),
|
|
198
|
-
resolveDependencies({ preferBuiltins }),
|
|
194
|
+
resolveDependencies({ preferBuiltins: false }),
|
|
199
195
|
babel({
|
|
200
196
|
babelHelpers: 'bundled',
|
|
201
197
|
extensions: ['.jsx', '.tsx'],
|
|
202
198
|
presets: ['@babel/preset-react'],
|
|
203
|
-
})
|
|
204
|
-
|
|
199
|
+
}),
|
|
200
|
+
]
|
|
205
201
|
if (copyPublicFrom && fs.existsSync(copyPublicFrom)) {
|
|
206
202
|
plugins.push(
|
|
207
203
|
copy({
|
|
@@ -212,6 +208,49 @@ export function createOssyRollupPlugins ({
|
|
|
212
208
|
return plugins
|
|
213
209
|
}
|
|
214
210
|
|
|
211
|
+
/** Bundles a single Node ESM file (inline dynamic imports) for SSR / API / tasks. */
|
|
212
|
+
export async function bundleOssyNodeEntry ({ inputPath, outputFile, nodeEnv }) {
|
|
213
|
+
const bundle = await rollup({
|
|
214
|
+
input: inputPath,
|
|
215
|
+
plugins: createOssyAppBundlePlugins({ nodeEnv }),
|
|
216
|
+
})
|
|
217
|
+
await bundle.write({
|
|
218
|
+
file: outputFile,
|
|
219
|
+
format: 'esm',
|
|
220
|
+
inlineDynamicImports: true,
|
|
221
|
+
})
|
|
222
|
+
await bundle.close()
|
|
223
|
+
}
|
|
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).
|
|
228
|
+
*/
|
|
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 }) {
|
|
247
|
+
for (const name of ['server.js', 'proxy-internal.js']) {
|
|
248
|
+
fs.copyFileSync(path.join(scriptDir, name), path.join(buildPath, name))
|
|
249
|
+
}
|
|
250
|
+
fs.copyFileSync(path.join(scriptDir, 'worker-entry.js'), path.join(buildPath, 'worker.js'))
|
|
251
|
+
fs.copyFileSync(path.join(scriptDir, 'worker-runtime.js'), path.join(buildPath, 'worker-runtime.js'))
|
|
252
|
+
}
|
|
253
|
+
|
|
215
254
|
/**
|
|
216
255
|
* Recursively lists files under `srcDir` whose basename matches `filePattern` (e.g. `/\.api\.js$/`).
|
|
217
256
|
*/
|
|
@@ -320,26 +359,20 @@ export function generateTaskModule ({ generatedPath, taskFiles }) {
|
|
|
320
359
|
}
|
|
321
360
|
|
|
322
361
|
/**
|
|
323
|
-
*
|
|
362
|
+
* Writes `build/.ossy/tasks.generated.js` and returns its path (stable Rollup input; empty when no task files).
|
|
324
363
|
*/
|
|
325
|
-
export function resolveTaskSource ({ srcDir,
|
|
326
|
-
const defaultStub = path.resolve(scriptDir, 'tasks.js')
|
|
364
|
+
export function resolveTaskSource ({ srcDir, buildPath }) {
|
|
327
365
|
ensureOssyGeneratedDir(buildPath)
|
|
328
366
|
const generatedPath = path.join(ossyGeneratedDir(buildPath), OSSY_GEN_TASKS_BASENAME)
|
|
329
|
-
|
|
330
367
|
const taskFiles = discoverFilesByPattern(srcDir, TASK_FILE_PATTERN)
|
|
331
|
-
|
|
332
|
-
|
|
368
|
+
fs.writeFileSync(
|
|
369
|
+
generatedPath,
|
|
370
|
+
generateTaskModule({
|
|
333
371
|
generatedPath,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
)
|
|
339
|
-
return { taskSourcePath: generatedPath, taskOverviewFiles: taskFiles, usedGenerated: true }
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return { taskSourcePath: defaultStub, taskOverviewFiles: [], usedGenerated: false }
|
|
372
|
+
taskFiles,
|
|
373
|
+
})
|
|
374
|
+
)
|
|
375
|
+
return { taskSourcePath: generatedPath, taskOverviewFiles: taskFiles }
|
|
343
376
|
}
|
|
344
377
|
|
|
345
378
|
export function filePathToRoute(filePath, srcDir) {
|
|
@@ -600,8 +633,6 @@ export const build = async (cliArgs) => {
|
|
|
600
633
|
let middlewareSourcePath = path.resolve('src/middleware.js');
|
|
601
634
|
const publicDir = path.resolve('public')
|
|
602
635
|
|
|
603
|
-
const inputServer = path.resolve(scriptDir, 'server.js')
|
|
604
|
-
|
|
605
636
|
printBuildOverview({
|
|
606
637
|
pagesSourcePath: pagesGeneratedPath,
|
|
607
638
|
apiSourcePath,
|
|
@@ -618,40 +649,38 @@ export const build = async (cliArgs) => {
|
|
|
618
649
|
? configPath
|
|
619
650
|
: path.resolve(scriptDir, 'default-config.js')
|
|
620
651
|
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
middlewareSourcePath,
|
|
625
|
-
configSourcePath,
|
|
626
|
-
nodeEnv: 'production',
|
|
627
|
-
buildPath,
|
|
628
|
-
}
|
|
652
|
+
const pagesBundlePath = path.join(ossyDir, OSSY_PAGES_SERVER_BUNDLE)
|
|
653
|
+
const apiBundlePath = path.join(ossyDir, OSSY_API_SERVER_BUNDLE)
|
|
654
|
+
const tasksBundlePath = path.join(ossyDir, OSSY_TASKS_SERVER_BUNDLE)
|
|
629
655
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
656
|
+
await bundleOssyNodeEntry({
|
|
657
|
+
inputPath: pagesGeneratedPath,
|
|
658
|
+
outputFile: pagesBundlePath,
|
|
659
|
+
nodeEnv: 'production',
|
|
634
660
|
})
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
661
|
+
await bundleOssyNodeEntry({
|
|
662
|
+
inputPath: apiSourcePath,
|
|
663
|
+
outputFile: apiBundlePath,
|
|
664
|
+
nodeEnv: 'production',
|
|
639
665
|
})
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
entryFileNames ({ name }) {
|
|
646
|
-
return name === 'server' ? 'server.js' : '[name].js'
|
|
647
|
-
},
|
|
648
|
-
assetFileNames: '[name][extname]',
|
|
666
|
+
const { taskSourcePath } = resolveTaskSource({ srcDir, buildPath })
|
|
667
|
+
await bundleOssyNodeEntry({
|
|
668
|
+
inputPath: taskSourcePath,
|
|
669
|
+
outputFile: tasksBundlePath,
|
|
670
|
+
nodeEnv: 'production',
|
|
649
671
|
})
|
|
650
|
-
await serverBundle.close()
|
|
651
672
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
673
|
+
writeAppRuntimeShims({
|
|
674
|
+
configSourcePath,
|
|
675
|
+
middlewareSourcePath,
|
|
676
|
+
ossyDir,
|
|
677
|
+
})
|
|
678
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
679
|
+
|
|
680
|
+
const clientPlugins = createOssyClientRollupPlugins({
|
|
681
|
+
nodeEnv: 'production',
|
|
682
|
+
copyPublicFrom: publicDir,
|
|
683
|
+
buildPath,
|
|
655
684
|
})
|
|
656
685
|
|
|
657
686
|
if (Object.keys(clientHydrateInput).length > 0) {
|
|
@@ -675,7 +704,5 @@ export const build = async (cliArgs) => {
|
|
|
675
704
|
await clientBundle.close()
|
|
676
705
|
}
|
|
677
706
|
|
|
678
|
-
ensureBuildStubs(buildPath)
|
|
679
|
-
|
|
680
707
|
console.log('[@ossy/app][build] Finished');
|
|
681
708
|
};
|
package/cli/dev.js
CHANGED
|
@@ -7,14 +7,23 @@ import {
|
|
|
7
7
|
PAGE_FILE_PATTERN,
|
|
8
8
|
generatePagesModule,
|
|
9
9
|
resolveApiSource,
|
|
10
|
+
resolveTaskSource,
|
|
10
11
|
resetOssyBuildDir,
|
|
11
|
-
|
|
12
|
+
bundleOssyNodeEntry,
|
|
13
|
+
copyOssyAppRuntime,
|
|
14
|
+
writeAppRuntimeShims,
|
|
15
|
+
createOssyAppBundlePlugins,
|
|
16
|
+
createOssyClientRollupPlugins,
|
|
12
17
|
writePageHydrateStubs,
|
|
13
18
|
buildClientHydrateInput,
|
|
14
19
|
clientHydrateIdForPage,
|
|
15
20
|
ossyGeneratedDir,
|
|
16
21
|
OSSY_GEN_PAGES_BASENAME,
|
|
17
22
|
OSSY_GEN_API_BASENAME,
|
|
23
|
+
OSSY_GEN_TASKS_BASENAME,
|
|
24
|
+
OSSY_PAGES_SERVER_BUNDLE,
|
|
25
|
+
OSSY_API_SERVER_BUNDLE,
|
|
26
|
+
OSSY_TASKS_SERVER_BUNDLE,
|
|
18
27
|
writeResourceTemplatesBarrelIfPresent,
|
|
19
28
|
resourceTemplatesDir,
|
|
20
29
|
OSSY_RESOURCE_TEMPLATES_OUT,
|
|
@@ -48,7 +57,6 @@ export const dev = async (cliArgs) => {
|
|
|
48
57
|
pagesGeneratedPath,
|
|
49
58
|
generatePagesModule(pageFiles, srcDir, pagesGeneratedPath)
|
|
50
59
|
)
|
|
51
|
-
const effectivePagesSource = pagesGeneratedPath
|
|
52
60
|
const ossyDir = ossyGeneratedDir(buildPath)
|
|
53
61
|
writePageHydrateStubs(pageFiles, srcDir, ossyDir)
|
|
54
62
|
const clientHydrateInput = buildClientHydrateInput(pageFiles, srcDir, ossyDir)
|
|
@@ -61,13 +69,12 @@ export const dev = async (cliArgs) => {
|
|
|
61
69
|
buildPath,
|
|
62
70
|
})
|
|
63
71
|
let apiSourcePath = resolvedApi
|
|
72
|
+
resolveTaskSource({ srcDir, buildPath })
|
|
64
73
|
let middlewareSourcePath = path.resolve(options['--middleware-source'] || 'src/middleware.js');
|
|
65
74
|
const publicDir = path.resolve('public')
|
|
66
75
|
|
|
67
|
-
const inputServer = path.resolve(scriptDir, 'server.js')
|
|
68
|
-
|
|
69
76
|
printBuildOverview({
|
|
70
|
-
pagesSourcePath:
|
|
77
|
+
pagesSourcePath: pagesGeneratedPath,
|
|
71
78
|
apiSourcePath,
|
|
72
79
|
apiOverviewFiles,
|
|
73
80
|
configPath,
|
|
@@ -82,37 +89,43 @@ export const dev = async (cliArgs) => {
|
|
|
82
89
|
? configPath
|
|
83
90
|
: path.resolve(scriptDir, 'default-config.js')
|
|
84
91
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
const pagesBundlePath = path.join(ossyDir, OSSY_PAGES_SERVER_BUNDLE)
|
|
93
|
+
const apiBundlePath = path.join(ossyDir, OSSY_API_SERVER_BUNDLE)
|
|
94
|
+
const tasksBundlePath = path.join(ossyDir, OSSY_TASKS_SERVER_BUNDLE)
|
|
95
|
+
const tasksGeneratedPath = path.join(ossyDir, OSSY_GEN_TASKS_BASENAME)
|
|
96
|
+
|
|
97
|
+
const runNodeBundles = async () => {
|
|
98
|
+
await bundleOssyNodeEntry({
|
|
99
|
+
inputPath: pagesGeneratedPath,
|
|
100
|
+
outputFile: pagesBundlePath,
|
|
101
|
+
nodeEnv: 'development',
|
|
102
|
+
})
|
|
103
|
+
await bundleOssyNodeEntry({
|
|
104
|
+
inputPath: apiSourcePath,
|
|
105
|
+
outputFile: apiBundlePath,
|
|
106
|
+
nodeEnv: 'development',
|
|
107
|
+
})
|
|
108
|
+
await bundleOssyNodeEntry({
|
|
109
|
+
inputPath: tasksGeneratedPath,
|
|
110
|
+
outputFile: tasksBundlePath,
|
|
111
|
+
nodeEnv: 'development',
|
|
112
|
+
})
|
|
113
|
+
writeAppRuntimeShims({
|
|
114
|
+
configSourcePath,
|
|
115
|
+
middlewareSourcePath,
|
|
116
|
+
ossyDir,
|
|
117
|
+
})
|
|
118
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
|
|
95
|
-
...sharedPluginOpts,
|
|
96
|
-
preferBuiltins: true,
|
|
97
|
-
copyPublicFrom: publicDir,
|
|
98
|
-
})
|
|
121
|
+
await runNodeBundles()
|
|
99
122
|
|
|
100
|
-
const clientPlugins =
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
const clientPlugins = createOssyClientRollupPlugins({
|
|
124
|
+
nodeEnv: 'development',
|
|
125
|
+
copyPublicFrom: publicDir,
|
|
126
|
+
buildPath,
|
|
103
127
|
})
|
|
104
128
|
|
|
105
|
-
const serverOutput = {
|
|
106
|
-
dir: buildPath,
|
|
107
|
-
format: 'esm',
|
|
108
|
-
preserveModules: true,
|
|
109
|
-
preserveModulesRoot: path.dirname(inputServer),
|
|
110
|
-
entryFileNames ({ name }) {
|
|
111
|
-
return name === 'server' ? 'server.js' : '[name].js'
|
|
112
|
-
},
|
|
113
|
-
assetFileNames: '[name][extname]',
|
|
114
|
-
}
|
|
115
|
-
|
|
116
129
|
const clientOutput = {
|
|
117
130
|
dir: buildPath,
|
|
118
131
|
format: 'esm',
|
|
@@ -167,12 +180,37 @@ export const dev = async (cliArgs) => {
|
|
|
167
180
|
}
|
|
168
181
|
}
|
|
169
182
|
|
|
183
|
+
const nodeWatchOpts = { watch: { clearScreen: false } }
|
|
170
184
|
const watchConfigs = [
|
|
171
185
|
{
|
|
172
|
-
input:
|
|
173
|
-
output:
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
input: pagesGeneratedPath,
|
|
187
|
+
output: {
|
|
188
|
+
file: pagesBundlePath,
|
|
189
|
+
format: 'esm',
|
|
190
|
+
inlineDynamicImports: true,
|
|
191
|
+
},
|
|
192
|
+
plugins: createOssyAppBundlePlugins({ nodeEnv: 'development' }),
|
|
193
|
+
...nodeWatchOpts,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
input: apiSourcePath,
|
|
197
|
+
output: {
|
|
198
|
+
file: apiBundlePath,
|
|
199
|
+
format: 'esm',
|
|
200
|
+
inlineDynamicImports: true,
|
|
201
|
+
},
|
|
202
|
+
plugins: createOssyAppBundlePlugins({ nodeEnv: 'development' }),
|
|
203
|
+
...nodeWatchOpts,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
input: tasksGeneratedPath,
|
|
207
|
+
output: {
|
|
208
|
+
file: tasksBundlePath,
|
|
209
|
+
format: 'esm',
|
|
210
|
+
inlineDynamicImports: true,
|
|
211
|
+
},
|
|
212
|
+
plugins: createOssyAppBundlePlugins({ nodeEnv: 'development' }),
|
|
213
|
+
...nodeWatchOpts,
|
|
176
214
|
},
|
|
177
215
|
]
|
|
178
216
|
if (Object.keys(clientHydrateInput).length > 0) {
|
|
@@ -196,11 +234,17 @@ export const dev = async (cliArgs) => {
|
|
|
196
234
|
console.log(`[@ossy/app][dev] Built in ${event.duration}ms`)
|
|
197
235
|
}
|
|
198
236
|
if (event.code === 'END') {
|
|
237
|
+
writeAppRuntimeShims({
|
|
238
|
+
configSourcePath,
|
|
239
|
+
middlewareSourcePath,
|
|
240
|
+
ossyDir,
|
|
241
|
+
})
|
|
242
|
+
copyOssyAppRuntime({ scriptDir, buildPath })
|
|
199
243
|
scheduleRestart()
|
|
200
244
|
}
|
|
201
245
|
})
|
|
202
246
|
|
|
203
|
-
const
|
|
247
|
+
const regenApiGenerated = () => {
|
|
204
248
|
if (options['--api-source']) return
|
|
205
249
|
resolveApiSource({
|
|
206
250
|
srcDir,
|
|
@@ -212,6 +256,13 @@ export const dev = async (cliArgs) => {
|
|
|
212
256
|
}
|
|
213
257
|
}
|
|
214
258
|
|
|
259
|
+
const regenTasksGenerated = () => {
|
|
260
|
+
resolveTaskSource({ srcDir, buildPath })
|
|
261
|
+
if (fs.existsSync(tasksGeneratedPath) && typeof watcher?.invalidate === 'function') {
|
|
262
|
+
watcher.invalidate(tasksGeneratedPath)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
215
266
|
fs.watch(srcDir, { recursive: true }, (eventType, filename) => {
|
|
216
267
|
if (!filename) return
|
|
217
268
|
if (/\.page\.(jsx?|tsx?)$/.test(filename)) {
|
|
@@ -228,7 +279,10 @@ export const dev = async (cliArgs) => {
|
|
|
228
279
|
}
|
|
229
280
|
}
|
|
230
281
|
if (/\.api\.(mjs|cjs|js)$/.test(filename)) {
|
|
231
|
-
|
|
282
|
+
regenApiGenerated()
|
|
283
|
+
}
|
|
284
|
+
if (/\.task\.(mjs|cjs|js)$/.test(filename)) {
|
|
285
|
+
regenTasksGenerated()
|
|
232
286
|
}
|
|
233
287
|
const norm = filename.replace(/\\/g, '/')
|
|
234
288
|
if (/\.resource\.js$/.test(norm) && norm.includes('resource-templates/')) {
|
package/cli/server.js
CHANGED
|
@@ -8,14 +8,14 @@ import { prerenderToNodeStream } from 'react-dom/static'
|
|
|
8
8
|
import { ProxyInternal } from './proxy-internal.js'
|
|
9
9
|
import cookieParser from 'cookie-parser'
|
|
10
10
|
|
|
11
|
-
import pages from '
|
|
12
|
-
import ApiRoutes from '
|
|
13
|
-
import Middleware from '
|
|
14
|
-
import configModule from '
|
|
11
|
+
import pages from './.ossy/pages.bundle.js'
|
|
12
|
+
import ApiRoutes from './.ossy/api.bundle.js'
|
|
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
|
|
|
18
|
-
/**
|
|
18
|
+
/** API bundle default may be an empty array. */
|
|
19
19
|
const apiRouteList = ApiRoutes ?? []
|
|
20
20
|
const pageList = pages ?? []
|
|
21
21
|
|
package/cli/worker-entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/app",
|
|
3
|
-
"version": "1.0
|
|
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.0
|
|
31
|
-
"@ossy/design-system": "^1.0
|
|
32
|
-
"@ossy/pages": "^1.0
|
|
33
|
-
"@ossy/router": "^1.0
|
|
34
|
-
"@ossy/router-react": "^1.0
|
|
35
|
-
"@ossy/sdk": "^1.0
|
|
36
|
-
"@ossy/sdk-react": "^1.0
|
|
37
|
-
"@ossy/themes": "^1.0
|
|
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
|
}
|