loader-runner icon indicating copy to clipboard operation
loader-runner copied to clipboard

Feature proposal: Add getOptions to loaderContext inside runLoaders

Open marcalexiei opened this issue 3 years ago • 1 comments

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.

marcalexiei avatar Mar 25 '21 23:03 marcalexiei

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 🤔

Randy808 avatar May 30 '21 15:05 Randy808