From 4d35b850951fc487a0addb1353c0d0a08f0f0922 Mon Sep 17 00:00:00 2001 From: Brendan Berg Date: Mon, 16 Dec 2024 14:23:51 +0700 Subject: [PATCH 1/2] replace parseQuery with getOptions --- src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index c52637b..ca94c6b 100644 --- a/src/index.js +++ b/src/index.js @@ -16,12 +16,12 @@ export default function loader(source) { this.cacheable(); } - const query = loaderUtils.parseQuery(this.query); - const cacheParserResults = !!query.cache; - const optimizeParser = query.optimize || 'speed'; - const trace = !!query.trace; - const dependencies = JSON.parse(query.dependencies || '{}'); - const allowedStartRules = extractAllowedStartRules(query); + const options = loaderUtils.getOptions(this) || {}; + const cacheParserResults = !!options.cache; + const optimizeParser = options.optimize || 'speed'; + const trace = !!options.trace; + const dependencies = JSON.parse(options.dependencies || '{}'); + const allowedStartRules = extractAllowedStartRules(options); // Description of PEG.js options: https://github.com/pegjs/pegjs#javascript-api const pegOptions = { From 06ed206d65c82f936de2a9be13eab623a22e2429 Mon Sep 17 00:00:00 2001 From: Brendan Berg Date: Mon, 16 Dec 2024 16:35:08 +0700 Subject: [PATCH 2/2] add backwards compatibility --- src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ca94c6b..18cbbdd 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,10 @@ export default function loader(source) { this.cacheable(); } - const options = loaderUtils.getOptions(this) || {}; + const options = + this.query && this.query.startsWith && this.query.startsWith("?") + ? loaderUtils.parseQuery(this.query) + : loaderUtils.getOptions(this) || {}; const cacheParserResults = !!options.cache; const optimizeParser = options.optimize || 'speed'; const trace = !!options.trace;