You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR csstools/postcss-normalize#65 fixes an issue with postcss-normalize that breaks webpack dev/build on Windows currently.
That package is using broken and unsupported internal node functions to resolve folders on Windows.
I tested the patch, and that's working fine:
diff --git a/node_modules/postcss-normalize/index.mjs b/node_modules/postcss-normalize/index.mjs
index 03594d3..7c2f333 100644
--- a/node_modules/postcss-normalize/index.mjs
+++ b/node_modules/postcss-normalize/index.mjs
@@ -1,5 +1,5 @@
import postcssBrowserComments from 'postcss-browser-comments';
-import Module from 'module';
+import { createRequire} from 'node:module'
import path from 'path';
import { URL } from 'url';
import fs from 'fs';
@@ -8,9 +8,8 @@ import postcss from 'postcss';
const assign = (...objects) => Object.assign(...objects);
const create = (...objects) => assign(Object.create(null), ...objects);
-const currentURL = import.meta.url;
-const currentFilename = new URL(currentURL).pathname;
-const currentDirname = path.dirname(currentFilename); // get resolved filenames for normalize.css
+// create package path resolver in an esm-compatible fashion
+const {resolve: requireResolve} = createRequire(import.meta.url)
const normalizeCSS = resolve('@csstools/normalize.css');
const normalizeDir = path.dirname(normalizeCSS);
@@ -54,11 +53,7 @@ const resolvedFilenamesById = create({
}); // get the resolved filename of a package/module
function resolve(id) {
- return resolve[id] = resolve[id] || Module._resolveFilename(id, {
- id: currentFilename,
- filename: currentFilename,
- paths: Module._nodeModulePaths(currentDirname)
- });
+ return resolve[id] = resolve[id] || requireResolve(id)
}
const cache$1 = create();
If you place the above file as postcss-normalize+10.0.1.patch in the project's patches folder, and run npx patch-package, it will apply the fix for you.
I'd would like to have created a PR for this, but i'm not sure how this would work for script packages. As currently patches only exist in templates, and some templates are compatible with multiple script packages, there is no obvious place to do this.
Maybe we should create a new ticket to add support for scripts-patches.
The text was updated successfully, but these errors were encountered:
This PR csstools/postcss-normalize#65 fixes an issue with postcss-normalize that breaks webpack dev/build on Windows currently.
That package is using broken and unsupported internal node functions to resolve folders on Windows.
I tested the patch, and that's working fine:
If you place the above file as
postcss-normalize+10.0.1.patch
in the project'spatches
folder, and runnpx patch-package
, it will apply the fix for you.I'd would like to have created a PR for this, but i'm not sure how this would work for
script
packages. As currently patches only exist in templates, and some templates are compatible with multiple script packages, there is no obvious place to do this.Maybe we should create a new ticket to add support for scripts-patches.
The text was updated successfully, but these errors were encountered: