File tree 3 files changed +24
-10
lines changed
3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import {
22
22
} from '../utils/path.js' ;
23
23
import { extendViteConfig } from '../utils/vite-config.js' ;
24
24
import {
25
- appendFile ,
26
25
copyFile ,
27
26
createWriteStream ,
28
27
existsSync ,
@@ -629,11 +628,18 @@ const emitStaticFiles = async (
629
628
}
630
629
await waitForTasks ( ) ;
631
630
const dynamicHtmlPaths = Array . from ( dynamicHtmlPathMap ) ;
632
- const code = `
633
- export const dynamicHtmlPaths = ${ JSON . stringify ( dynamicHtmlPaths ) } ;
634
- export const publicIndexHtml = ${ JSON . stringify ( defaultHtmlStr ) } ;
635
- ` ;
636
- await appendFile ( distEntriesFile , code ) ;
631
+ let distEntriesFileContent = await readFile ( distEntriesFile , {
632
+ encoding : 'utf8' ,
633
+ } ) ;
634
+ distEntriesFileContent = distEntriesFileContent . replace (
635
+ 'globalThis.__WAKU_DYNAMIC_HTML_PATHS__' ,
636
+ JSON . stringify ( dynamicHtmlPaths ) ,
637
+ ) ;
638
+ distEntriesFileContent = distEntriesFileContent . replace (
639
+ 'globalThis.__WAKU_PUBLIC_INDEX_HTML__' ,
640
+ JSON . stringify ( defaultHtmlStr ) ,
641
+ ) ;
642
+ await writeFile ( distEntriesFile , distEntriesFileContent ) ;
637
643
} ;
638
644
639
645
// For Deploy
Original file line number Diff line number Diff line change 1
1
import { INTERNAL_iterateSerializablePlatformData } from '../../server.js' ;
2
2
import { joinPath } from '../utils/path.js' ;
3
- import { appendFile , mkdir , writeFile } from '../utils/node-fs.js' ;
3
+ import { mkdir , readFile , writeFile } from '../utils/node-fs.js' ;
4
4
import { DIST_ENTRIES_JS } from './constants.js' ;
5
5
6
6
const DIST_PLATFORM_DATA = 'platform-data' ;
@@ -15,10 +15,14 @@ export const emitPlatformData = async (distDir: string) => {
15
15
const destFile = joinPath ( distDir , DIST_PLATFORM_DATA , key + '.js' ) ;
16
16
await writeFile ( destFile , `export default ${ JSON . stringify ( data ) } ;` ) ;
17
17
}
18
- await appendFile (
19
- joinPath ( distDir , DIST_ENTRIES_JS ) ,
18
+ const distEntriesFile = joinPath ( distDir , DIST_ENTRIES_JS ) ;
19
+ let distEntriesFileContent = await readFile ( distEntriesFile , {
20
+ encoding : 'utf8' ,
21
+ } ) ;
22
+ distEntriesFileContent = distEntriesFileContent . replace (
23
+ 'globalThis.__WAKU_LOAD_PLATFORM_DATA__' ,
20
24
`
21
- export function loadPlatformData (key) {
25
+ (key) => {
22
26
switch (key) {
23
27
${ Array . from ( keys )
24
28
. map (
@@ -31,4 +35,5 @@ export function loadPlatformData(key) {
31
35
}
32
36
` ,
33
37
) ;
38
+ await writeFile ( distEntriesFile , distEntriesFileContent ) ;
34
39
} ;
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ export function loadModule(id) {
39
39
}
40
40
globalThis.__WAKU_SERVER_IMPORT__ = loadModule;
41
41
globalThis.__WAKU_CLIENT_IMPORT__ = (id) => loadModule('${ opts . ssrDir } /' + id);
42
+ export const dynamicHtmlPaths = globalThis.__WAKU_DYNAMIC_HTML_PATHS__;
43
+ export const publicIndexHtml = globalThis.__WAKU_PUBLIC_INDEX_HTML__;
44
+ export const loadPlatformData = globalThis.__WAKU_LOAD_PLATFORM_DATA__;
42
45
` ;
43
46
let entriesFile = '' ;
44
47
let configFile = '' ;
You can’t perform that action at this time.
0 commit comments