From 67d975de9cbe13591289dc55a0a263e6b0410f3c Mon Sep 17 00:00:00 2001 From: Rob Figueiredo Date: Wed, 14 Aug 2019 19:59:00 -0400 Subject: [PATCH] JsChecker: support extensionless ES6 imports --- java/com/google/javascript/jscomp/CheckStrictDeps.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com/google/javascript/jscomp/CheckStrictDeps.java b/java/com/google/javascript/jscomp/CheckStrictDeps.java index 70109ddbc2..ed3de2e4b8 100644 --- a/java/com/google/javascript/jscomp/CheckStrictDeps.java +++ b/java/com/google/javascript/jscomp/CheckStrictDeps.java @@ -136,6 +136,12 @@ private void visitEs6Import(NodeTraversal t, Node n) { private void checkNamespaceIsProvided(NodeTraversal t, Node n, String namespace) { if (namespace.startsWith("/") || namespace.startsWith(".")) { // TODO(jart): Unify path resolution with ModuleLoader. + // NOTE(robfig): To enable usage of extensionless ES6 modules, + // copy these 3 lines from NodeModuleResolver.java. + if (!namespace.endsWith(".js")) { + namespace += ".js"; + } + Webpath me = Webpath.get(t.getSourceName()); if (!me.isAbsolute()) { me = Webpath.get("/").resolve(me);