1- var fs = require ( 'fs' ) ;
2- var path = require ( 'path' ) ;
3- var http = require ( 'http' ) ;
4- var ecstatic = require ( 'ecstatic' ) ;
5- var open = require ( 'open' ) ;
6- var webpack = require ( 'webpack' ) ;
7- var minimist = require ( 'minimist' ) ;
8-
9- var constants = require ( '../../tasks/util/constants' ) ;
10- var config = require ( '../../webpack.config.js' ) ;
11- config . optimization = { minimize : false } ;
1+ import fs from 'fs' ;
2+ import path from 'path' ;
3+ import http from 'http' ;
4+ import ecstatic from 'ecstatic' ;
5+ import open from 'open' ;
6+ import minimist from 'minimist' ;
7+
8+ import constants from '../../tasks/util/constants.js' ;
9+ import { build } from 'esbuild' ;
10+ import config from '../../esbuild-config.js' ;
1211
1312var args = minimist ( process . argv . slice ( 2 ) , { } ) ;
1413var PORT = args . port || 3000 ;
@@ -21,6 +20,8 @@ var reglTraceList = [
2120 'splom'
2221] ;
2322
23+
24+
2425// Create server
2526var _static = ecstatic ( {
2627 root : constants . pathToRoot ,
@@ -57,55 +58,25 @@ var server = http.createServer(function(req, res) {
5758 }
5859} ) ;
5960
60-
61- // Start the server up!
62- server . listen ( PORT ) ;
63-
64- // open up browser window
65- open ( 'http://localhost:' + PORT + '/devtools/regl_codegen/index' + ( strict ? '-strict' : '' ) + '.html' ) ;
66-
6761// Build and bundle all the things!
68- getMockFiles ( )
62+ await getMockFiles ( )
6963 . then ( readFiles )
7064 . then ( createMocksList )
7165 . then ( saveMockListToFile )
7266 . then ( saveReglTracesToFile . bind ( null , reglTraceList ) ) ;
7367
74- // Devtools config
75- var devtoolsConfig = { } ;
76-
77- var devtoolsPath = path . join ( constants . pathToRoot , 'devtools/regl_codegen' ) ;
78- devtoolsConfig . entry = path . join ( devtoolsPath , 'devtools.js' ) ;
79-
80- devtoolsConfig . output = {
81- path : config . output . path ,
82- filename : 'regl_codegen-bundle.js' ,
83- library : {
84- name : 'Tabs' ,
85- type : 'umd'
86- }
87- } ;
88-
89- devtoolsConfig . target = config . target ;
90- devtoolsConfig . plugins = config . plugins ;
91- devtoolsConfig . optimization = config . optimization ;
92- devtoolsConfig . mode = 'production' ;
93-
94- var compiler ;
95-
96- compiler = webpack ( devtoolsConfig ) ;
97- compiler . run ( function ( devtoolsErr , devtoolsStats ) {
98- if ( devtoolsErr ) {
99- console . log ( 'err:' , devtoolsErr ) ;
100- } else if ( devtoolsStats . errors && devtoolsStats . errors . length ) {
101- console . log ( 'stats.errors:' , devtoolsStats . errors ) ;
102- } else {
103- console . log ( 'success:' , devtoolsConfig . output . path + '/' + devtoolsConfig . output . filename ) ;
68+ // Start the server up!
69+ server . listen ( PORT ) ;
10470
105- purgeGeneratedCode ( reglTraceList ) ;
106- }
107- } ) ;
71+ // open up browser window
72+ open ( 'http://localhost:' + PORT + '/devtools/regl_codegen/index' + ( strict ? '-strict' : '' ) + '.html' ) ;
10873
74+ var devtoolsPath = path . join ( constants . pathToRoot , 'devtools/regl_codegen' ) ;
75+ config . entryPoints = [ path . join ( devtoolsPath , 'devtools.js' ) ] ;
76+ config . outfile = './build/regl_codegen-bundle.js' ;
77+ config . sourcemap = false ;
78+ config . minify = false ;
79+ await build ( config ) ;
10980
11081function getMockFiles ( ) {
11182 return new Promise ( function ( resolve , reject ) {
@@ -240,18 +211,3 @@ function handleCodegen(data) {
240211 var precompiled = header + imports + exports ;
241212 fs . writeFileSync ( pathToReglPrecompiledSrc , precompiled ) ;
242213}
243-
244-
245- function purgeGeneratedCode ( traces ) {
246- var pathToReglCodegenSrc = constants . pathToReglCodegenSrc ;
247-
248- var files = fs . readdirSync ( pathToReglCodegenSrc ) ;
249- files . forEach ( function ( file ) {
250- fs . unlinkSync ( path . join ( pathToReglCodegenSrc , file ) ) ;
251- } ) ;
252-
253- traces . forEach ( function ( trace ) {
254- var pathToReglPrecompiledSrc = path . join ( constants . pathToSrc , 'traces' , trace , 'regl_precompiled.js' ) ;
255- fs . writeFileSync ( pathToReglPrecompiledSrc , 'module.exports = {};\n' ) ;
256- } ) ;
257- }
0 commit comments