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

Enable easy embedding of vite builds #4105

Open
lutzhelm opened this issue Feb 14, 2025 · 0 comments
Open

Enable easy embedding of vite builds #4105

lutzhelm opened this issue Feb 14, 2025 · 0 comments
Labels
embed Issues related to installing / embedding Mirador in another application

Comments

@lutzhelm
Copy link
Contributor

Since alpha.9, embedding does no longer work as it is described in the README just by adding a CDN bundle to an HTML doc:

<script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"></script>

The bundle is missing react and react-dom which (because they are peer denedencies) are declared as externals in the rollup options of the vite build config. (alpha.9 and alpha.10 bundles also lack react/jsx-runtime but that has been changed on main.)

Mirador is loaded when the peer dependencies are also provided via script tags, but it only took me a few clicks to encounter a reference error (specifically selecting the index sidebar panel for a manifest with structures).

<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/mirador@{version to be released yet}/dist/mirador.min.js"><!-- actually used a local build from main --></script>

So a better way would be to provide an additional bundle that also provides the missing peer dependencies.

The CDNs work in different ways:

  • UNPKG delivers everything that is on npmjs
  • I believe it's the same for jsdelivr
  • cdnjs requires a package to be listed in a specific Github repo

We also previously discussed offering bundles that already contain some of the plugins, that's a different issue but it should be considered while deciding on an approach to tackle this issue.

We should not require people to build their own Mirador builds with npm if they just want to use it as-is.

@lutzhelm lutzhelm added the embed Issues related to installing / embedding Mirador in another application label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embed Issues related to installing / embedding Mirador in another application
Projects
None yet
Development

No branches or pull requests

1 participant