2
2
/* eslint-env node */
3
3
4
4
import { exec , spawn } from "child_process" ;
5
- import esbuild from "esbuild" ;
6
5
import * as fs from "fs/promises" ;
7
6
import { createServer } from "http" ;
8
7
import * as path from "path" ;
9
8
import { fileURLToPath , pathToFileURL } from "url" ;
10
9
import launchStaticServer from "../../scripts/launch_static_server.mjs" ;
11
10
import removeDir from "../../scripts/utils/remove_dir.mjs" ;
11
+ import runBundler from "../../scripts/run_bundler.mjs" ;
12
12
import createContentServer from "../contents/server.mjs" ;
13
13
import { rmSync , writeFileSync } from "fs" ;
14
14
@@ -465,7 +465,7 @@ async function initializePerformanceTestsPages({ branchName, remoteGitUrl }) {
465
465
*/
466
466
async function prepareCurrentRxPlayerTests ( ) {
467
467
await linkCurrentRxPlayer ( ) ;
468
- await createBundle ( { output : "current.js" , minify : false , production : true } ) ;
468
+ await createBundle ( { output : "current.js" , minify : true , production : true } ) ;
469
469
}
470
470
471
471
/**
@@ -480,7 +480,7 @@ async function prepareCurrentRxPlayerTests() {
480
480
*/
481
481
async function prepareLastRxPlayerTests ( { branchName, remoteGitUrl } ) {
482
482
await linkRxPlayerBranch ( { branchName, remoteGitUrl } ) ;
483
- await createBundle ( { output : "previous.js" , minify : false , production : true } ) ;
483
+ await createBundle ( { output : "previous.js" , minify : true , production : true } ) ;
484
484
}
485
485
486
486
/**
@@ -981,35 +981,26 @@ function getSamplePerScenarios(samplesObj) {
981
981
* in "development" mode, which has supplementary assertions.
982
982
* @returns {Promise }
983
983
*/
984
- function createBundle ( options ) {
984
+ async function createBundle ( options ) {
985
985
const minify = ! ! options . minify ;
986
- const isDevMode = ! options . production ;
987
- return esbuild
988
- . build ( {
989
- entryPoints : [ path . join ( currentDirectory , "src" , "main.js" ) ] ,
990
- bundle : true ,
986
+ try {
987
+ await runBundler ( path . join ( currentDirectory , "src" , "main.js" ) , {
991
988
minify,
989
+ silent : true ,
990
+ globalScope : false ,
991
+ production : true ,
992
+ watch : false ,
992
993
outfile : path . join ( currentDirectory , options . output ) ,
993
- define : {
994
+ globals : {
994
995
__TEST_CONTENT_SERVER__ : JSON . stringify ( {
995
996
URL : "127.0.0.1" ,
996
997
PORT : "3000" ,
997
998
} ) ,
998
- "process.env.NODE_ENV" : JSON . stringify ( isDevMode ? "development" : "production" ) ,
999
- __ENVIRONMENT__ : JSON . stringify ( {
1000
- PRODUCTION : 0 ,
1001
- DEV : 1 ,
1002
- CURRENT_ENV : isDevMode ? 1 : 0 ,
1003
- } ) ,
1004
- __LOGGER_LEVEL__ : JSON . stringify ( {
1005
- CURRENT_LEVEL : "INFO" ,
1006
- } ) ,
1007
- __GLOBAL_SCOPE__ : JSON . stringify ( false ) ,
1008
999
} ,
1009
- } )
1010
- . catch ( ( err ) => {
1011
- throw new Error ( `Demo build failed:` , err ) ;
1012
1000
} ) ;
1001
+ } catch ( err ) {
1002
+ throw new Error ( `Performance build failed:` , err ) ;
1003
+ }
1013
1004
}
1014
1005
1015
1006
/**
0 commit comments