shadow-cljs icon indicating copy to clipboard operation
shadow-cljs copied to clipboard

Failed to inspect file when trying to use a dependency from NPM

Open mauricioszabo opened this issue 2 years ago • 2 comments

I had to use a NPM dependency that have the following code on it:

class GitHost {
  constructor (type, user, auth, project, committish, defaultRepresentation, opts = {}) {
    Object.assign(this, GitHost.#gitHosts[type], {
      type,
      user,
      auth,
      project,
      committish,
      default: defaultRepresentation,
      opts,
    })
  }

  static #gitHosts = { byShortcut: {}, byDomain: {} }
  ///...
}```

This, surprisingly, is valid Javascript code, but when I tried to add this dependency  to shadow-cljs (either by using `:target :browser` or by using `:js-options {:js-provider :shadow}`) the build fails with the message:

Failed to inspect file /home/mauricio/...

it was required from /home/mauricio/...

Errors encountered while trying to parse file /home/mauricio/... {:line ..., :message "'identifier' expected"}


The line and column match exactly the beginning of `.#gitHosts[type],`

mauricioszabo avatar Apr 14 '23 03:04 mauricioszabo

This is not yet supported by the Closure Compiler I guess. You can use :js-provider :external if you must use this package. Otherwise we'll have to wait till the Closure Compiler implements it. Nothing I can do from the shadow-cljs side.

thheller avatar Apr 14 '23 03:04 thheller

This is the related issue https://github.com/google/closure-compiler/issues/2731. Still nothing though.

thheller avatar Nov 22 '23 08:11 thheller