Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error on dynamic import #486

Closed
jakzo opened this issue Apr 22, 2019 · 6 comments
Closed

Compiler error on dynamic import #486

jakzo opened this issue Apr 22, 2019 · 6 comments

Comments

@jakzo
Copy link

jakzo commented Apr 22, 2019

JS supports using import as a function. When shadow-cljs encounters one of these, the Closure compiler fails.

Example

:requireing a JS file with the following code:

export default function() {
  import("hello").then(function(mod) {
    alert(mod.default);
  });
}

will fail when compiling with this error:

shadow-cljs - config: /.../shadow-dynamic-import-issue/shadow-cljs.edn  cli version: 2.7.17  node: v11.6.0
shadow-cljs - starting ...
[:dynamic] Compiling ...
errors in file: /.../shadow-dynamic-import-issue/node_modules/dynamic-import/index.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/dynamic-import/index.js", :js-requires [], :js-errors [{:line 2, :column 2, :message "'}' expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false}
ExceptionInfo: errors in file: /.../shadow-dynamic-import-issue/node_modules/dynamic-import/index.js
        clojure.core/ex-info (core.clj:4739)
        clojure.core/ex-info (core.clj:4739)
        shadow.build.npm/get-file-info* (npm.clj:530)
        ...

Repro: https://github.com/jakzo/shadow-dynamic-import-issue

@thheller
Copy link
Owner

Dynamic import is not currently supported by the Closure Compiler (or shadow-cljs).

Some initial support was added recently but I'm not yet sure how final support will look. I don't think this is a good idea to begin with so we'll see how it turns out.

@FalseProtagonist
Copy link

Sorry, just to check that I'm interpreting these issues correctly - it's now supported by Google Closure but not planned to be supported in shadow-cljs (?)

@thheller
Copy link
Owner

Depends. I have not tested enough yet. Currently blocked by ClojureScript being incompatible with the latest Closure Compiler.

@coatlicue89
Copy link

Hi, seems dynamic imports are supported by the Closure Compiler https://github.com/google/closure-compiler/wiki/JS-Modules#dynamic-import-expressions . But not working for me actually. Whats the status? can I help?

@thheller
Copy link
Owner

Please open a new ticket with a reproducible repo for something that may not work. This is not exactly a "small topic". So, without knowing what are trying to do I can't comment on the status.

@coatlicue89
Copy link

Issue created #1084 thanks for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants