webpack / schema-utils

Options Validation
MIT License
246 stars 39 forks source link

feat: port loaderContext's getOptions from webpack #123

Closed qnighy closed 3 years ago

qnighy commented 3 years ago

This PR contains a:

Motivation / Use-Case

To help https://github.com/webpack-contrib/thread-loader/issues/106.

https://github.com/webpack-contrib/thread-loader/pull/113 will surely fix the issue above, but the PR will create multiple copies of getOptions implementation. https://github.com/webpack-contrib/thread-loader/pull/113#pullrequestreview-632931951

This PR attempts to extract the common part from getOptions to reuse in webpack and thread-loader.

Breaking Changes

No.

Additional Info

This feature may not fit schema-utils' intended scope. I'm adding the feature here because it's a validation-related feature and webpack already depends on schema-utils, but I'm willing to do extra work if there's a better place for the feature.

cc: @alexander-akait

codecov[bot] commented 3 years ago

Codecov Report

Merging #123 (5fe159a) into master (2e768a1) will increase coverage by 0.06%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #123      +/-   ##
==========================================
+ Coverage   97.57%   97.63%   +0.06%     
==========================================
  Files           6        7       +1     
  Lines         700      720      +20     
  Branches      299      304       +5     
==========================================
+ Hits          683      703      +20     
  Misses         15       15              
  Partials        2        2              
Impacted Files Coverage Δ
src/getLoaderOptions.js 100.00% <100.00%> (ø)
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2e768a1...5fe159a. Read the comment docs.

qnighy commented 3 years ago

@alexander-akait then where do you think is the best?

alexander-akait commented 3 years ago

Inside thread-loader, we should run webpack API like we do with other loaders methods

qnighy commented 3 years ago

Inside thread-loader, we should run webpack API like we do with other loaders methods

@alexander-akait That seems too difficult to me. Isn't there an option to release https://github.com/webpack-contrib/thread-loader/pull/102 without getOptions for the time being? After that I might have a bandwidth for this.

qnighy commented 3 years ago

Closing in favor of https://github.com/webpack-contrib/thread-loader/pull/113. Thanks!