2
0
Эх сурвалжийг харах

Replaced Google Closure compiler with Terser

Mr.doob 4 жил өмнө
parent
commit
e59a50f79c
3 өөрчлөгдсөн 363 нэмэгдсэн , 326 устгасан
  1. 300 322
      package-lock.json
  2. 1 2
      package.json
  3. 62 2
      utils/build/rollup.config.js

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 300 - 322
package-lock.json


+ 1 - 2
package.json

@@ -55,7 +55,6 @@
     "start": "npm run dev",
     "test": "npm run test-lint && npm run test-unit",
     "build": "rollup -c utils/build/rollup.config.js",
-    "build-closure": "npm run build && google-closure-compiler --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/three.js --js_output_file build/three.min.js",
     "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"http-server -c-1 -p 8080\"",
     "dev-test": "concurrently --names \"ROLLUP,ROLLUPTEST,HTTP\" -c \"bgBlue.bold,bgRed.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"npm run dev --prefix test\" \"http-server -p 8080\"",
     "lint-fix": "eslint src --ext js --ext ts --fix && eslint examples/js/ --ext js --ext ts --ignore-pattern libs --fix",
@@ -95,10 +94,10 @@
     "eslint": "^7.6.0",
     "eslint-config-mdcs": "^5.0.0",
     "eslint-plugin-html": "^6.0.3",
-    "google-closure-compiler": "20200719.0.0",
     "http-server": "^0.12.3",
     "rollup": "^2.23.1",
     "rollup-plugin-buble": "^0.19.8",
+    "rollup-plugin-terser": "^7.0.2",
     "typescript": "^4.0.2"
   },
   "jspm": {

+ 62 - 2
utils/build/rollup.config.js

@@ -1,4 +1,5 @@
 import buble from 'rollup-plugin-buble';
+import { terser } from "rollup-plugin-terser";
 
 function glconstants() {
 
@@ -240,6 +241,22 @@ function bubleCleanup() {
 
 }
 
+function header() {
+
+	const template = "// threejs.org/license\n${code}";
+
+	return {
+
+		renderChunk( code ) {
+
+			return template.replace( '${code}', code );
+
+		}
+
+	};
+
+}
+
 export default [
 	{
 		input: 'src/Three.js',
@@ -252,7 +269,8 @@ export default [
 					classes: true
 				}
 			} ),
-			bubleCleanup()
+			bubleCleanup(),
+			header()
 		],
 		output: [
 			{
@@ -267,7 +285,32 @@ export default [
 		input: 'src/Three.js',
 		plugins: [
 			glconstants(),
-			glsl()
+			glsl(),
+			buble( {
+				transforms: {
+					arrow: false,
+					classes: true
+				}
+			} ),
+			bubleCleanup(),
+			terser(),
+			header()
+		],
+		output: [
+			{
+				format: 'umd',
+				name: 'THREE',
+				file: 'build/three.min.js',
+				indent: '\t'
+			}
+		]
+	},
+	{
+		input: 'src/Three.js',
+		plugins: [
+			glconstants(),
+			glsl(),
+			header()
 		],
 		output: [
 			{
@@ -276,5 +319,22 @@ export default [
 				indent: '\t'
 			}
 		]
+	},
+	{
+		input: 'src/Three.js',
+		plugins: [
+			glconstants(),
+			glsl(),
+			terser(),
+			header()
+		],
+		output: [
+			{
+				format: 'esm',
+				file: 'build/three.module.min.js',
+				indent: '\t'
+			}
+		]
 	}
+
 ];

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно