@@ -108,6 +108,7 @@ function getMainBundleInfo() {
108108 '- using CDN URL ' + cdnRoot + 'latest' + MINJS + ' OR ' + cdnRoot + pkg . version + MINJS ,
109109 '' ,
110110 'or as raw javascript:' ,
111+ '- using the `plotly.js-dist` npm package (starting in `v1.39.0`)' ,
111112 '- using dist file `dist/plotly.js`' ,
112113 '- using CDN URL ' + cdnRoot + 'latest' + JS + ' OR ' + cdnRoot + pkg . version + JS ,
113114 '- using CommonJS with `require(\'plotly.js\')`' ,
@@ -127,7 +128,8 @@ function getMainBundleInfo() {
127128 'Starting in `v1.15.0`, plotly.js also ships with several _partial_ bundles:' ,
128129 '' ,
129130 constants . partialBundlePaths . map ( makeBundleHeaderInfo ) . join ( '\n' ) ,
130- ''
131+ '' ,
132+ 'Starting in `v1.39.0`, each plotly.js partial bundle has a corresponding npm package with no dependency.'
131133 ] ;
132134}
133135
@@ -155,25 +157,54 @@ function makeBundleInfo(pathObj) {
155157 var name = pathObj . name ;
156158 var sizes = findSizes ( pathObj ) ;
157159 var moduleList = common . findModuleList ( pathObj . index ) ;
160+ var pkgName = 'plotly.js-' + name + '-dist' ;
158161
159162 return [
160163 '### plotly.js ' + name ,
161164 '' ,
162165 'The `' + name + '` partial bundle contains trace modules ' + common . formatEnumeration ( moduleList ) + '.' ,
163166 '' ,
164- '| Way to import | Location |' ,
165- '|---------------|----------|' ,
166- '| dist bundle | ' + '`dist/plotly-' + name + JS + '` |' ,
167- '| dist bundle (minified) | ' + '`dist/plotly-' + name + MINJS + '` |' ,
167+ '#### Stats' ,
168+ '' ,
169+ '| Raw size | Minified size | Minified + gzip size |' ,
170+ '|------|-----------------|------------------------|' ,
171+ '| ' + sizes . raw + ' | ' + sizes . minified + ' | ' + sizes . gzipped + ' |' ,
172+ '' ,
173+ '#### CDN links' ,
174+ '' ,
175+ '| Flavor | URL |' ,
176+ '| ------ | --- |' ,
168177 '| CDN URL (latest) | ' + cdnRoot + name + '-latest' + JS + ' |' ,
169178 '| CDN URL (latest minified) | ' + cdnRoot + name + '-latest' + MINJS + ' |' ,
170179 '| CDN URL (tagged) | ' + cdnRoot + name + '-' + pkg . version + JS + ' |' ,
171180 '| CDN URL (tagged minified) | ' + cdnRoot + name + '-' + pkg . version + MINJS + ' |' ,
181+ '' ,
182+ '#### npm package (starting in `v1.39.0`)' ,
183+ '' ,
184+ 'Install with' ,
185+ '```' ,
186+ 'npm install ' + pkgName ,
187+ '```' ,
188+ '' ,
189+ 'ES6 module usage:' ,
190+ '```js' ,
191+ 'import Plotly from \'' + pkgName + '\'' ,
192+ '```' ,
193+ '' ,
194+ 'CommonJS usage:' ,
195+ '```js' ,
196+ 'var Plotly = require(\'' + pkgName + '\');' ,
197+ '```' ,
198+ '' ,
199+ '#### plotly.js dist files' ,
200+ '' ,
201+ '| Way to import | Location |' ,
202+ '|---------------|----------|' ,
203+ '| dist bundle | ' + '`dist/plotly-' + name + JS + '` |' ,
204+ '| dist bundle (minified) | ' + '`dist/plotly-' + name + MINJS + '` |' ,
205+ '| ES6 module | ' + '`import Plotly from \'plotly.js/lib/' + 'index-' + name + '\'`' + ' |' ,
172206 '| CommonJS | ' + '`require(\'plotly.js/lib/' + 'index-' + name + '\')`' + ' |' ,
173207 '' ,
174- '| Raw size | Minified size | Minified + gzip size |' ,
175- '|------|-----------------|------------------------|' ,
176- '| ' + sizes . raw + ' | ' + sizes . minified + ' | ' + sizes . gzipped + ' |' ,
177208 ''
178209 ] . join ( '\n' ) ;
179210}
0 commit comments