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

Feature proposal: Add getOptions to loaderContext inside runLoaders #52

Open
marcalexiei opened this issue Mar 25, 2021 · 1 comment
Open

Comments

@marcalexiei
Copy link

Feature Proposal

Introduces getOptions function inside loaderContext.

The implementation of this function should mirror the one inside webpack NormalModule.
I think we can use loader context in the same way of webpack to extract loader's options and validate them if a schema is provided (Include schema-utils and json-parse-better-errors (or maybe directly use JSON.parse) as dependencies).

Feature Use Case

getOptions will become available to loaders called via loader-runner.
thread-loader is one of them and has an open issue about undefined this.getOptions.


I have created a simple reproduction repository for reference.
If you agree I can try to do a PR.

@Randy808
Copy link

What would your implementation look like? Would you be checking for the presence of 'getOptions' in the loaderContext and add it if not there? Maybe the original PR that added 'getOptions' to webpack should've just lived in this repo to prevent code duplication 🤔

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

2 participants