thread-loader
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -5,2 +5,9 @@ # Changelog | ||
### [3.0.3](https://github.com/webpack-contrib/thread-loader/compare/v3.0.2...v3.0.3) (2021-04-13) | ||
### Bug Fixes | ||
* `getOptions` usage ([#113](https://github.com/webpack-contrib/thread-loader/issues/113)) ([d7531ef](https://github.com/webpack-contrib/thread-loader/commit/d7531efd39b90eff3e6cdd5e6917997f5b392bff)) | ||
### [3.0.2](https://github.com/webpack-contrib/thread-loader/compare/v3.0.1...v3.0.2) (2021-04-12) | ||
@@ -7,0 +14,0 @@ |
@@ -7,2 +7,4 @@ "use strict"; | ||
var _querystring = _interopRequireDefault(require("querystring")); | ||
var _loaderRunner = _interopRequireDefault(require("loader-runner")); | ||
@@ -12,2 +14,6 @@ | ||
var _jsonParseBetterErrors = _interopRequireDefault(require("json-parse-better-errors")); | ||
var _schemaUtils = require("schema-utils"); | ||
var _readBuffer = _interopRequireDefault(require("./readBuffer")); | ||
@@ -168,2 +174,52 @@ | ||
}, | ||
// Not an arrow function because it uses this | ||
getOptions(schema) { | ||
// loaders, loaderIndex will be defined by runLoaders | ||
const loader = this.loaders[this.loaderIndex]; // Verbatim copy from | ||
// https://github.com/webpack/webpack/blob/v5.31.2/lib/NormalModule.js#L471-L508 | ||
// except eslint/prettier differences | ||
// -- unfortunate result of getOptions being synchronous functions. | ||
let { | ||
options | ||
} = loader; | ||
if (typeof options === 'string') { | ||
if (options.substr(0, 1) === '{' && options.substr(-1) === '}') { | ||
try { | ||
options = (0, _jsonParseBetterErrors.default)(options); | ||
} catch (e) { | ||
throw new Error(`Cannot parse string options: ${e.message}`); | ||
} | ||
} else { | ||
options = _querystring.default.parse(options, '&', '=', { | ||
maxKeys: 0 | ||
}); | ||
} | ||
} // eslint-disable-next-line no-undefined | ||
if (options === null || options === undefined) { | ||
options = {}; | ||
} | ||
if (schema) { | ||
let name = 'Loader'; | ||
let baseDataPath = 'options'; | ||
let match; // eslint-disable-next-line no-cond-assign | ||
if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) { | ||
[, name, baseDataPath] = match; | ||
} | ||
(0, _schemaUtils.validate)(schema, options, { | ||
name, | ||
baseDataPath | ||
}); | ||
} | ||
return options; | ||
}, | ||
emitWarning: warning => { | ||
@@ -170,0 +226,0 @@ writeJson({ |
{ | ||
"name": "thread-loader", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Runs the following loaders in a worker pool", | ||
@@ -44,5 +44,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"json-parse-better-errors": "^1.0.2", | ||
"loader-runner": "^4.1.0", | ||
"loader-utils": "^2.0.0", | ||
"neo-async": "^2.6.2" | ||
"neo-async": "^2.6.2", | ||
"schema-utils": "^3.0.0" | ||
}, | ||
@@ -76,3 +78,3 @@ "devDependencies": { | ||
"sass": "^1.27.0", | ||
"sass-loader": "^10.0.4", | ||
"sass-loader": "^11.0.1", | ||
"standard-version": "^9.0.0", | ||
@@ -79,0 +81,0 @@ "webpack": "^5.3.0", |
43261
907
6
+ Addedschema-utils@^3.0.0
+ Addedjson-parse-better-errors@1.0.2(transitive)