Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove transforms from bundles #7254

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions CUSTOM_BUNDLE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Custom bundle
You can simply make custom bundles yourself, if none of the [distributed packages](https://github.com/plotly/plotly.js/blob/master/dist/README.md) meet your needs, or you want to make a more optimized bundle file with/without specific traces and transforms.
You can simply make custom bundles yourself, if none of the [distributed packages](https://github.com/plotly/plotly.js/blob/master/dist/README.md) meet your needs, or you want to make a more optimized bundle file with/without specific traces.

Make sure you have the versions of node/npm that's recommended:
- plotly.js before 2.5: Node 12/npm 6
Expand Down Expand Up @@ -27,7 +27,7 @@ cd plotly.js
npm i
```

By default all traces and transforms are included in the bundle if you simply run:
By default all traces are included in the bundle if you simply run:
```sh
npm run custom-bundle
```
Expand All @@ -39,16 +39,6 @@ npm run custom-bundle -- --traces scatter,scattergl,scatter3d
Please note that the `scatter` trace is currently included in all bundles and cannot be removed.
[This behaviour may change in the future](https://github.com/plotly/plotly.js/pull/5535), so we recommend that you explicitly include `scatter` anyway if you need it in your bundle.

Use the `transforms` option to specify which should be included.
```sh
npm run custom-bundle -- --transforms sort,filter
```

Or use `transforms none` to exclude them all.
```sh
npm run custom-bundle -- --transforms none
```

Use the `strict` option to use strict trace types where possible.
```sh
npm run custom-bundle -- --traces scatter,scattergl --strict
Expand All @@ -66,15 +56,14 @@ npm run custom-bundle -- --unminified
```

# Example illustrating use of different options together
To create an unminified custom bundle named `myScatters` including `scatter`, `scattergl` and `scatter3d` traces without any transforms:
To create an unminified custom bundle named `myScatters` including `scatter`, `scattergl` and `scatter3d` traces:
```sh
npm run custom-bundle -- \
--unminified \
--out myScatters \
--traces scatter,scattergl,scatter3d \
--transforms none
```
Or simply on one line:
```sh
npm run custom-bundle -- --unminified --out myScatters --traces scatter,scattergl,scatter3d --transforms none
npm run custom-bundle -- --unminified --out myScatters --traces scatter,scattergl,scatter3d
```
2 changes: 1 addition & 1 deletion draftlogs/7240_remove.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Drop transforms from the API [[#7240](https://github.com/plotly/plotly.js/pull/7240)]
- Drop transforms from the API [[#7240](https://github.com/plotly/plotly.js/pull/7240), [#7254](https://github.com/plotly/plotly.js/pull/7254)]
3 changes: 0 additions & 3 deletions lib/aggregate.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/filter.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/groupby.js

This file was deleted.

6 changes: 0 additions & 6 deletions lib/index-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ Plotly.register([
require('./bar'),
require('./pie'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-cartesian.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ Plotly.register([
require('./image'),
require('./pie'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ Plotly.register([
require('./ohlc'),
require('./candlestick'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ Plotly.register([
require('./scattergeo'),
require('./choropleth'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-gl2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ Plotly.register([
require('./splom'),
require('./parcoords'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-gl3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ Plotly.register([
require('./cone'),
require('./streamtube'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ Plotly.register([
require('./choroplethmap'),
require('./densitymap'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ Plotly.register([
require('./choroplethmapbox'),
require('./densitymapbox'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ Plotly.register([
require('./barpolar'),
require('./scattersmith'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ Plotly.register([
require('./barpolar'),
require('./scattersmith'),

// transforms
require('./aggregate'),
require('./filter'),
require('./groupby'),
require('./sort'),

// components
require('./calendars'),
]);
Expand Down
3 changes: 0 additions & 3 deletions lib/sort.js

This file was deleted.

3 changes: 0 additions & 3 deletions tasks/custom_bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import runSeries from 'run-series';
import partialBundle from './partial_bundle.mjs';
import constants from './util/constants.js';

var allTransforms = constants.allTransforms;
var allTraces = constants.allTraces;

function createList(outList, inList, allList, type) {
Expand Down Expand Up @@ -55,12 +54,10 @@ if(process.argv.length > 2) {
var unminified = inputBoolean(args.unminified, false);
var out = args.out ? args.out : 'custom';
var traces = inputArray(args.traces, allTraces);
var transforms = inputArray(args.transforms, allTransforms);
var strict = inputBoolean(args.strict, false);

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

name: out,
index: path.join(constants.pathToLib, 'index-' + (strict ? 'strict-' : '') + out + '.js'),
Expand Down
1 change: 0 additions & 1 deletion tasks/extra_bundles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ for(var i = 0; i < list.length; i++) {
dist: opts.dist,
distMin: opts.distMin,
traceList: opts.traceList,
transformList: opts.transformList,
calendars: opts.calendars
});
}
Expand Down
6 changes: 2 additions & 4 deletions tasks/partial_bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import common from './util/common.js';
import _bundle from './util/bundle_wrapper.mjs';

var header = constants.licenseDist + '\n';
var allTransforms = constants.allTransforms;
var allTraces = constants.allTraces;
var mainIndex = constants.mainIndex;
var strictIndex = constants.strictIndex;
Expand All @@ -18,7 +17,6 @@ export default function partialBundle(tasks, opts) {
var dist = opts.dist;
var distMin = opts.distMin;
var traceList = opts.traceList;
var transformList = opts.transformList;
var calendars = opts.calendars;
var strict = opts.strict;

Expand All @@ -27,8 +25,8 @@ export default function partialBundle(tasks, opts) {
tasks.push(function(done) {
var partialIndex = (strict) ? strictIndex : mainIndex;

var all = ['calendars'].concat(allTransforms).concat(allTraces);
var includes = (calendars ? ['calendars'] : []).concat(transformList).concat(traceList);
var all = ['calendars'].concat(allTraces);
var includes = (calendars ? ['calendars'] : []).concat(traceList);
var excludes = all.filter(function(e) { return includes.indexOf(e) === -1; });

excludes.forEach(function(t) {
Expand Down
9 changes: 0 additions & 9 deletions tasks/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ function exposePartsInLib() {

insert('calendars', 'src/components');

[
'aggregate',
'filter',
'groupby',
'sort'
].forEach(function(k) {
insert(k, 'src/transforms');
});

constants.allTraces.forEach(function(k) {
insert(k, 'src/traces');
});
Expand Down
8 changes: 0 additions & 8 deletions tasks/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ var strictIndex = fs.readFileSync(pathToPlotlyStrict, 'utf-8');
var allTraces = fs.readdirSync(path.join(pathToSrc, 'traces'))
.filter(startsWithLowerCase);

var allTransforms = fs.readdirSync(path.join(pathToSrc, 'transforms'))
.filter(function(v) {
return startsWithLowerCase(v) && v !== 'helpers.js';
})
.map(function(e) { return e.replace('.js', ''); });

var pathToTopojsonSrc;
try {
pathToTopojsonSrc = path.join(path.dirname(require.resolve('sane-topojson')), 'dist/');
Expand Down Expand Up @@ -162,7 +156,6 @@ function makePartialBundleOpts(name) {
return {
name: name,
traceList: partialBundleTraces[name],
transformList: allTransforms,
calendars: true,
index: path.join(pathToLib, 'index-' + name + '.js'),
dist: path.join(pathToDist, 'plotly-' + name + '.js'),
Expand All @@ -185,7 +178,6 @@ module.exports = {

partialBundleTraces: partialBundleTraces,

allTransforms: allTransforms,
allTraces: allTraces,
mainIndex: mainIndex,
strictIndex: strictIndex,
Expand Down
3 changes: 1 addition & 2 deletions test/jasmine/bundle_tests/component_first_test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var Plotly = require('../../../lib/core');
var Bar = require('../../../lib/bar');
var Scatter3d = require('../../../lib/scatter3d');
var Filter = require('../../../lib/filter');
var Calendars = require('../../../lib/calendars');

var checkComponent = require('../assets/check_component');

describe('Bundle with a component loaded before traces', function() {
'use strict';

Plotly.register([Calendars, Filter, Scatter3d, Bar]);
Plotly.register([Calendars, Scatter3d, Bar]);

checkComponent(Plotly);
});
3 changes: 1 addition & 2 deletions test/jasmine/bundle_tests/component_last_test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var Plotly = require('../../../lib/core');
var Bar = require('../../../lib/bar');
var Scatter3d = require('../../../lib/scatter3d');
var Filter = require('../../../lib/filter');
var Calendars = require('../../../lib/calendars');

var checkComponent = require('../assets/check_component');

describe('Bundle with a component loaded after traces', function() {
'use strict';

Plotly.register([Bar, Scatter3d, Filter, Calendars]);
Plotly.register([Bar, Scatter3d, Calendars]);

checkComponent(Plotly);
});