Conversation
…al content loader The virtual content loader hardcoded a node_modules/ path for @openzeppelin/ui-styles/global.css, which only works when pnpm uses shamefully-hoist (hoisted node-linker). In Docker builds where .npmrc is excluded, pnpm defaults to isolated mode and the package is not hoisted to the root node_modules, causing the CSS theme to silently resolve as empty. Use createRequire from the builder package directory to resolve npm: prefixed entries via Node's module resolution algorithm, which correctly follows pnpm symlinks in any hoisting strategy.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where the global.css file was empty in staging exports when using pnpm's isolated node-linker strategy. The fix introduces an npm: prefix convention in the virtual content loader plugin that uses Node's module resolution via createRequire(), which correctly handles pnpm symlinks regardless of hoisting strategy.
Changes:
- Introduced
npm:prefix convention for npm package resolution in virtual files map - Added
createRequire()from Node's module system to resolve npm packages from the builder directory - Updated
global-css-contententry to usenpm:@openzeppelin/ui-styles/global.cssinstead of hardcodednode_modules/path
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The .replace(/\\/g, '\\') call was a no-op (replacing backslash with itself). Fix to .replace(/\\/g, '\\\\') so backslashes in CSS content are properly escaped when embedded in template literals. Flagged by CodeQL.
78c9b3a to
51b3815
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
global.cssin staging exports caused by the virtual content loader's hardcodednode_modules/path failing under pnpm's isolated node-linker.npmrc(which containsshamefully-hoist=true) is excluded from Docker builds via.dockerignore. Without it, pnpm defaults toisolatedmode where@openzeppelin/ui-stylesis only available inapps/builder/node_modules/, not at the monorepo root — causing the virtual content loader to silently fall back to an empty string.npmrcto Docker (which could leak future auth tokens), introduce annpm:prefix convention in thevirtualFilesmap that triggerscreateRequire()resolution from the builder package directory, which correctly follows pnpm symlinks in any hoisting strategyBefore
After
Test plan
src/styles/global.csspnpm buildon the exported app and verifybg-backgroundresolvespnpm buildof the builder app still embeds CSS correctly