Skip to content

Commit 8a55466

Browse files
save file
1 parent dbc9de9 commit 8a55466

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

npm/espree-browser/scripts/espree-browser-esm.html

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,16 @@
108108

109109

110110
await rollup.esm();
111+
//await rollup.cjs();
112+
111113

112114
var uint8 = await webcontainer.fs.readFile(filename);
113115
var blob = new Blob([uint8],{type:'text/javascript'});
114-
var txt = await blob.text();
116+
var url = window.URL.createObjectURL(blob);
117+
//var txt = await blob.text();
118+
115119

120+
test.esm(url);
116121

117122

118123

@@ -214,9 +219,8 @@
214219

215220

216221

217-
test.esm = function(){
222+
test.esm = async function(url){
218223

219-
var url = window.URL.createObjectURL(blob);
220224
var {espree} = await import(url);
221225
console.log(espree);
222226

@@ -236,6 +240,35 @@
236240

237241
}//test
238242

243+
244+
test.cjs = async function(url){
245+
246+
var script = document.createElement('script');
247+
script.src = url;
248+
script.onload = onload;
249+
document.head.append(script);
250+
251+
252+
function onload(){
253+
254+
var code = `
255+
256+
function fn(){
257+
258+
console.log('helloworld');
259+
260+
}//fn
261+
262+
`;
263+
264+
var result = espree.parse(code);
265+
console.log(result);
266+
267+
}//onload
268+
269+
}//cjs
270+
271+
239272
}//ready
240273

241274

0 commit comments

Comments
 (0)