Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"files": {
"maxSize": 10000000,
"includes": [
"**/esbuild-config.js",
"**/src/**",
"**/lib/**",
"**/test/**",
Expand Down
7 changes: 1 addition & 6 deletions devtools/regl_codegen/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import minimist from 'minimist';

import constants from '../../tasks/util/constants.js';
import { build } from 'esbuild';
import config from '../../esbuild-config.js';
import { esbuildConfig as config } from '../../esbuild-config.js';

var args = minimist(process.argv.slice(2), {});
var PORT = args.port || 3000;
Expand Down Expand Up @@ -64,11 +64,6 @@ server.listen(PORT);
// open up browser window
open('http://localhost:' + PORT + '/devtools/regl_codegen/index' + (strict ? '-strict' : '') + '.html');

var devtoolsPath = path.join(constants.pathToRoot, 'devtools/regl_codegen');
config.entryPoints = [path.join(devtoolsPath, 'devtools.js')];
config.outfile = './build/regl_codegen-bundle.js';
config.sourcemap = false;
config.minify = false;
await build(config);

function getMockFiles() {
Expand Down
7 changes: 7 additions & 0 deletions devtools/test_dashboard/build.mjs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camdecoster After the cleanup you've done, does this step really need a separate file? Couldn't you just now add build(localDevConfig); to the beginning of the makeSchema() function in schema.mjs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair question. I envisioned this script as being one that could be called elsewhere, but that seems like it violates the YAGNI principle. I'll do as you suggest. We can always add it back.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { build } from 'esbuild';
import { localDevConfig } from '../../esbuild-config.js';

// Build plotly.js to be used locally, such as when generating the schema.
// This is the same process used in the test dashboard server script, but
// run only once.
build(localDevConfig);
32 changes: 3 additions & 29 deletions devtools/test_dashboard/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,25 @@ import minimist from 'minimist';

import constants from '../../tasks/util/constants.js';
import { context, build } from 'esbuild';
import config from '../../esbuild-config.js';

import { glsl } from 'esbuild-plugin-glsl';
import { devtoolsConfig, localDevConfig } from '../../esbuild-config.js';

var args = minimist(process.argv.slice(2), {});
var PORT = args.port || 3000;
var strict = args.strict;
var mathjax3 = args.mathjax3;
var mathjax3chtml = args.mathjax3chtml;

if (strict) {
config.entryPoints = ['./lib/index-strict.js'];
}

config.outfile = './build/plotly.js';
if (strict) localDevConfig.entryPoints = ['./lib/index-strict.js'];

var mockFolder = constants.pathToTestImageMocks;

// mock list
await getMockFiles().then(readFiles).then(createMocksList).then(saveMockListToFile);

// Devtools config
var devtoolsConfig = {
entryPoints: [path.join(constants.pathToRoot, 'devtools', 'test_dashboard', 'devtools.js')],
outfile: path.join(constants.pathToRoot, 'build', 'test_dashboard-bundle.js'),
format: 'cjs',
globalName: 'Tabs',
bundle: true,
minify: false,
sourcemap: false,
plugins: [
glsl({
minify: true
})
],
define: {
global: 'window'
},
target: 'es2016',
logLevel: 'info'
};

build(devtoolsConfig);

var ctx = await context(config);
var ctx = await context(localDevConfig);
devServer();
console.log('watching esbuild...');
await ctx.watch();
Expand Down
59 changes: 44 additions & 15 deletions esbuild-config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,59 @@
var glsl = require('esbuild-plugin-glsl').glsl;
var environmentPlugin = require('esbuild-plugin-environment').environmentPlugin;
const { environmentPlugin } = require('esbuild-plugin-environment');
const { glsl } = require('esbuild-plugin-glsl');
const InlineCSSPlugin = require('esbuild-plugin-inline-css');
const path = require('path');
const constants = require('./tasks/util/constants.js');

module.exports = {
// Default config used when building library
const esbuildConfig = {
entryPoints: ['./lib/index.js'],
format: 'iife',
globalName: 'Plotly',
bundle: true,
minify: false,
sourcemap: false,
plugins: [
InlineCSSPlugin(),
glsl({
minify: true,
}),
environmentPlugin({
NODE_DEBUG: false,
}),
],
plugins: [InlineCSSPlugin(), glsl({ minify: true }), environmentPlugin({ NODE_DEBUG: false })],
alias: {
stream: 'stream-browserify',
stream: 'stream-browserify'
},
define: {
global: 'window',
'define.amd': 'false',
'define.amd': 'false'
},
target: 'es2016',
logLevel: 'info',
logLevel: 'info'
};

const devtoolsConfig = {
Copy link
Contributor

@emilykl emilykl Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camdecoster Could you add a comment above each of these configs explaining what it's used for (to the extent that you know)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll come up with something, but the variable names were my attempt at a description.

entryPoints: [path.join(constants.pathToRoot, 'devtools', 'test_dashboard', 'devtools.js')],
outfile: path.join(constants.pathToRoot, 'build', 'test_dashboard-bundle.js'),
format: 'cjs',
globalName: 'Tabs',
bundle: true,
minify: false,
sourcemap: false,
plugins: [glsl({ minify: true })],
define: { global: 'window' },
target: 'es2016',
logLevel: 'info'
};

const localDevConfig = {
...esbuildConfig,
outfile: './build/plotly.js'
};

const localDevReglCodegenConfig = {
...esbuildConfig,
entryPoints: [path.join(constants.pathToRoot, 'devtools/regl_codegen', 'devtools.js')],
outfile: './build/regl_codegen-bundle.js',
sourcemap: false,
minify: false
};

module.exports = {
devtoolsConfig,
esbuildConfig,
localDevConfig,
localDevReglCodegenConfig,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"bundle": "node tasks/bundle.mjs",
"extra-bundles": "node tasks/extra_bundles.mjs",
"locales": "node tasks/locales.js",
"schema": "node tasks/schema.mjs",
"schema": "node devtools/test_dashboard/build.mjs && node tasks/schema.mjs",
"stats": "node tasks/stats.js",
"find-strings": "node tasks/find_locale_strings.js",
"preprocess": "node tasks/preprocess.js",
Expand Down
2 changes: 1 addition & 1 deletion tasks/util/bundle_wrapper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import prependFile from 'prepend-file';

import { build } from 'esbuild';

import esbuildConfig from '../../esbuild-config.js';
import { esbuildConfig } from '../../esbuild-config.js';
import esbuildPluginStripMeta from '../../tasks/compress_attributes.js';

import common from './common.js';
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var path = require('path');
var minimist = require('minimist');
var constants = require('../../tasks/util/constants');
var esbuildConfig = require('../../esbuild-config.js');
const { esbuildConfig } = require('../../esbuild-config.js');

var isCI = Boolean(process.env.CI);

Expand Down