Skip to content

Commit

Permalink
add types for app runtime support load
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Jan 4, 2021
1 parent 483762e commit 7767d28
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/xarc-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function load(
waitTo();
xReq.once("activate", () => {
clearTimeout(timer);
resolve();
resolve(null);
});
}).then(() => setupIsomorphicCdnAssetsMapping(options.isomorphicCdnOptions));
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/xarc-app/support/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "../dist/index.d";
2 changes: 1 addition & 1 deletion samples/create-app-demo/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const home = declareSubApp({
});

export const Demo2 = declareSubApp({
name: "demo1b",
name: "demo2",
getModule: () => import("./demo2")
});

Expand Down
4 changes: 2 additions & 2 deletions samples/create-app-demo/src/demo2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// A more complicate demo subapp using Redux
//
// Note: using redux requires top level Redux store initialization so if another
// subapp tries to use this as a dynamic component, then it must also redux and
// provide the redux top level store facility.
// subapp tries to use this as a dynamic component, then it must also uses redux and
// provides the redux top level store facility.
//

import { React, ReactSubApp } from "@xarc/react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { React, ReactSubApp, createDynamicComponent, staticPropsFeature } from "@xarc/react";
import electrodePng from "../static/electrode.png";
import electrodePng from "../../static/electrode.png";
import { message } from "./message";

export const Demo1 = createDynamicComponent(
{
name: "demo1",
getModule: () => import("./demo1")
getModule: () => import("../demo1")
},
{ ssr: true }
);
Expand All @@ -28,5 +28,9 @@ const Home = props => {

export const subapp: ReactSubApp = {
Component: Home,
wantFeatures: [staticPropsFeature({ serverModule: require.resolve("./home-static-props") })]
wantFeatures: [
staticPropsFeature({
serverModule: require.resolve("./static-props")
})
]
};
File renamed without changes.
15 changes: 11 additions & 4 deletions samples/create-app-demo/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { PageRenderer } from "@xarc/react";
const support = require("@xarc/app/support");
import { load } from "@xarc/app/support";
const electrodeServer = require("@xarc/fastify-server");

import { config } from "./config";
import { Demo2, home } from "../app";

async function start() {
await support.load();
await load({
isomorphicCdnOptions: {
prodOnly: true
}
});
const server = await electrodeServer(config);

let homeRenderer;
let homeRenderer: PageRenderer;

server.route({
method: "GET",
Expand All @@ -22,7 +26,10 @@ async function start() {
subApps: [
{ name: home.name, ssr: true },
{ name: Demo2.name, ssr: true }
]
],
prodAssetData: {
cdnMap: "config/assets.json"
}
});
}
const context = await homeRenderer.render({ request });
Expand Down

0 comments on commit 7767d28

Please sign in to comment.