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

Issue with importmaps and lit-html #161

Closed
lylo opened this issue Mar 5, 2024 · 9 comments · Fixed by #163
Closed

Issue with importmaps and lit-html #161

lylo opened this issue Mar 5, 2024 · 9 comments · Fixed by #163

Comments

@lylo
Copy link

lylo commented Mar 5, 2024

Playing with the latest Rhino and importmaps.

The problem is the second line below (to do with the trailing slash):

Pinning "lit-html" to vendor/javascript/lit-html.js via download from https://ga.jspm.io/npm:lit-html@2.8.0/lit-html.js
Pinning "lit-html/" to vendor/javascript/lit-html/.js via download from https://ga.jspm.io/npm:lit-html@2.8.0/
/Users/olly/.gem/ruby/3.3.0/gems/importmap-rails-2.0.1/lib/importmap/packager.rb:80:in `handle_failure_response': Unexpected response code (404) (Importmap::Packager::HTTPError)

Not sure if it's an Importmap gem issue or Rhino config, but figured I'd mention it here.

@KonnorRogers
Copy link
Owner

Yea this is unfortunately a known issue with importmaps 2.x and it's new vendoring by default approach.

rails/importmap-rails#217

It doesn't properly account for "exportmaps" remappings.

You could try:

bin/importmap pin rhino-editor/cdn/exports/index.js and see if that works. I can't remember how it determines dependencies, if it reads them from package.json or actually reads file contents.

@lylo
Copy link
Author

lylo commented Mar 5, 2024

Thank you for explaining that Konnor. Shame but hopefully a fix will come out in the wash at some point.

@KonnorRogers
Copy link
Owner

@lylo looks like there's a pretty big pending PR that should hopefully fix things.

rails/importmap-rails#235

@lylo
Copy link
Author

lylo commented Mar 6, 2024

Oh cool, thanks. I've subscribed to that 👌

@KonnorRogers
Copy link
Owner

@lylo Added docs for workaround until that issue resolves itself with importmaps and there can be a "proper" way to handle it.

@KonnorRogers
Copy link
Owner

@lylo
Copy link
Author

lylo commented Mar 28, 2024

Thank you @KonnorRogers, very kind

@lylo
Copy link
Author

lylo commented Mar 30, 2024

The problem I'm finding with this is that you need to do

bin/importmap pin rhino-editor

in order for the dependencies (i.e. @tiptap/core etc) to be pinned also. But this bails when trying to pin lit-html

Pinning "lit" to vendor/javascript/lit.js via download from https://ga.jspm.io/npm:lit@2.8.0/index.js
Pinning "lit-element/lit-element.js" to vendor/javascript/lit-element/lit-element.js.js via download from https://ga.jspm.io/npm:lit-element@3.3.3/lit-element.js
Pinning "lit-html" to vendor/javascript/lit-html.js via download from https://ga.jspm.io/npm:lit-html@2.8.0/lit-html.js
Pinning "lit-html/" to vendor/javascript/lit-html/.js via download from https://ga.jspm.io/npm:lit-html@2.8.0/
/Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/packager.rb:80:in `handle_failure_response': Unexpected response code (404) (Importmap::Packager::HTTPError)
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/packager.rb:118:in `download_package_file'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/packager.rb:57:in `download'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/commands.rb:19:in `block in pin'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/commands.rb:17:in `each'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/commands.rb:17:in `pin'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/importmap-rails-2.0.1/lib/importmap/commands.rb:141:in `<main>'
	from <internal:/Users/olly/.rbenv/versions/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from <internal:/Users/olly/.rbenv/versions/3.2.3/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from /Users/olly/.rbenv/versions/3.2.3/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:34:in `require'
	from bin/importmap:4:in `<main>'

It feels like the many dependencies that Rhino/TipTap require on the JS side cause too many problems with importmaps in its current state. Unless there's a definitive list of what to pin? Either way, lit-html seems to cause a whole manner of problems when being vendored.

I might go back to the drawing board with npm!

@KonnorRogers
Copy link
Owner

Yea this exact issue is why I have a prebundled file and a way to just curl it. Otherwise importmaps tries to download the full dependency tree

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

Successfully merging a pull request may close this issue.

2 participants