From ff7134f34dc655ba838d8da6b8f39b6615e0eb09 Mon Sep 17 00:00:00 2001 From: sliftist <52947011+sliftist@users.noreply.github.com> Date: Sat, 22 Feb 2020 15:11:35 -0500 Subject: [PATCH] Default getOptions to return {} Default getOptions to return {}, that way loaders don't break when the loader options are removed. For example, if the loader changes from "example-loader?setFlag" to "example-loader". Without this change every single user of getOptions will almost certainly want to default getOptions to null manually. --- lib/getOptions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/getOptions.js b/lib/getOptions.js index 9cbbed4..7fc4337 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -5,7 +5,12 @@ const parseQuery = require('./parseQuery'); function getOptions(loaderContext) { const query = loaderContext.query; - if (typeof query === 'string' && query !== '') { + if (query === '') { + // webpack sets query to '' when no options are set + return {}; + } + + if (typeof query === 'string') { return parseQuery(loaderContext.query); }