Compiled from https://github.com/google/closure-compiler at b11c9970d87579ae50cee7dcda771ac726c71867 Reasons to use custom release: - Turned off property renaming in ADVANCED mode. Otherwise React plugins break. - Need c4a104075d40dd2191b45de33d00b79edd45b97e - Applied small patch to fix https://github.com/google/closure-compiler/issues/2170 - Fixed NPE in CommonJS rewrite path. ## Work remote https://github.com/google/closure-compiler/pull/2190/files ``` diff --git a/src/com/google/javascript/jscomp/deps/ModuleLoader.java b/src/com/google/javascript/jscomp/deps/ModuleLoader.java index 46cdaa6..910e619 100644 --- a/src/com/google/javascript/jscomp/deps/ModuleLoader.java +++ b/src/com/google/javascript/jscomp/deps/ModuleLoader.java @@ -368,10 +368,14 @@ public final class ModuleLoader { // /foo/ -> bar/node_modules/baz/foo_bar_baz.js // /foo/node_modules/bar/ -> baz/foo_bar_baz.js for (String modulePath : modulePaths) { - String[] nodeModulesDirs = modulePath.split("/node_modules/"); + String splitPath = modulePath; + if (modulePath.startsWith("node_modules/")) { + splitPath = "/" + modulePath; + } + String[] nodeModulesDirs = splitPath.split("/node_modules/"); String parentPath = ""; for (int i = 0; i < nodeModulesDirs.length - 1; i++) { - if (i + 1 < nodeModulesDirs.length) { + if (i + 1 < nodeModulesDirs.length && !nodeModulesDirs[i].equals("")) { parentPath += nodeModulesDirs[i] + "/"; } String subPath = modulePath.substring(parentPath.length() + "node_modules/".length()); ```