@@ -34,6 +34,7 @@ const ENTRY_POINTS = {
34
34
webview : {
35
35
entryPoint : './src/webview/index.ts' ,
36
36
html : true ,
37
+ inlineBundle : true ,
37
38
} ,
38
39
} ;
39
40
@@ -99,18 +100,30 @@ async function main() {
99
100
<html>
100
101
<head>
101
102
<meta charset="utf-8" />
102
- <title>MetaMask Snaps Iframe Execution Environment</title>
103
+ <title>MetaMask Snaps Execution Environment</title>
103
104
<script>${ lavaMoatRuntimeBrowser } </script>
104
105
</head>
105
106
<body>
106
107
<script src="bundle.js"></script>
107
108
</body>
108
109
</html>` ;
109
110
111
+ const createInlinedHTML = ( bundleSource ) => `<!DOCTYPE html>
112
+ <html>
113
+ <head>
114
+ <meta charset="utf-8" />
115
+ <title>MetaMask Snaps Execution Environment</title>
116
+ <script>${ lavaMoatRuntimeBrowser } </script>
117
+ </head>
118
+ <body>
119
+ <script>${ bundleSource } </script>
120
+ </body>
121
+ </html>` ;
122
+
110
123
await Promise . all (
111
124
Object . entries ( ENTRY_POINTS ) . map ( async ( [ key , config ] ) => {
112
125
console . log ( 'Bundling' , key ) ;
113
- const { html, node, worker, entryPoint } = config ;
126
+ const { html, node, worker, entryPoint, inlineBundle } = config ;
114
127
const insertGlobalVars = node
115
128
? { process : undefined , ...LavaMoatBrowserify . args . insertGlobalVars }
116
129
: LavaMoatBrowserify . args . insertGlobalVars ;
@@ -218,14 +231,19 @@ async function main() {
218
231
outputBundle = `${ runtime } \n${ outputBundle } ` ;
219
232
}
220
233
221
- const bundlePath = path . join ( OUTPUT_PATH , key , OUTPUT_BUNDLE ) ;
222
- await fs . mkdir ( path . dirname ( bundlePath ) , { recursive : true } ) ;
223
- await fs . writeFile ( bundlePath , outputBundle ) ;
234
+ if ( ! inlineBundle ) {
235
+ const bundlePath = path . join ( OUTPUT_PATH , key , OUTPUT_BUNDLE ) ;
236
+ await fs . mkdir ( path . dirname ( bundlePath ) , { recursive : true } ) ;
237
+ await fs . writeFile ( bundlePath , outputBundle ) ;
238
+ }
224
239
225
240
if ( html ) {
226
241
const htmlPath = path . join ( OUTPUT_PATH , key , OUTPUT_HTML ) ;
227
242
await fs . mkdir ( path . dirname ( htmlPath ) , { recursive : true } ) ;
228
- await fs . writeFile ( htmlPath , htmlFile ) ;
243
+ await fs . writeFile (
244
+ htmlPath ,
245
+ inlineBundle ? createInlinedHTML ( outputBundle ) : htmlFile ,
246
+ ) ;
229
247
}
230
248
231
249
const outputBytes = stringToBytes ( outputBundle ) ;
0 commit comments