File: detect_module_index.patch

package info (click to toggle)
node-es6-module-transpiler 0.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 712 kB
  • ctags: 434
  • sloc: makefile: 2; sh: 2
file content (19 lines) | stat: -rw-r--r-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Description: make imports work when the module is a module/index.js
Author: Julien Puydt
Forwarded: yes

--- a/lib/file_resolver.js
+++ b/lib/file_resolver.js
@@ -67,6 +67,12 @@
   for (var i = 0, length = paths.length; i < length; i++) {
     var includePath = paths[i];
     var resolved = Path.resolve(includePath, importedPath);
+
+    var index = Path.join(resolved, 'index.js')
+    if (fs.existsSync(index)) {
+      return index;
+    }
+
     if (!~resolved.lastIndexOf('.')) {
       resolved += '.js';
     }