11var path = require ( 'path' ) ;
22var fs = require ( 'fs' ) ;
33
4- var falafel = require ( 'falafel' ) ;
54var gzipSize = require ( 'gzip-size' ) ;
65var prettySize = require ( 'prettysize' ) ;
76
@@ -11,7 +10,6 @@ var pkg = require('../package.json');
1110
1211var pathDistREADME = path . join ( constants . pathToDist , 'README.md' ) ;
1312var cdnRoot = 'https://cdn.plot.ly/plotly-' ;
14- var coreModules = [ 'scatter' ] ;
1513
1614var ENC = 'utf-8' ;
1715var JS = '.js' ;
@@ -156,12 +154,12 @@ function makeBundleHeaderInfo(pathObj) {
156154function makeBundleInfo ( pathObj ) {
157155 var name = pathObj . name ;
158156 var sizes = findSizes ( pathObj ) ;
159- var moduleList = coreModules . concat ( scrapeContent ( pathObj ) ) ;
157+ var moduleList = common . findModuleList ( pathObj . index ) ;
160158
161159 return [
162160 '### plotly.js ' + name ,
163161 '' ,
164- formatBundleInfo ( name , moduleList ) ,
162+ 'The `' + name + '` partial bundle contains trace modules ' + common . formatEnumeration ( moduleList ) + '.' ,
165163 '' ,
166164 '| Way to import | Location |' ,
167165 '|---------------|----------|' ,
@@ -197,50 +195,3 @@ function findSizes(pathObj) {
197195
198196 return sizes ;
199197}
200-
201- function scrapeContent ( pathObj ) {
202- var code = fs . readFileSync ( pathObj . index , ENC ) ;
203- var moduleList = [ ] ;
204-
205- falafel ( code , function ( node ) {
206- if ( isModuleNode ( node ) ) {
207- var moduleName = node . value . replace ( './' , '' ) ;
208- moduleList . push ( moduleName ) ;
209- }
210- } ) ;
211-
212- return moduleList ;
213- }
214-
215- function isModuleNode ( node ) {
216- return (
217- node . type === 'Literal' &&
218- node . parent &&
219- node . parent . type === 'CallExpression' &&
220- node . parent . callee &&
221- node . parent . callee . type === 'Identifier' &&
222- node . parent . callee . name === 'require' &&
223- node . parent . parent &&
224- node . parent . parent . type === 'ArrayExpression'
225- ) ;
226- }
227-
228- function formatBundleInfo ( bundleName , moduleList ) {
229- var enumeration = moduleList . map ( function ( moduleName , i ) {
230- var len = moduleList . length ,
231- ending ;
232-
233- if ( i === len - 2 ) ending = ' and' ;
234- else if ( i < len - 1 ) ending = ',' ;
235- else ending = '' ;
236-
237- return '`' + moduleName + '`' + ending ;
238- } ) ;
239-
240- return [
241- 'The' , '`' + bundleName + '`' ,
242- 'partial bundle contains the' ,
243- enumeration . join ( ' ' ) ,
244- 'trace modules.'
245- ] . join ( ' ' ) ;
246- }
0 commit comments