Uploaded image for project: 'ClojureScript'
  1. CLJS-2592

:npm-deps using ES6 modules with .mjs extensions are not detected correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: 1.10.238
    • Fix versions: None
    • Labels:
      None
    • Environment:

      Tested with both ClojureScript 1.10.64 and ClojureScript master (4375a63)

      Description

      Several modern JS libraries have adopted the .mjs extension for ES6 modules. Two examples of such libraries are https://github.com/leebyron/iterall/ and https://github.com/graphql/graphql-js/.

      Indexing packages that use this file extension (e.g. for their index.mjs) and adding them to the compiler environment is currently broken. As a result, these packages will not be resolvable at runtime, leading to errors such as this:

      base.js:1357 Uncaught Error: Undefined nameToPath for iterall
          at visitNode (base.js:1357)
          at Object.goog.writeScripts_ (base.js:1369)
          at Object.goog.require (base.js:706)
          at index.html:7
      

      I've created a minimal repository to reproduce the issue here: https://github.com/Jannis/cljs-npm-deps-mjs-issue.

      I'll attach a patch with a fix and two tests (one to verify indexing, one to verify building) shortly.

        Attachments

        1. CLJS-2592__1.patch
          7 kB
        2. CLJS-2592.3.patch
          13 kB
        3. CLJS-2592.4.patch
          12 kB
        4. CLJS-2592.patch
          7 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jannis Jannis Pohlmann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: