@@ -149,29 +149,33 @@ export default function ({ config = 'wrangler.toml', platformProxy = {} } = {})
149
149
builder . writePrerendered ( bucket_dir ) ;
150
150
} ,
151
151
152
- async emulate ( ) {
153
- const proxy = await getPlatformProxy ( platformProxy ) ;
154
- const platform = /** @type {App.Platform } */ ( {
155
- env : proxy . env ,
156
- context : proxy . ctx ,
157
- caches : proxy . caches ,
158
- cf : proxy . cf
159
- } ) ;
152
+ emulate ( ) {
153
+ const getting_platform = ( async ( ) => {
154
+ const proxy = await getPlatformProxy ( platformProxy ) ;
155
+ const platform = /** @type {App.Platform } */ ( {
156
+ env : proxy . env ,
157
+ context : proxy . ctx ,
158
+ caches : proxy . caches ,
159
+ cf : proxy . cf
160
+ } ) ;
160
161
161
- /** @type {Record<string, any> } */
162
- const env = { } ;
163
- const prerender_platform = /** @type {App.Platform } */ ( /** @type {unknown } */ ( { env } ) ) ;
162
+ /** @type {Record<string, any> } */
163
+ const env = { } ;
164
+ const prerender_platform = /** @type {App.Platform } */ ( /** @type {unknown } */ ( { env } ) ) ;
164
165
165
- for ( const key in proxy . env ) {
166
- Object . defineProperty ( env , key , {
167
- get : ( ) => {
168
- throw new Error ( `Cannot access platform.env.${ key } in a prerenderable route` ) ;
169
- }
170
- } ) ;
171
- }
166
+ for ( const key in proxy . env ) {
167
+ Object . defineProperty ( env , key , {
168
+ get : ( ) => {
169
+ throw new Error ( `Cannot access platform.env.${ key } in a prerenderable route` ) ;
170
+ }
171
+ } ) ;
172
+ }
173
+ return { platform, prerender_platform } ;
174
+ } ) ( ) ;
172
175
173
176
return {
174
- platform : ( { prerender } ) => {
177
+ platform : async ( { prerender } ) => {
178
+ const { platform, prerender_platform } = await getting_platform ;
175
179
return prerender ? prerender_platform : platform ;
176
180
}
177
181
} ;
0 commit comments