Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/fix-browserslist-pnpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@asyncapi/generator": patch
---

Fix browserslist error when using pnpm

Set BROWSERSLIST_ROOT_PATH environment variable during template compilation
to prevent browserslist from searching outside the template directory. This
fixes an issue where pnpm's shim files were incorrectly parsed as browserslist
configuration, causing "Unknown browser query" errors.

Fixes: https://github.com/asyncapi/cli/issues/1781
17 changes: 16 additions & 1 deletion apps/generator/lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,22 @@ class Generator {
*/
async configureTemplate() {
if (this.compile) {
await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
// Set BROWSERSLIST_ROOT_PATH to prevent browserslist from searching
// outside the template directory. This fixes issues with pnpm where
// browserslist would incorrectly parse pnpm shim files as config.
// See: https://github.com/asyncapi/cli/issues/1781
const previousRootPath = process.env.BROWSERSLIST_ROOT_PATH;
process.env.BROWSERSLIST_ROOT_PATH = this.templateDir;
try {
await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
} finally {
// Restore previous value if it existed
if (previousRootPath === undefined) {
delete process.env.BROWSERSLIST_ROOT_PATH;
} else {
process.env.BROWSERSLIST_ROOT_PATH = previousRootPath;
}
}
}
}

Expand Down
Loading