Skip to content

Commit 3654580

Browse files
committed
Move esbuild configs to one file, update references
1 parent fd910a1 commit 3654580

File tree

7 files changed

+59
-67
lines changed

7 files changed

+59
-67
lines changed

biome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"files": {
55
"maxSize": 10000000,
66
"includes": [
7+
"**/esbuild-config.mjs",
78
"**/src/**",
89
"**/lib/**",
910
"**/test/**",

devtools/regl_codegen/server.mjs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import minimist from 'minimist';
77

88
import constants from '../../tasks/util/constants.js';
99
import { build } from 'esbuild';
10-
import config from '../../esbuild-config.js';
10+
import config from '../../esbuild-config.mjs';
1111

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

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

7469
function getMockFiles() {

devtools/test_dashboard/server.mjs

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,25 @@ import minimist from 'minimist';
77

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

12-
import { glsl } from 'esbuild-plugin-glsl';
11+
import { devtoolsConfig, localDevConfig } from '../../esbuild-config.mjs';
1312

1413
var args = minimist(process.argv.slice(2), {});
1514
var PORT = args.port || 3000;
1615
var strict = args.strict;
1716
var mathjax3 = args.mathjax3;
1817
var mathjax3chtml = args.mathjax3chtml;
1918

20-
if (strict) {
21-
config.entryPoints = ['./lib/index-strict.js'];
22-
}
23-
24-
config.outfile = './build/plotly.js';
19+
if (strict) localDevConfig.entryPoints = ['./lib/index-strict.js'];
2520

2621
var mockFolder = constants.pathToTestImageMocks;
2722

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

31-
// Devtools config
32-
var devtoolsConfig = {
33-
entryPoints: [path.join(constants.pathToRoot, 'devtools', 'test_dashboard', 'devtools.js')],
34-
outfile: path.join(constants.pathToRoot, 'build', 'test_dashboard-bundle.js'),
35-
format: 'cjs',
36-
globalName: 'Tabs',
37-
bundle: true,
38-
minify: false,
39-
sourcemap: false,
40-
plugins: [
41-
glsl({
42-
minify: true
43-
})
44-
],
45-
define: {
46-
global: 'window'
47-
},
48-
target: 'es2016',
49-
logLevel: 'info'
50-
};
51-
5226
build(devtoolsConfig);
5327

54-
var ctx = await context(config);
28+
var ctx = await context(localDevConfig);
5529
devServer();
5630
console.log('watching esbuild...');
5731
await ctx.watch();

esbuild-config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

esbuild-config.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { environmentPlugin } from 'esbuild-plugin-environment';
2+
import { glsl } from 'esbuild-plugin-glsl';
3+
import InlineCSSPlugin from 'esbuild-plugin-inline-css';
4+
import path from 'path';
5+
import constants from './tasks/util/constants.js';
6+
7+
export const plotlyEsbuildConfig = {
8+
entryPoints: ['./lib/index.js'],
9+
format: 'iife',
10+
globalName: 'Plotly',
11+
bundle: true,
12+
minify: false,
13+
sourcemap: false,
14+
plugins: [InlineCSSPlugin(), glsl({ minify: true }), environmentPlugin({ NODE_DEBUG: false })],
15+
alias: {
16+
stream: 'stream-browserify'
17+
},
18+
define: {
19+
global: 'window',
20+
'define.amd': 'false'
21+
},
22+
target: 'es2016',
23+
logLevel: 'info'
24+
};
25+
export default plotlyEsbuildConfig;
26+
27+
export const devtoolsConfig = {
28+
entryPoints: [path.join(constants.pathToRoot, 'devtools', 'test_dashboard', 'devtools.js')],
29+
outfile: path.join(constants.pathToRoot, 'build', 'test_dashboard-bundle.js'),
30+
format: 'cjs',
31+
globalName: 'Tabs',
32+
bundle: true,
33+
minify: false,
34+
sourcemap: false,
35+
plugins: [glsl({ minify: true })],
36+
define: { global: 'window' },
37+
target: 'es2016',
38+
logLevel: 'info'
39+
};
40+
41+
export const localDevConfig = {
42+
...plotlyEsbuildConfig,
43+
outfile: './build/plotly.js'
44+
};
45+
46+
export const localDevReglCodegenConfig = {
47+
...plotlyEsbuildConfig,
48+
entryPoints: [path.join(constants.pathToRoot, 'devtools/regl_codegen', 'devtools.js')],
49+
outfile: './build/regl_codegen-bundle.js',
50+
sourcemap: false,
51+
minify: false
52+
};

tasks/util/bundle_wrapper.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import prependFile from 'prepend-file';
44

55
import { build } from 'esbuild';
66

7-
import esbuildConfig from '../../esbuild-config.js';
7+
import esbuildConfig from '../../esbuild-config.mjs';
88
import esbuildPluginStripMeta from '../../tasks/compress_attributes.js';
99

1010
import common from './common.js';

test/jasmine/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var path = require('path');
44
var minimist = require('minimist');
55
var constants = require('../../tasks/util/constants');
6-
var esbuildConfig = require('../../esbuild-config.js');
6+
var esbuildConfig = require('../../esbuild-config.mjs');
77

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

0 commit comments

Comments
 (0)