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

Some hacks required to get it work with non-Rails #25

Open
katafrakt opened this issue Aug 26, 2020 · 3 comments
Open

Some hacks required to get it work with non-Rails #25

katafrakt opened this issue Aug 26, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@katafrakt
Copy link

Hey! I'm trying to use Snowpacker with Hanami and I finally managed to get it to work, but I needed to add two hacks to Snowpacker to achieve that. I wonder what would be your ideas for proper fixes.

Hack 1: 304 + Content-Type

When I reload the page and Snowpack server returns 304 (file not changed), Rack complains about it with an exception:

Rack::Lint::LintError: Content-Type header found in 304 response, not allowed
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:710:in `block in check_content_type'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:706:in `each'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:706:in `check_content_type'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:70:in `_call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
	/home/katafrakt/.rbenv/versions/2.6.6/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

I hacked it by modifying proxy.rb and adding this to the end of perform_request:

        re = super(env)
          if re[0] == 304
            re[1].delete('content-type')
          end
        re
      else

Hack 2: /web_modules

I'm trying to use Vue 3 with it. To achieve that I had to reroute /web_modules too in Rack proxy. This hack is in the beginning of perform_requests:

env["PATH_INFO"].gsub!(/^\/web_modules/, "/#{Snowpacker.config.output_path}/web_modules")

I know both of these are stupid, but with that it works, so they can be a starting point to find proper solutions.

Thanks for this project, by the way!

@KonnorRogers
Copy link
Owner

KonnorRogers commented Aug 26, 2020

@katafrakt first of all, really cool that you're trying out Snowpacker. Unfortunately, this gem is also wildly incomplete in its current state. I didn't expect anybody to be using it yet to be honest.

As for fixes, I have never personally used Hanami so I'd have to look into it a little further...I also haven't tested it with SPAs yet...

Like I said this project isn't really ready to be used in its current state, but I do appreciate being made aware of these issues. I'm going to leave this issue open for when I get around to testing it.

@katafrakt
Copy link
Author

I think these aren't really Hanami-related, just non-Rails related, and should also happen in Sinatra or Roda. I can check that. For the first issue (304), I suspect that Rails has some extra middleware which fixes it.

Anyway, if you need any help, let me know. Hanami is currently missing any kind of modern frontend stack integration and I think Snowpack looks far more promising than Webpack.

@KonnorRogers
Copy link
Owner

@katafrakt good to know...I did not realize this was an issue with Hanami. I imagine this also rings true for Sinatra.

As of right now, the Snowpacker development is "halted" because I'm working on a Snowpack plugin to bundle for production which will include a Manifest of assets as well as

I'll definitely let you know should anything come up as to any issues I may need help with.

Thank you again for the feedback and I'll work on making sure these are non-issues in the future!

@KonnorRogers KonnorRogers added the bug Something isn't working label Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants