Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21d09a6

Browse filesBrowse files
authored
Merge pull request plotly#6557 from CallumNZ/custom-bundle-strict
Add --strict option to custom bundle
2 parents 3f8cfe7 + 174d387 commit 21d09a6
Copy full SHA for 21d09a6

File tree

Expand file treeCollapse file tree

5 files changed

+19
-8
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+19
-8
lines changed

‎CUSTOM_BUNDLE.md

Copy file name to clipboardExpand all lines: CUSTOM_BUNDLE.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ Or use `transforms none` to exclude them all.
3030
npm run custom-bundle -- --transforms none
3131
```
3232

33+
Use the `strict` option to use strict trace types where possible.
34+
```sh
35+
npm run custom-bundle -- --traces scatter,scattergl --strict
36+
```
37+
3338
Use the `out` option to change the bundle filename (default `custom`).
3439
The new bundle will be created in the `dist/` directory and named `plotly-<out>.min.js` or `plotly-<out>.js` if unminified.
3540
```sh

‎draftlogs/6557_add.md

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add strict option to custom bundle command [[#6557](https://github.com/plotly/plotly.js/pull/6557)], with thanks to @CallumNZ for the contribution!

‎tasks/custom_bundle.js

Copy file name to clipboardExpand all lines: tasks/custom_bundle.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ if(process.argv.length > 2) {
5656
var out = args.out ? args.out : 'custom';
5757
var traces = inputArray(args.traces, allTraces);
5858
var transforms = inputArray(args.transforms, allTransforms);
59+
var strict = inputBoolean(args.strict, false);
5960

6061
var opts = {
6162
traceList: createList(['scatter'], traces, allTraces, 'trace'),
6263
transformList: createList([], transforms, allTransforms, 'transform'),
6364

6465
name: out,
65-
index: path.join(constants.pathToLib, 'index-' + out + '.js')
66+
index: path.join(constants.pathToLib, 'index-' + (strict ? 'strict-' : '') + out + '.js'),
67+
strict: strict,
6668
};
6769

6870
if(unminified) {

‎tasks/partial_bundle.js

Copy file name to clipboardExpand all lines: tasks/partial_bundle.js
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var header = constants.licenseDist + '\n';
88
var allTransforms = constants.allTransforms;
99
var allTraces = constants.allTraces;
1010
var mainIndex = constants.mainIndex;
11+
var strictIndex = constants.strictIndex;
1112

1213
// Bundle the plotly.js partial bundles
1314
module.exports = function partialBundle(tasks, opts) {
@@ -19,11 +20,12 @@ module.exports = function partialBundle(tasks, opts) {
1920
var traceList = opts.traceList;
2021
var transformList = opts.transformList;
2122
var calendars = opts.calendars;
23+
var strict = opts.strict;
2224

2325
// skip strict bundle which is no longer a partial bundle and has a special index file for regl traces
2426
if(name !== 'strict') {
2527
tasks.push(function(done) {
26-
var partialIndex = mainIndex;
28+
var partialIndex = (strict) ? strictIndex : mainIndex;
2729

2830
var all = ['calendars'].concat(allTransforms).concat(allTraces);
2931
var includes = (calendars ? ['calendars'] : []).concat(transformList).concat(traceList);
@@ -32,12 +34,11 @@ module.exports = function partialBundle(tasks, opts) {
3234
excludes.forEach(function(t) {
3335
var WHITESPACE_BEFORE = '\\s*';
3436
// remove require
35-
var newCode = partialIndex.replace(
36-
new RegExp(
37-
WHITESPACE_BEFORE +
38-
'require\\(\'\\./' + t + '\'\\),',
39-
'g'), ''
40-
);
37+
var regEx = WHITESPACE_BEFORE + 'require\\(\'\\./' + t + '\'\\),';
38+
if(strict) {
39+
regEx += '|require\\(\'\\.\\./src/traces/' + t + '/strict\'\\),';
40+
}
41+
var newCode = partialIndex.replace(new RegExp(regEx, 'g'), '');
4142

4243
// test removal
4344
if(newCode === partialIndex) {

‎tasks/util/constants.js

Copy file name to clipboardExpand all lines: tasks/util/constants.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function startsWithLowerCase(v) {
2020
var pathToPlotlyIndex = path.join(pathToLib, 'index.js');
2121
var pathToPlotlyStrict = path.join(pathToLib, 'index-strict.js');
2222
var mainIndex = fs.readFileSync(pathToPlotlyIndex, 'utf-8');
23+
var strictIndex = fs.readFileSync(pathToPlotlyStrict, 'utf-8');
2324
var allTraces = fs.readdirSync(path.join(pathToSrc, 'traces'))
2425
.filter(startsWithLowerCase);
2526

@@ -191,6 +192,7 @@ module.exports = {
191192
allTransforms: allTransforms,
192193
allTraces: allTraces,
193194
mainIndex: mainIndex,
195+
strictIndex: strictIndex,
194196
pathToPlotlyIndex: pathToPlotlyIndex,
195197
pathToPlotlyStrict: pathToPlotlyStrict,
196198
pathToPlotlyCore: path.join(pathToSrc, 'core.js'),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.