Skip to content

Importing diff2html via rails Importmap causes “TypeError: n.Template is not a constructor” #567

Description

@doguto

Description

When using diff2html via Rails Importmap, a runtime error occurs when importing the library.

Environment

Rails: 7.x (using Importmap)

diff2html: 3.4.52

Browser: Chrome

Importmap configuration

# config/importmap.rb
pin "diff2html", to: "https://ga.jspm.io/npm:diff2html@3.4.52/lib-esm/diff2html.js"

usage

// only import
import * as Diff2Html from "diff2html"

Error message

The following error appears in the browser console:

diff2html-templates.js:3 Uncaught TypeError: n.Template is not a constructor
    at diff2html-templates.js:3:41
    at (anonymous)

What I’ve tried

Tested with both jspm.io and jsDelivr CDNs → same error

Tried older versions (e.g., 2.8.0) → no error caused

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions