@@ -33,14 +33,6 @@ <h3>rollup example</h3>
3333 var packages = [ 'acorn' ] ;
3434 var filename = 'acorn.js' ;
3535
36- files [ 'entry.js' ] = `
37-
38- import * as acorn from 'acorn';
39- export {acorn};
40-
41- //export default espree; // iife / umd
42-
43- ` ;
4436
4537
4638
@@ -93,23 +85,25 @@ <h3>rollup example</h3>
9385
9486 await rollup ( ) ;
9587
96- var uint8 = await webcontainer . fs . readFile ( 'acorn.m.js' ) ;
88+ var uint8 = await webcontainer . fs . readFile ( filename ) ;
9789 var blob = new Blob ( [ uint8 ] , { type :'text/javascript' } ) ;
9890 var url = window . URL . createObjectURL ( blob ) ;
9991
100- console . log ( 'download...' ) ;
101-
102- var a = document . createElement ( 'a' ) ;
103- a . href = url ;
104- a . download = 'acorn.m.js' ;
105- document . body . append ( a ) ;
106- a . click ( ) ;
10792
108- console . log ( 'done' ) ;
109- return ;
93+ if ( 1 ) {
94+ console . log ( 'download...' ) ;
95+
96+ var a = document . createElement ( 'a' ) ;
97+ a . href = url ;
98+ a . download = 'acorn.m.js' ;
99+ document . body . append ( a ) ;
100+ a . click ( ) ;
101+
102+ console . log ( 'done' ) ;
103+ return ;
104+ }
110105
111- var { espree} = await import ( 'https://libs.ext-code.com/external/js/espree/espree.m.js' ) ;
112- var { estraverse} = await import ( url ) ;
106+ var { acorn} = await import ( url ) ;
113107
114108 var code = `
115109
@@ -121,8 +115,12 @@ <h3>rollup example</h3>
121115
122116 ` ;
123117
124- var ast = espree . parse ( code ) ;
118+ var ast = acorn . parse ( code ) ;
119+ console . log ( ast ) ;
125120
121+
122+
123+ /*
126124 estraverse.traverse(ast, {
127125 enter(node) {
128126 if (node.type === 'FunctionDeclaration') {
@@ -139,9 +137,10 @@ <h3>rollup example</h3>
139137 }
140138 }
141139 });
142-
143-
144-
140+ */
141+
142+
143+
145144 console . log ( 'done.' ) ;
146145
147146
@@ -221,6 +220,16 @@ <h3>rollup example</h3>
221220 //:
222221
223222
223+ files [ 'entry.js' ] = `
224+
225+ import * as acorn from 'acorn';
226+ //export {acorn};
227+
228+ export default espree; // iife / umd
229+
230+ ` ;
231+
232+
224233 files [ 'package.json' ] = `
225234
226235 {
@@ -243,11 +252,11 @@ <h3>rollup example</h3>
243252 input : 'entry.js',
244253 output : {
245254 file : '${ filename } ',
246- format : 'es'
255+ // format : 'es'
247256
248- // format : 'iife', // or 'umd'
249- // name : 'espree', // This becomes window.espree
250- // exports : 'default',
257+ format : 'iife', // or 'umd'
258+ name : 'espree', // This becomes window.espree
259+ exports : 'default',
251260
252261 },
253262 plugins : [
0 commit comments