From 3efa28c9f1d392fc57fe2ee4b9c3aed264eb8c80 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 23 Aug 2020 15:20:29 +0200 Subject: [PATCH] Don't break when options._flags is undefined entirely --- src/phase-streams/dedupe-bundle-css.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/phase-streams/dedupe-bundle-css.js b/src/phase-streams/dedupe-bundle-css.js index 179e47d..c99929a 100644 --- a/src/phase-streams/dedupe-bundle-css.js +++ b/src/phase-streams/dedupe-bundle-css.js @@ -18,7 +18,7 @@ module.exports = function (state) { let allCss = ""; let loaderItem; - let entryPoint = (options._flags.entries != null) + let entryPoint = (options._flags != null && options._flags.entries != null) // Get the (absolute!) path of the folder containing the initial entry file, as a reference point for relative paths in the output ? path.dirname(path.resolve(options._flags.entries[0])) // ... or, if no entry file is specified, go off the current working directory @@ -27,13 +27,13 @@ module.exports = function (state) { return stream((item) => { // And the same for the loader shim path. All this relative-path stuff is to prevent absolute filesystem URLs from leaking into the output, as those might contain sensitive information. let relativeLoaderPath = path.relative(path.dirname(item.file), loaderShimPath); - + if (isCss(item)) { return Promise.try(() => { return processFile(item); }).then(({ result, icssExports }) => { allCss += `/* from ${path.relative(entryPoint, item.file)} */\n\n${result.css}\n\n`; - + if (!item.__icssify__discardable) { return { ... item, @@ -56,6 +56,7 @@ module.exports = function (state) { source: loaderItem.source.replace('"## CONTENT MARKER ##"', JSON.stringify(allCss)) }; } else { + // FIXME: Can occur if some dependency also gets processed and require()s a CSS file, but does not specify icssify as a transform (but the using project does) -- like with ui-lib + site-builder throw new Error("Processed CSS, but global loader was not encountered. This should never happen, please report it as a bug!"); } }