From 30b39766fab4232d598dab837038cea97c725ddd Mon Sep 17 00:00:00 2001 From: Gavriel Rachael-Homann Date: Thu, 14 Jan 2021 16:30:54 -0600 Subject: [PATCH] Pass thru twigOptions to compiler regardless of code path When options are provided to this loader via webpack config, they should always pass thru to the compiler regardless of which codepath is taken. This unfortunately isn't the case for all webpack configs, resulting in critical options like autoescape: true not being seen when compiling .twig files. --- lib/loader.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index 98f581d..46a2984 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -48,13 +48,15 @@ module.exports = function (source) { Twig.extend(function (Twig) { var compiler = Twig.compiler; - // pass values to the compiler, and return the compiler function - compiler.module['webpack'] = compilerFactory({ + var compilerOptions = { loaderApi: loaderApi, resolve: resolve, resolveMap: resolveMap, path: path - }); + }; + Object.assign(compilerOptions, options); + // pass values to the compiler, and return the compiler function + compiler.module['webpack'] = compilerFactory(compilerOptions); }); tpl = Twig.twig({