-
Notifications
You must be signed in to change notification settings - Fork 104
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
Sprockets 4 Compatibility #65
Conversation
I'm able to get a really simple test app working with this gem with these changes, but so far haven't gotten the tests to pass.
cool, i may be able to help with the tests if needed. LMK |
it looks like the issue might be with switching to be careful that your example app is using sassc - i usually double check by intentionally creating a syntax error and seeing that it is |
In my example app I added a syntax error and it looks like it's coming from
That was a good debugging idea. I'll have to dig into these test failures a bit more. |
I did a It looks like no transformer is running, not the sassc-rails one nor the built in Sprockets one on these 9 failing tests. In the loader right after we set processors I added
When I run sprockets tests I get results like this
You can see where the However when I do the same with the scss-rails test suite I get results like this:
I think the difference is that Sprockets 4 will actually render your So
In the tests should be
|
Ah, that makes sense. Is that extension change backwards compatible? |
b0bb332
to
c62a5ea
Compare
Sprockets 3 supports both `register_transformer` and `register_engine` unfortunately they don't play well with one another i.e. if a "transformer" is registered using `register_engine` it behaves slightly differently than when registered via `register_transformer`. This cause problems because the default engines in `lib/sprockets.rb` that are registered all use `register_engine` so if we want to over-write the existing sass engine we have to do both calls when possible.
Got all tests green. Did have to use both |
Anything else to do here? Any questions? |
Frustratingly you may need to use both `register_engine` to get the behavior your want in Sprockets 3 even if you're using the new API (i.e. `register_transformer` etc.). I think this is because the different APIs have a different backend but I haven't looked into it enough to know exactly why they diverged. Here's a PR that shows the problem: sass/sassc-rails#65 If you only call `register_transformer` then the Sprockets 3 tests will fail. I think this is because the processor built into `lib/sprockets.rb` and registered via `register_engine` still gets executed. By registering the sassc processor again with `register_engine` we're writing over the built in processor to ensure ours takes priority. I'm not 100% on this cause but it seems reasonable. This PR introduces a way to silence the deprecation for `register_engine` so that libraries that still need the `register_engine` API to function correctly (such as sassc-rails) can operate without deprecations. This is an opt-in flag, we assume if you use the flag that you're aware of the new API and have updated your library appropriately. After this PR I'm going to change the docs to show how to use both `register_transformer` and `register_engine` at the same time.
Frustratingly you may need to use both `register_engine` to get the behavior your want in Sprockets 3 even if you're using the new API (i.e. `register_transformer` etc.). I think this is because the different APIs have a different backend but I haven't looked into it enough to know exactly why they diverged. Here's a PR that shows the problem: sass/sassc-rails#65 If you only call `register_transformer` then the Sprockets 3 tests will fail. I think this is because the processor built into `lib/sprockets.rb` and registered via `register_engine` still gets executed. By registering the sassc processor again with `register_engine` we're writing over the built in processor to ensure ours takes priority. I'm not 100% on this cause but it seems reasonable. This PR introduces a way to silence the deprecation for `register_engine` so that libraries that still need the `register_engine` API to function correctly (such as sassc-rails) can operate without deprecations. This is an opt-in flag, we assume if you use the flag that you're aware of the new API and have updated your library appropriately. After this PR I'm going to change the docs to show how to use both `register_transformer` and `register_engine` at the same time.
Frustratingly you may need to use both `register_engine` to get the behavior your want in Sprockets 3 even if you're using the new API (i.e. `register_transformer` etc.). I think this is because the different APIs have a different backend but I haven't looked into it enough to know exactly why they diverged. Here's a PR that shows the problem: sass/sassc-rails#65 If you only call `register_transformer` then the Sprockets 3 tests will fail. I think this is because the processor built into `lib/sprockets.rb` and registered via `register_engine` still gets executed. By registering the sassc processor again with `register_engine` we're writing over the built in processor to ensure ours takes priority. I'm not 100% on this cause but it seems reasonable. This PR introduces a way to silence the deprecation for `register_engine` so that libraries that still need the `register_engine` API to function correctly (such as sassc-rails) can operate without deprecations. This is an opt-in flag, we assume if you use the flag that you're aware of the new API and have updated your library appropriately. After this PR I'm going to change the docs to show how to use both `register_transformer` and `register_engine` at the same time.
Frustratingly you may need to use both `register_engine` to get the behavior your want in Sprockets 3 even if you're using the new API (i.e. `register_transformer` etc.). I think this is because the different APIs have a different backend but I haven't looked into it enough to know exactly why they diverged. Here's a PR that shows the problem: sass/sassc-rails#65 If you only call `register_transformer` then the Sprockets 3 tests will fail. I think this is because the processor built into `lib/sprockets.rb` and registered via `register_engine` still gets executed. By registering the sassc processor again with `register_engine` we're writing over the built in processor to ensure ours takes priority. I'm not 100% on this cause but it seems reasonable. This PR introduces a way to silence the deprecation for `register_engine` so that libraries that still need the `register_engine` API to function correctly (such as sassc-rails) can operate without deprecations. This is an opt-in flag, we assume if you use the flag that you're aware of the new API and have updated your library appropriately. After this PR I'm going to change the docs to show how to use both `register_transformer` and `register_engine` at the same time.
env.register_engine '.scss', SassC::Rails::ScssTemplate | ||
if env.respond_to?(:register_transformer) | ||
env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new #->() { puts "yoyoyoy" } | ||
env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new #->() { puts "yoyoyoy" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave the puts "yoyoyoy"
in at the end of these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, can you send me a PR to get rid of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll have a go tonight (UK time) 👍
I just added issue #93, I think it's related. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
I'm able to get a really simple test app working with this gem with these changes, but so far haven't gotten the tests to pass.