Skip to content

Pinning highlight.js does not work (Probably not an issue with importmap-rails) #270

@tagliala

Description

@tagliala

Hello,

I was trying to use importmap-rails to vendor highlight.js

As a non-javascript developer I'm struggling into understanding whether this is an issue with importmap-rails (probably it isn't) or in highlight.js, which is not importmap friendly when it comes to vendoring javascript files (can't use the cdn)

I only need to highlight json files for testing purposes, so I wanted to pin highlight.js/lib/core and highlight.js/lib/languages/json

The following happens when trying to pin core:

$ bin/importmap pin highlight.js/lib/core
Pinning "highlight.js/lib/core" to vendor/javascript/highlight.js/lib/core.js via download from https://ga.jspm.io/npm:[email protected]/es/core.js

$ cat vendor/javascript/highlight.js--lib--core.js 
// highlight.js/lib/[email protected] downloaded from https://ga.jspm.io/npm:[email protected]/es/core.js

import o from"../lib/core.js";export{o as HighlightJS,o as default};

As you can see there is a relative import to ../lib/core.js, and that results in a 404 error in the browser console.

Pinning highlight.js/lib/languages/json works instead, because the code is actually there

By inspecting the package source at https://www.npmjs.com/package/highlight.js?activeTab=code, I can see that package.json has some exports related to core:

    "./lib/core": {
      "require": "./lib/core.js",
      "import": "./es/core.js"
    },

Should I report this to highlight.js?

Thanks for any help you can provide

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions