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

middleman build broken in v4.1.1 when requiring .js files from .coffee files #135

Open
betesh opened this issue Jul 19, 2021 · 2 comments
Open

Comments

@betesh
Copy link

betesh commented Jul 19, 2021

When a file in source/javascripts has a .js.coffee extension and contains "#= require site.js", middleman build succeeds with middleman-sprockets v4.1.0 but fails with v4.1.1. See reproduction script below.

Changing the extension from ".js.coffee" to ".coffee" fixes it. If this breaking change was intended, it should be noted in the README and 4.1.1 should have been versioned 5.0.0.

Expected behavior and actual behavior

Expected

== Sprockets will render css with SassC
      create  build/javascripts/other.js
      create  build/images/.keep
      create  build/javascripts/site.js
      create  build/index.html
Project built successfully.

Actual

== Sprockets will render css with SassC
~/sprockets-bug/source/javascripts/other.js.coffee:1: couldn't find file 'site.js' with type 'text/coffeescript' (Sprockets::FileNotFound)
Checked in these paths: 
  ~/sprockets-bug/source/javascripts
  ~/sprockets-bug/source/stylesheets
  ~/sprockets-bug/source
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/resolve.rb:62:in `resolve!'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:409:in `resolve'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:216:in `process_require_directive'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:189:in `block in process_directives'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:187:in `each'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:187:in `process_directives'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:84:in `_call'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:65:in `call'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/environment.rb:31:in `find_asset'
	from ~/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/base.rb:119:in `[]'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/resource.rb:37:in `block in sprockets_asset'
	from ~/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4/lib/active_support/notifications.rb:205:in `instrument'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-core-4.4.0/lib/middleman-core/util.rb:21:in `instrument'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/resource.rb:36:in `sprockets_asset'
	from ~/.rvm/gems/ruby-3.0.2/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from ~/.rvm/gems/ruby-3.0.2/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from ~/.rvm/gems/ruby-3.0.2/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/extension.rb:98:in `map'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/extension.rb:98:in `linked_resources'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/extension.rb:111:in `linked_resources!'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/extension.rb:61:in `block in manipulate_resource_list'
	from ~/.rvm/gems/ruby-3.0.2/gems/activesupport-6.1.4/lib/active_support/notifications.rb:205:in `instrument'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-core-4.4.0/lib/middleman-core/util.rb:21:in `instrument'
	from ~/.rvm/gems/ruby-3.0.2/gems/middleman-sprockets-4.1.1/lib/middleman-sprockets/extension.rb:60:in `manipulate_resource_list'

Steps to reproduce the problem (from a clean middleman installation) or example repo

$ middleman new sprockets-bug && \
  cd sprockets-bug && \
  echo "gem 'middleman-sprockets', '= v4.1.1' " >> Gemfile &&\
  echo "activate :sprockets" >> config.rb && \
  echo "#= require site.js" >> source/javascripts/other.js.coffee && \
  rm source/stylesheets/ -rf && \
  bundle && \
  bundle exec middleman build

Additional information

  • Ruby version: 3.0.2
  • Middleman version: 4.4.0
  • Middleman Sprockets version: 4.1.1
  • OS version:
$ lsb_release --all
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.7 LTS
Release:	16.04
Codename:	xenial
@sdey-s1
Copy link

sdey-s1 commented Dec 14, 2022

did you find any solution yet?

@Jack12816
Copy link

  • Rename the source/javascripts/site.js.coffee to source/javascripts/site.js
  • Convert the #= require to //= require lines

Like mentioned in the first lines of the issue. Works with Sprockets 4 on my end. ✌️

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

No branches or pull requests

3 participants