Skip to content

Commit

Permalink
fix: build warning of runApp is not exported (#6438)
Browse files Browse the repository at this point in the history
* fix: build warning of runApp is not exported

* chore: remove log

* fix: render
  • Loading branch information
ClarkXia authored Aug 3, 2023
1 parent 67eae5c commit 9978372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 1 addition & 5 deletions packages/ice/src/createService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ async function createService({ rootDir, command, commandArgs }: CreateServiceOpt
command,
});

let entryCode = `if (app.runApp) {
app.runApp(render, renderOptions);
} else {
render();
}`;
let entryCode = 'render();';

const generatorAPI = {
addExport: (declarationData: Omit<DeclarationData, 'declarationType'>) => {
Expand Down
14 changes: 13 additions & 1 deletion packages/ice/templates/core/entry.client.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const renderOptions: RunClientAppOptions = {
},
};

const render = (customOptions: Record<string, any> = {}) => {
const defaultRender = (customOptions: Partial<RunClientAppOptions> = {}) => {
return runClientApp({
...renderOptions,
...customOptions,
Expand All @@ -60,6 +60,18 @@ const render = (customOptions: Record<string, any> = {}) => {
});
};

const renderApp = (appExport: any, customOptions: Partial<RunClientAppOptions>) => {
if (appExport.runApp) {
return appExport.runApp(defaultRender, renderOptions);
} else {
return defaultRender(customOptions);
}
};

const render = (customOptions: Partial<RunClientAppOptions> = {}) => {
renderApp(app, customOptions);
};

<%- entryCode %>

if (import.meta.webpackHot) {
Expand Down

0 comments on commit 9978372

Please sign in to comment.