Skip to content

Commit 13c9a5e

Browse files
committed
use esbuild with karma and jasmine
1 parent 8498c54 commit 13c9a5e

File tree

5 files changed

+24
-44
lines changed

5 files changed

+24
-44
lines changed

devtools/regl_codegen/server.mjs

Lines changed: 1 addition & 1 deletion
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.mjs';
10+
import config from '../../esbuild-config.js';
1111

1212
var args = minimist(process.argv.slice(2), {});
1313
var PORT = args.port || 3000;

devtools/test_dashboard/server.mjs

Lines changed: 3 additions & 1 deletion
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 { context } from 'esbuild';
10-
import config from '../../esbuild-config.mjs';
10+
import config from '../../esbuild-config.js';
1111

1212
var args = minimist(process.argv.slice(2), {});
1313
var PORT = args.port || 3000;
@@ -19,6 +19,8 @@ if(strict) {
1919
config.entryPoints = ['./lib/index-strict.js'];
2020
}
2121

22+
config.outfile = './build/plotly.js';
23+
2224
var mockFolder = constants.pathToTestImageMocks;
2325

2426
// mock list
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { glsl } from 'esbuild-plugin-glsl';
2-
import { environmentPlugin } from 'esbuild-plugin-environment';
3-
// import babel from 'esbuild-plugin-babel';
1+
var glsl = require('esbuild-plugin-glsl').glsl;
2+
var environmentPlugin = require('esbuild-plugin-environment').environmentPlugin;
3+
// var babel = require('esbuild-plugin-babel');
44

5-
export default {
5+
module.exports = {
66
entryPoints: ['./lib/index.js'],
7-
outfile: './build/plotly.js',
87
format: 'iife',
98
globalName: 'Plotly',
109
bundle: true,

tasks/util/bundle_wrapper.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { build } from 'esbuild';
22

3-
import esbuildConfig from '../../esbuild-config.mjs';
3+
import esbuildConfig from '../../esbuild-config.js';
44
import browserifyAdapter from 'esbuild-plugin-browserify-adapter';
55

66
import transform from '../../tasks/compress_attributes.js';

test/jasmine/karma.conf.js

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
var path = require('path');
44
var minimist = require('minimist');
5-
var NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
6-
var LoaderOptionsPlugin = require('webpack').LoaderOptionsPlugin;
75
var constants = require('../../tasks/util/constants');
8-
var webpackConfig = require('../../webpack.config.js');
6+
var esbuildConfig = require('../../esbuild-config.js');
97

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

@@ -175,9 +173,17 @@ func.defaultConfig = {
175173
// base path that will be used to resolve all patterns (eg. files, exclude)
176174
basePath: constants.pathToRoot,
177175

178-
// frameworks to use
179-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
180-
frameworks: ['jasmine', 'jasmine-spec-tags', 'webpack', 'viewport'],
176+
frameworks: ['jasmine', 'jasmine-spec-tags', 'viewport'],
177+
178+
plugins: [
179+
require('karma-jasmine'),
180+
require('karma-jasmine-spec-tags'),
181+
require('karma-viewport'),
182+
require('karma-spec-reporter'),
183+
require('karma-chrome-launcher'),
184+
require('karma-firefox-launcher'),
185+
require('karma-esbuild'),
186+
],
181187

182188
// list of files / patterns to load in the browser
183189
//
@@ -262,26 +268,7 @@ func.defaultConfig = {
262268
}
263269
},
264270

265-
webpack: {
266-
target: ['web', 'es5'],
267-
module: {
268-
rules: webpackConfig.module.rules
269-
},
270-
resolve: {
271-
fallback: {
272-
stream: require.resolve('stream-browserify')
273-
}
274-
},
275-
plugins: [
276-
new NodePolyfillPlugin({ includeAliases: ['process'] }),
277-
new LoaderOptionsPlugin({
278-
// test: /\.xxx$/, // may apply this only for some modules
279-
options: {
280-
library: webpackConfig.output.library
281-
}
282-
})
283-
]
284-
},
271+
esbuild: esbuildConfig,
285272

286273
client: {
287274
// Options for `karma-jasmine-spec-tags`
@@ -328,21 +315,13 @@ func.defaultConfig = {
328315
failOnEmptyTestSuite: !argv.doNotFailOnEmptyTestSuite
329316
};
330317

331-
func.defaultConfig.preprocessors[pathToCustomMatchers] = ['webpack'];
332-
func.defaultConfig.preprocessors[testFileGlob] = ['webpack'];
318+
func.defaultConfig.preprocessors[pathToCustomMatchers] = ['esbuild'];
319+
func.defaultConfig.preprocessors[testFileGlob] = ['esbuild'];
333320

334321
if(isBundleTest) {
335322
switch(basename(testFileGlob)) {
336323
case 'minified_bundle':
337324
func.defaultConfig.files.push(constants.pathToPlotlyBuildMin);
338-
func.defaultConfig.module = {
339-
rules: {
340-
test: /\.js$/,
341-
use: [
342-
'transform-loader?' + path.resolve(__dirname, 'tasks/compress_attributes.js')
343-
]
344-
}
345-
};
346325
break;
347326
case 'plotschema':
348327
// no tasks/compress_attributes in this case

0 commit comments

Comments
 (0)