Browse Source

Replaced concurrently with custom preview.js. (#32655)

mrdoob 1 month ago
parent
commit
48f168d4f0
3 changed files with 72 additions and 82 deletions
  1. 4 79
      package-lock.json
  2. 2 3
      package.json
  3. 66 0
      utils/build/preview.js

+ 4 - 79
package-lock.json

@@ -12,7 +12,6 @@
         "@eslint/js": "^9.0.0",
         "@rollup/plugin-node-resolve": "^16.0.0",
         "@rollup/plugin-terser": "^0.4.0",
-        "concurrently": "^9.0.0",
         "eslint": "^9.0.0",
         "eslint-config-mdcs": "^5.0.0",
         "eslint-plugin-compat": "^6.0.0",
@@ -1298,19 +1297,6 @@
         "url": "https://github.com/chalk/chalk?sponsor=1"
       }
     },
-    "node_modules/chalk/node_modules/supports-color": {
-      "version": "7.2.0",
-      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
-      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
-      "dev": true,
-      "license": "MIT",
-      "dependencies": {
-        "has-flag": "^4.0.0"
-      },
-      "engines": {
-        "node": ">=8"
-      }
-    },
     "node_modules/chromium-bidi": {
       "version": "12.0.1",
       "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-12.0.1.tgz",
@@ -1387,31 +1373,6 @@
       "dev": true,
       "license": "MIT"
     },
-    "node_modules/concurrently": {
-      "version": "9.2.1",
-      "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz",
-      "integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==",
-      "dev": true,
-      "license": "MIT",
-      "dependencies": {
-        "chalk": "4.1.2",
-        "rxjs": "7.8.2",
-        "shell-quote": "1.8.3",
-        "supports-color": "8.1.1",
-        "tree-kill": "1.2.2",
-        "yargs": "17.7.2"
-      },
-      "bin": {
-        "conc": "dist/bin/concurrently.js",
-        "concurrently": "dist/bin/concurrently.js"
-      },
-      "engines": {
-        "node": ">=18"
-      },
-      "funding": {
-        "url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
-      }
-    },
     "node_modules/cosmiconfig": {
       "version": "9.0.0",
       "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz",
@@ -3242,16 +3203,6 @@
         "fsevents": "~2.3.2"
       }
     },
-    "node_modules/rxjs": {
-      "version": "7.8.2",
-      "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
-      "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
-      "dev": true,
-      "license": "Apache-2.0",
-      "dependencies": {
-        "tslib": "^2.1.0"
-      }
-    },
     "node_modules/safe-buffer": {
       "version": "5.2.1",
       "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -3333,19 +3284,6 @@
         "node": ">=8"
       }
     },
-    "node_modules/shell-quote": {
-      "version": "1.8.3",
-      "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
-      "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
-      "dev": true,
-      "license": "MIT",
-      "engines": {
-        "node": ">= 0.4"
-      },
-      "funding": {
-        "url": "https://github.com/sponsors/ljharb"
-      }
-    },
     "node_modules/smart-buffer": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
@@ -3494,19 +3432,16 @@
       }
     },
     "node_modules/supports-color": {
-      "version": "8.1.1",
-      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
-      "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
+      "version": "7.2.0",
+      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
       "dev": true,
       "license": "MIT",
       "dependencies": {
         "has-flag": "^4.0.0"
       },
       "engines": {
-        "node": ">=10"
-      },
-      "funding": {
-        "url": "https://github.com/chalk/supports-color?sponsor=1"
+        "node": ">=8"
       }
     },
     "node_modules/supports-preserve-symlinks-flag": {
@@ -3613,16 +3548,6 @@
         "url": "https://github.com/sponsors/sindresorhus"
       }
     },
-    "node_modules/tree-kill": {
-      "version": "1.2.2",
-      "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
-      "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
-      "dev": true,
-      "license": "MIT",
-      "bin": {
-        "tree-kill": "cli.js"
-      }
-    },
     "node_modules/tslib": {
       "version": "2.8.1",
       "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",

+ 2 - 3
package.json

@@ -50,8 +50,8 @@
     "build-docs": "jsdoc -c utils/docs/jsdoc.config.json",
     "dev": "node utils/build/dev.js && node utils/server.js -p 8080",
     "dev-ssl": "node utils/build/dev.js && node utils/server.js -p 8080 --ssl",
-    "preview": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"node utils/server.js -p 8080\"",
-    "preview-ssl": "concurrently --names \"ROLLUP,HTTPS\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"node utils/server.js -p 8080 --ssl\"",
+    "preview": "node utils/build/preview.js",
+    "preview-ssl": "node utils/build/preview.js --ssl",
     "lint-core": "eslint src",
     "lint-addons": "eslint examples/jsm",
     "lint-examples": "eslint examples",
@@ -96,7 +96,6 @@
     "@eslint/js": "^9.0.0",
     "@rollup/plugin-node-resolve": "^16.0.0",
     "@rollup/plugin-terser": "^0.4.0",
-    "concurrently": "^9.0.0",
     "eslint": "^9.0.0",
     "eslint-config-mdcs": "^5.0.0",
     "eslint-plugin-compat": "^6.0.0",

+ 66 - 0
utils/build/preview.js

@@ -0,0 +1,66 @@
+import { spawn } from 'child_process';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+const __dirname = path.dirname( fileURLToPath( import.meta.url ) );
+const rootDir = path.resolve( __dirname, '../..' );
+
+const useSSL = process.argv.includes( '--ssl' );
+
+// Start rollup in watch mode
+const rollup = spawn( 'npx', [
+	'rollup',
+	'-c', 'utils/build/rollup.config.js',
+	'-w',
+	'-m', 'inline'
+], {
+	cwd: rootDir,
+	stdio: [ 'ignore', 'pipe', 'pipe' ],
+	shell: true
+} );
+
+// Start server
+const serverArgs = [ 'utils/server.js', '-p', '8080' ];
+if ( useSSL ) serverArgs.push( '--ssl' );
+
+const server = spawn( 'node', serverArgs, {
+	cwd: rootDir,
+	stdio: [ 'ignore', 'pipe', 'pipe' ],
+	shell: false
+} );
+
+// Prefix output
+const prefix = ( name, color ) => {
+
+	return ( data ) => {
+
+		const lines = data.toString().split( '\n' ).filter( l => l.trim() );
+		for ( const line of lines ) {
+
+			console.log( `${color}[${name}]\x1b[0m ${line}` );
+
+		}
+
+	};
+
+};
+
+rollup.stdout.on( 'data', prefix( 'ROLLUP', '\x1b[44m\x1b[1m' ) );
+rollup.stderr.on( 'data', prefix( 'ROLLUP', '\x1b[44m\x1b[1m' ) );
+server.stdout.on( 'data', prefix( 'HTTP', '\x1b[42m\x1b[1m' ) );
+server.stderr.on( 'data', prefix( 'HTTP', '\x1b[42m\x1b[1m' ) );
+
+// Handle cleanup
+const cleanup = () => {
+
+	rollup.kill();
+	server.kill();
+	process.exit( 0 );
+
+};
+
+process.on( 'SIGINT', cleanup );
+process.on( 'SIGTERM', cleanup );
+
+rollup.on( 'close', cleanup );
+server.on( 'close', cleanup );

粤ICP备19079148号