From b71af3917bd5e3de22103fb948520cdb82c2bdcc Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Tue, 8 Oct 2024 08:42:43 -0400 Subject: [PATCH] better path detection handling --- packages/plugin-css-modules/src/index.js | 12 +++++------- .../test/cases/build.default/build.default.spec.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/plugin-css-modules/src/index.js b/packages/plugin-css-modules/src/index.js index b32e03ae5..c92482cd5 100644 --- a/packages/plugin-css-modules/src/index.js +++ b/packages/plugin-css-modules/src/index.js @@ -16,8 +16,8 @@ function getCssModulesMap(compilation) { const locationUrl = new URL('./__css-modules-map.json', compilation.context.scratchDir); let cssModulesMap = {}; - if (fs.existsSync(locationUrl.pathname)) { - cssModulesMap = JSON.parse(fs.readFileSync(locationUrl.pathname)); + if (fs.existsSync(locationUrl)) { + cssModulesMap = JSON.parse(fs.readFileSync(locationUrl)); } return cssModulesMap; @@ -147,12 +147,10 @@ class CssModulesResource extends ResourceInterface { this.extensions = ['module.css']; this.contentType = 'text/javascript'; - // // console.log('constructor???') - if (!fs.existsSync(this.compilation.context.scratchDir.pathname)) { - // // console.log('!!!!!!!!! make it!'); - fs.mkdirSync(this.compilation.context.scratchDir.pathname, { recursive: true }); + if (!fs.existsSync(this.compilation.context.scratchDir)) { + fs.mkdirSync(this.compilation.context.scratchDir, { recursive: true }); fs.writeFileSync( - new URL('./__css-modules-map.json', this.compilation.context.scratchDir).pathname, + new URL('./__css-modules-map.json', this.compilation.context.scratchDir), JSON.stringify({}) ); } diff --git a/packages/plugin-css-modules/test/cases/build.default/build.default.spec.js b/packages/plugin-css-modules/test/cases/build.default/build.default.spec.js index 75a04a751..3c8e08800 100644 --- a/packages/plugin-css-modules/test/cases/build.default/build.default.spec.js +++ b/packages/plugin-css-modules/test/cases/build.default/build.default.spec.js @@ -40,7 +40,7 @@ import { implementation } from 'jsdom/lib/jsdom/living/nodes/HTMLStyleElement-im const expect = chai.expect; describe('Build Greenwood With: ', function() { - const LABEL = 'Default Configuration for CSS Modules with pre-rendering'; + const LABEL = 'Default Configuration for CSS Modules'; const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js'); const outputPath = fileURLToPath(new URL('.', import.meta.url)); let runner;