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

feat: add resultHook (options.resultHook) #684

Closed
wants to merge 2 commits into from

Conversation

kossnocorp
Copy link

When resultHook is passed with the query, css-loader will call it with the loader context and the result. It will allow extending css-loader functionality without using a fork. For instance, it will be possible to generate TypeScript typing files on the fly.

What kind of change does this PR introduce?
This PR introduces a feature.

Did you add tests for your changes?
Yes.

If relevant, did you update the README?
Yes.

Summary
I want to add TypeScript support to decss. To do so I have to generate type definition files. I can't do it via additional loader as I need an access to raw exports object.

Does this PR introduce a breaking change?
Nope.

Other information
¯\(ツ)

When resultHook is passed with the query, css-loader will call it with
the loader context and the result. It will allow extending css-loader
functionality without using a fork. For instance, it will be possible to
generate TypeScript typing files on the fly.
@jsf-clabot
Copy link

jsf-clabot commented Feb 26, 2018

CLA assistant check
All committers have signed the CLA.

@michael-ciniawsky michael-ciniawsky changed the title Allow to pass resultHook to the loader feat: add resultHook (options.resultHook) Feb 26, 2018
Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry, but I have to decline this, it's out-of-scope for this loader to support specific use cases or libraries

@kossnocorp
Copy link
Author

Well, it's sad to hear. Any alternatives to achieve that?

@alexander-akait
Copy link
Member

@kossnocorp
Copy link
Author

@evilebottnawi are you suggest to eval css-loader's output? I can see how this could help but I'm afraid there are will be too many corner cases to make it stable.

@alexander-akait
Copy link
Member

@kossnocorp look here in theory we can use meta to pass result. But in future we remove css-modules from loader in favor postcss-plugin or css-modules-loader. You can help us with this 👍

@kossnocorp
Copy link
Author

@evilebottnawi having meta would be great. If I properly understand webpack allows to pass additional data along with source? I'm not familiar with this feature, can you please direct me to the docs or examples of usage?

Also, @michael-ciniawsky WDYT?

@alexander-akait
Copy link
Member

@kossnocorp no docs 😄 Yep, for pass own data from loader to other loader

@kossnocorp
Copy link
Author

@michael-ciniawsky what do you think, won't it be out of scope?

@kossnocorp
Copy link
Author

😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants