@ossy/app 1.11.6 → 1.11.7

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/README.md CHANGED
@@ -21,9 +21,9 @@ export const metadata = { path: { en: '/about', sv: '/om' } }
21
21
  export default () => <h1>About</h1>
22
22
  ```
23
23
 
24
- During `dev` / `build`, the tooling writes **JSON manifests** under **`build/.ossy/`**: **`pages.generated.json`** (after compile: route ids, paths, `sourceFile`, merged `metadata`, and **`module`** — a `page-modules/<id>.mjs` path used for lazy `import()` in the browser and on SSR), **`pages.bundle.json`** (compiled module index), plus the same pattern for API and tasks. Small **`*.runtime.mjs`** loaders (copied from `@ossy/app`) load the app shell; **`pages.runtime.mjs`** exports the route table from **`pages.generated.json`** only. The server exposes compiled page modules at **`/__ossy/page-modules/`** for same-origin dynamic imports.
24
+ During `dev` / `build`, the tooling writes **JSON manifests** under **`build/.ossy/`**: **`pages.generated.json`** (after compile: route ids, paths, `sourceFile`, merged `metadata`, and **`module`** — a `page-modules/<id>.mjs` path the **Node** server `import()`s per request for SSR), **`pages.bundle.json`** (compiled module index), plus the same pattern for API and tasks. **`pages.runtime.mjs`** exports the route table from **`pages.generated.json`** only.
25
25
 
26
- **Client JS (per-page):** For each `*.page.jsx`, the build emits **`build/.ossy/hydrate-<pageId>.jsx`** → **`public/static/<pageId>.js`**. The HTML for a request only loads the hydrate script for the **current** route (full document navigation), so other pages’ components are not part of that entry. React and shared dependencies still go into hashed shared chunks. The inline config (`window.__INITIAL_APP_CONFIG__`) no longer includes the full `pages` list—only request-time fields (theme, `apiUrl`, etc.).
26
+ **Client JS (per-page):** For each `*.page.jsx`, the build emits **`build/.ossy/hydrate-<pageId>.jsx`** → **`public/static/<pageId>.js`**. Rollup bundles that entry with the page source so **`react` resolves in the browser** (unlike the Node `page-modules/*.mjs` chunks, which keep `react` external). The HTML only loads the hydrate script for the **current** route. The inline config (`window.__INITIAL_APP_CONFIG__`) keeps request-time fields (theme, `apiUrl`, etc.); `pages` in config include `id`, `path`, and `module` for consistency with the manifest.
27
27
 
28
28
  Add `src/config.js` for workspace and theme:
29
29
 
package/cli/build.js CHANGED
@@ -69,8 +69,6 @@ export const OSSY_TASKS_RUNTIME_BASENAME = 'tasks.runtime.mjs'
69
69
 
70
70
  export const OSSY_PAGE_MODULES_DIRNAME = 'page-modules'
71
71
 
72
- /** Express serves compiled page modules here for browser `import()`. Must match `server.js`. */
73
- export const OSSY_PAGE_MODULE_WEB_PREFIX = '/__ossy/page-modules'
74
72
  /** Tiny Rollup inputs that re-export `metadata` so per-page server bundles keep i18n paths. */
75
73
  export const OSSY_PAGE_SERVER_ENTRIES_DIRNAME = 'page-server-entries'
76
74
  export const OSSY_API_MODULES_DIRNAME = 'api-modules'
@@ -455,7 +453,7 @@ export async function compileTaskServerModules ({ taskFiles, ossyDir, nodeEnv, o
455
453
 
456
454
  /**
457
455
  * Merges compiled `metadata` + `module` into `pages.generated.json` (same order as `pageBundleList`).
458
- * Enables lazy `import()` in the browser and Node without putting `Component` on the route object.
456
+ * Writes `module` on each route for Node SSR (`import()` of `page-modules/*.mjs`); hydrate uses a separate Rollup client entry.
459
457
  */
460
458
  export async function enrichPagesGeneratedManifest ({
461
459
  ossyDir,
@@ -561,7 +559,7 @@ export function clientHydrateIdForPage (pageAbsPath, srcDir) {
561
559
  return idMatch ? idMatch[1] : derived.id
562
560
  }
563
561
 
564
- /** Posix path relative to `build/.ossy/` for the compiled server/browser page module. */
562
+ /** Posix path relative to `build/.ossy/` for the compiled **Node** page module (SSR). */
565
563
  export function pageServerModuleRelPath (pageAbsPath, srcDir) {
566
564
  const pageId = clientHydrateIdForPage(pageAbsPath, srcDir)
567
565
  const safeId = String(pageId).replace(/[^a-zA-Z0-9_-]+/g, '-') || 'page'
@@ -600,35 +598,26 @@ export function writePageServerRollupEntry ({ pageAbsPath, stubPath }) {
600
598
  }
601
599
 
602
600
  /**
603
- * One client entry per page: `import()` the compiled page module URL, then hydrates the document.
601
+ * One client entry per page: Rollup bundles this stub with the page source so `react` resolves in the browser.
602
+ * (Do not `import()` the Node `page-modules/*.mjs` build from the client — those files use bare `react` specifiers.)
604
603
  */
605
604
  export function generatePageHydrateModule ({ pageAbsPath, stubAbsPath, srcDir }) {
606
- void stubAbsPath
607
- const outName = path.posix.basename(pageServerModuleRelPath(pageAbsPath, srcDir))
608
- const pageImportUrl = `${OSSY_PAGE_MODULE_WEB_PREFIX}/${outName}`
609
- const pageImportLiteral = JSON.stringify(pageImportUrl)
605
+ const rel = relToGeneratedImport(stubAbsPath, pageAbsPath)
610
606
  return [
611
607
  '// Generated by @ossy/app — do not edit',
612
608
  '',
613
609
  "import React, { createElement } from 'react'",
614
610
  "import 'react-dom'",
615
611
  "import { hydrateRoot } from 'react-dom/client'",
612
+ `import * as _page from './${rel}'`,
616
613
  '',
617
- 'async function main () {',
618
- ' const initialConfig = window.__INITIAL_APP_CONFIG__ || {}',
619
- ` const _page = await import(${pageImportLiteral})`,
620
- ' const Page = _page?.default',
621
- ' if (typeof Page !== \'function\') {',
622
- ' throw new Error(`[@ossy/app] Page must export default as a function component`)',
623
- ' }',
624
- ' const rootTree = createElement(Page, initialConfig)',
625
- ' hydrateRoot(document, rootTree)',
614
+ 'const initialConfig = window.__INITIAL_APP_CONFIG__ || {}',
615
+ 'const Page = _page?.default',
616
+ 'if (typeof Page !== \'function\') {',
617
+ ' throw new Error(`[@ossy/app] Page must export default as a function component`)',
626
618
  '}',
627
- '',
628
- 'main().catch((err) => {',
629
- ' console.error(err)',
630
- " document.body.innerHTML = '<p style=\\'font-family:sans-serif;padding:1rem\\'>Hydration failed.</p>'",
631
- '})',
619
+ 'const rootTree = createElement(Page, initialConfig)',
620
+ 'hydrateRoot(document, rootTree)',
632
621
  '',
633
622
  ].join('\n')
634
623
  }
@@ -32,7 +32,7 @@ export function buildPrerenderAppConfig ({
32
32
  urlPath,
33
33
  isAuthenticated = false,
34
34
  }) {
35
- /** `module` is the lazy import path segment (see `OSSY_PAGE_MODULE_WEB_PREFIX` in the server). */
35
+ /** `module` is the compiled page path under `.ossy/` (Node `import()` only; not loaded as raw ESM in the browser). */
36
36
  const pages = pageList.map((page) => ({
37
37
  id: page?.id,
38
38
  path: page?.path,
package/cli/server.js CHANGED
@@ -38,7 +38,6 @@ const app = express();
38
38
 
39
39
  const currentDir = path.dirname(url.fileURLToPath(import.meta.url))
40
40
  const ROOT_PATH = path.resolve(currentDir, 'public')
41
- const OSSY_PAGE_MODULES_STATIC = path.resolve(currentDir, '.ossy', 'page-modules')
42
41
 
43
42
  const isDevReloadEnabled = process.env.OSSY_DEV_RELOAD === '1'
44
43
  const reloadClients = new Set()
@@ -122,10 +121,6 @@ const middleware = [
122
121
  ProxyInternal(),
123
122
  ]
124
123
 
125
- const pageModuleRouter = express.Router()
126
- pageModuleRouter.use(express.static(OSSY_PAGE_MODULES_STATIC))
127
- app.use('/__ossy/page-modules', pageModuleRouter)
128
-
129
124
  app.use(middleware)
130
125
 
131
126
  const apiRouter = OssyRouter.of({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/app",
3
- "version": "1.11.6",
3
+ "version": "1.11.7",
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.11.6",
31
- "@ossy/design-system": "^1.11.6",
32
- "@ossy/pages": "^1.11.6",
33
- "@ossy/router": "^1.11.6",
34
- "@ossy/router-react": "^1.11.6",
35
- "@ossy/sdk": "^1.11.6",
36
- "@ossy/sdk-react": "^1.11.6",
37
- "@ossy/themes": "^1.11.6",
30
+ "@ossy/connected-components": "^1.11.7",
31
+ "@ossy/design-system": "^1.11.7",
32
+ "@ossy/pages": "^1.11.7",
33
+ "@ossy/router": "^1.11.7",
34
+ "@ossy/router-react": "^1.11.7",
35
+ "@ossy/sdk": "^1.11.7",
36
+ "@ossy/sdk-react": "^1.11.7",
37
+ "@ossy/themes": "^1.11.7",
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": "f9bbe1dbd426b6ee5d07021428b900c570952ea4"
70
+ "gitHead": "43d1eca8557efc9586398a893ce9832b2ebf0444"
71
71
  }