@@ -5,12 +5,17 @@ import { RollupOptions } from 'rollup';
5
5
import { rollup , type RollupBuild } from 'rollup' ;
6
6
7
7
import {
8
+ STENCIL_APP_DATA_ID ,
8
9
STENCIL_HYDRATE_FACTORY_ID ,
9
10
STENCIL_INTERNAL_HYDRATE_ID ,
10
11
STENCIL_MOCK_DOC_ID ,
11
12
} from '../../bundle/entry-alias-ids' ;
12
13
import { bundleHydrateFactory } from './bundle-hydrate-factory' ;
13
- import { HYDRATE_FACTORY_INTRO , HYDRATE_FACTORY_OUTRO } from './hydrate-factory-closure' ;
14
+ import {
15
+ HYDRATE_FACTORY_INTRO ,
16
+ HYDRATE_FACTORY_OUTRO ,
17
+ MODE_RESOLUTION_CHAIN_DECLARATION ,
18
+ } from './hydrate-factory-closure' ;
14
19
import { updateToHydrateComponents } from './update-to-hydrate-components' ;
15
20
import { writeHydrateOutputs } from './write-hydrate-outputs' ;
16
21
@@ -50,6 +55,7 @@ export const generateHydrateApp = async (
50
55
const packageDir = join ( config . sys . getCompilerExecutingPath ( ) , '..' , '..' ) ;
51
56
const input = join ( packageDir , 'internal' , 'hydrate' , 'runner.js' ) ;
52
57
const mockDoc = join ( packageDir , 'mock-doc' , 'index.js' ) ;
58
+ const appData = join ( packageDir , 'internal' , 'app-data' , 'index.js' ) ;
53
59
54
60
const rollupOptions : RollupOptions = {
55
61
...config . rollupConfig . inputOptions ,
@@ -67,6 +73,9 @@ export const generateHydrateApp = async (
67
73
if ( id === STENCIL_MOCK_DOC_ID ) {
68
74
return mockDoc ;
69
75
}
76
+ if ( id === STENCIL_APP_DATA_ID ) {
77
+ return appData ;
78
+ }
70
79
return null ;
71
80
} ,
72
81
load ( id ) {
@@ -75,6 +84,14 @@ export const generateHydrateApp = async (
75
84
}
76
85
return null ;
77
86
} ,
87
+ transform ( code ) {
88
+ /**
89
+ * Remove the modeResolutionChain variable from the generated code.
90
+ * This variable is redefined in `HYDRATE_FACTORY_INTRO` to ensure we can
91
+ * use it within the hydrate and global runtime.
92
+ */
93
+ return code . replace ( `var ${ MODE_RESOLUTION_CHAIN_DECLARATION } ` , '' ) ;
94
+ } ,
78
95
} ,
79
96
] ,
80
97
treeshake : false ,
0 commit comments