Browse Source

Merge pull request #19934 from mrdoob/rollup

Rollup: Added bubleCleanup.
Mr.doob 5 years ago
parent
commit
de6fc20a53
1 changed files with 38 additions and 1 deletions
  1. 38 1
      utils/build/rollup.config.js

+ 38 - 1
utils/build/rollup.config.js

@@ -201,6 +201,42 @@ function glsl() {
 
 }
 
+function bubleCleanup() {
+
+	const begin1 = /var (\w+) = \/\*@__PURE__*\*\/\(function \((\w+)\) {\n/;
+	const end1 = /if \( (\w+) \) (\w+)\.__proto__ = (\w+);\s+(\w+)\.prototype = Object\.create\( (\w+) && (\w+)\.prototype \);\s+(\w+)\.prototype\.constructor = (\w+);\s+return (\w+);\s+}\((\w+)\)\)/;
+
+	return {
+
+		transform( code ) {
+
+			while ( begin1.test( code ) ) {
+
+				code = code.replace( begin1, function () {
+
+					return '';
+
+				} );
+
+				code = code.replace( end1, function ( match, p1, p2 ) {
+
+					return `${p2}.prototype = Object.create( ${p1}.prototype );\n\t${p2}.prototype.constructor = ${p2};\n`;
+
+				} );
+
+			}
+
+			return {
+				code: code,
+				map: { mappings: '' }
+			};
+
+		}
+
+	};
+
+}
+
 export default [
 	{
 		input: 'src/Three.js',
@@ -212,7 +248,8 @@ export default [
 					arrow: false,
 					classes: true
 				}
-			} )
+			} ),
+			bubleCleanup()
 		],
 		output: [
 			{