File tree Expand file tree Collapse file tree
npm/espree-browser/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
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
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
You can’t perform that action at this time.
0 commit comments