Browse Source

JSM: Avoid replacing strings.

Mr.doob 6 years ago
parent
commit
822530be58
1 changed files with 3 additions and 2 deletions
  1. 3 2
      utils/modularize.js

+ 3 - 2
utils/modularize.js

@@ -44,9 +44,10 @@ function convert( path, ignoreList ) {
 
 	} );
 
-	contents = contents.replace( /THREE\.([a-zA-Z0-9]+)(\.{0,1})/g, function ( match, p1, p2 ) {
+	contents = contents.replace( /(\'?)THREE\.([a-zA-Z0-9]+)(\.{0,1})/g, function ( match, p1, p2, p3 ) {
 
-		if ( p1 === className ) return `${p1}${p2}`;
+		if ( p1 === '\'' ) return match; // Inside a string
+		if ( p2 === className ) return `${p2}${p3}`;
 
 		return match;