@ossy/app 1.3.0 → 1.4.1

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.
Files changed (3) hide show
  1. package/cli/build.js +8 -18
  2. package/cli/server.js +2 -14
  3. package/package.json +10 -10
package/cli/build.js CHANGED
@@ -159,8 +159,8 @@ export function createOssyAppBundlePlugins ({ nodeEnv }) {
159
159
  }),
160
160
  json(),
161
161
  nodeExternals({
162
- deps: true,
163
- devDeps: false,
162
+ deps: false,
163
+ devDeps: true,
164
164
  peerDeps: true,
165
165
  packagePath: path.join(process.cwd(), 'package.json'),
166
166
  }),
@@ -185,8 +185,8 @@ export function createOssyClientRollupPlugins ({ nodeEnv, copyPublicFrom, buildP
185
185
  }),
186
186
  json(),
187
187
  nodeExternals({
188
- deps: true,
189
- devDeps: false,
188
+ deps: false,
189
+ devDeps: true,
190
190
  peerDeps: true,
191
191
  packagePath: path.join(process.cwd(), 'package.json'),
192
192
  }),
@@ -415,12 +415,10 @@ export function generatePageHydrateModule ({ pageAbsPath, stubAbsPath, srcDir })
415
415
  return [
416
416
  '// Generated by @ossy/app — do not edit',
417
417
  '',
418
- "import React, { cloneElement, createElement } from 'react'",
418
+ "import React, { cloneElement } from 'react'",
419
419
  "import 'react-dom'",
420
420
  "import { hydrateRoot } from 'react-dom/client'",
421
- "import { App } from '@ossy/connected-components'",
422
421
  `import * as _page from './${rel}'`,
423
- `import pageRoutes from './${OSSY_GEN_PAGES_BASENAME}'`,
424
422
  '',
425
423
  'function toPage(mod, derived) {',
426
424
  ' const meta = mod?.metadata || {}',
@@ -433,17 +431,9 @@ export function generatePageHydrateModule ({ pageAbsPath, stubAbsPath, srcDir })
433
431
  '',
434
432
  `const _route = toPage(_page, { id: ${idLiteral}, path: ${pathLiteral} })`,
435
433
  'const initialConfig = window.__INITIAL_APP_CONFIG__ || {}',
436
- 'const pagesForApp = pageRoutes.map((p) =>',
437
- ' p.id === _route.id',
438
- ' ? { ...p, element: cloneElement(p.element, initialConfig) }',
439
- ' : p',
440
- ')',
441
- 'const rootTree = createElement(App, {',
442
- ' ...initialConfig,',
443
- ' url: window.location.href,',
444
- ' pages: pagesForApp,',
445
- ' includeDocumentShell: false,',
446
- '})',
434
+ 'const rootTree = _route?.element',
435
+ ' ? cloneElement(_route.element, initialConfig)',
436
+ " : React.createElement('p', null, 'Not found')",
447
437
  'hydrateRoot(document, rootTree)',
448
438
  '',
449
439
  ].join('\n')
package/cli/server.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import path from 'path';
2
2
  import url from 'url'
3
- import React, { cloneElement, createElement } from 'react';
3
+ import React, { cloneElement } from 'react';
4
4
  import express from 'express'
5
5
  import morgan from 'morgan'
6
6
  import { Router as OssyRouter } from '@ossy/router'
7
- import { App } from '@ossy/connected-components'
8
7
  import { prerenderToNodeStream } from 'react-dom/static'
9
8
  import { ProxyInternal } from './proxy-internal.js'
10
9
  import cookieParser from 'cookie-parser'
@@ -142,18 +141,7 @@ app.all('*all', (req, res) => {
142
141
  return
143
142
  }
144
143
 
145
- const pagesForApp = pageList.map((p) =>
146
- p.id === route.id
147
- ? { ...p, element: cloneElement(p.element, appConfig) }
148
- : p
149
- )
150
- const rootElement = createElement(App, {
151
- ...appConfig,
152
- pages: pagesForApp,
153
- includeDocumentShell: false,
154
- })
155
-
156
- prerenderHtmlDocument(rootElement, appConfig, route.id)
144
+ prerenderHtmlDocument(cloneElement(route.element, appConfig), appConfig, route.id)
157
145
  .then(html => { res.send(html) })
158
146
  .catch(err => { res.send(err) })
159
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/app",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
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.3.0",
31
- "@ossy/design-system": "^1.3.0",
32
- "@ossy/pages": "^1.3.0",
33
- "@ossy/router": "^1.3.0",
34
- "@ossy/router-react": "^1.3.0",
35
- "@ossy/sdk": "^1.3.0",
36
- "@ossy/sdk-react": "^1.3.0",
37
- "@ossy/themes": "^1.3.0",
30
+ "@ossy/connected-components": "^1.4.1",
31
+ "@ossy/design-system": "^1.4.1",
32
+ "@ossy/pages": "^1.4.1",
33
+ "@ossy/router": "^1.4.1",
34
+ "@ossy/router-react": "^1.4.1",
35
+ "@ossy/sdk": "^1.4.1",
36
+ "@ossy/sdk-react": "^1.4.1",
37
+ "@ossy/themes": "^1.4.1",
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": "15e5a4ab14895064b6281eec4daf1cea3340806e"
70
+ "gitHead": "ffccd09f5b13bddbf48e2b88ebb8b9d1e02c43f1"
71
71
  }