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

Failed to inspect file when trying to use highlight.js #1116

Closed
chr15m opened this issue May 1, 2023 · 3 comments
Closed

Failed to inspect file when trying to use highlight.js #1116

chr15m opened this issue May 1, 2023 · 3 comments

Comments

@chr15m
Copy link

chr15m commented May 1, 2023

Source here: https://github.com/highlightjs/highlight.js/blob/main/src/languages/isbl.js

Compilation failed!
Failed to inspect file
  node_modules/highlight.js/lib/languages/isbl.js

it was required from
  node_modules/highlight.js/lib/index.js

Errors encountered while trying to parse file
  node_modules/highlight.js/lib/languages/isbl.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}

RuntimeException: Exception parsing "node_modules/highlight.js/lib/languages/isbl.js"

I guess like #1110 this is a Google Closure issue?

@thheller
Copy link
Owner

thheller commented May 1, 2023

highlight.js has been problematic for a while, there are a couple other issues regarding that. It is not #1110.

Luckily this is easily worked arround since that file is unlikely to be used anyways. If you control where/how highlight.js is used I recommend rewriting your requires to only include what you actually need.

You can see an example of this in this lib. https://github.com/superstructor/re-highlight

So, basically instead of (:require ["highlight.js" :as hl]) you do https://github.com/superstructor/re-highlight/blob/37cd2ea194351c5c8b49e048327b66d340132405/src/re_highlight/core.cljs#L5-L6, and only actually require the support you need. This makes the build substantially smaller, without any downside.

@chr15m
Copy link
Author

chr15m commented May 1, 2023

Unfortunately it is being consumed by an npm dep but I think I figured out a way to squash the error by injecting an empty JS module into that one file during post-install. Thanks!

@thheller
Copy link
Owner

thheller commented May 1, 2023

You can do :js-options {:resolve {"highlight.js" {:target :npm :require "highlight.js/lib/core"}}} in the build config and then add the additional stuff you actually need by requiring it yourself. That should also address the problem.

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

2 participants