Skip to content

fix: url resolution in windows - #3337

Merged
ommeirelles merged 4 commits into
devfrom
fix/windows
May 21, 2026
Merged

ommeirelles merged 4 commits into
devfrom
fix/windows

Conversation

@ommeirelles

@ommeirelles ommeirelles commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Added a fix to @faststore/cli where imports was throwing in windows OS beacuse a unhandled C:/ esm path load

Summary by CodeRabbit

  • Refactor
    • Improved how the CLI loads user/project configs, plugins, and discovery files by standardizing module URLs.
    • Leads to more reliable CLI commands (build, dev, start, cache, cms-sync, i18n, test, plugin and generation flows) with fewer runtime import/load issues when reading project configs and plugins.

Review Change Stack

@ommeirelles
ommeirelles requested a review from a team as a code owner May 20, 2026 01:27
@ommeirelles
ommeirelles requested review from gabpaladino and lucasfp13 and removed request for a team May 20, 2026 01:27
@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b234454-42ba-44c4-809f-d84190ac9a87

📥 Commits

Reviewing files that changed from the base of the PR and between ce5155a and 03620d0.

⛔ Files ignored due to path filters (2)
  • biome.json is excluded by none and included by none
  • scripts/set-resolution.js is excluded by none and included by none
📒 Files selected for processing (20)
  • packages/cli/src/commands/build.ts
  • packages/cli/src/commands/cache-graphql.ts
  • packages/cli/src/commands/cms-sync.ts
  • packages/cli/src/commands/dev.ts
  • packages/cli/src/commands/start.ts
  • packages/cli/src/commands/test.ts
  • packages/cli/src/utils/config.ts
  • packages/cli/src/utils/createNextjsPages.ts
  • packages/cli/src/utils/deprecations.ts
  • packages/cli/src/utils/directory.test.ts
  • packages/cli/src/utils/file.ts
  • packages/cli/src/utils/generate.ts
  • packages/cli/src/utils/hcms.test.ts
  • packages/cli/src/utils/hcms.ts
  • packages/cli/src/utils/plugins.ts
  • packages/cli/src/utils/runCommandSync.ts
  • packages/core/next.config.js
  • packages/core/src/server/index.ts
  • packages/core/src/utils/myAccountRedirect.tsx
  • packages/storybook/.storybook/main.ts
✅ Files skipped from review due to trivial changes (13)
  • packages/core/next.config.js
  • packages/storybook/.storybook/main.ts
  • packages/cli/src/utils/file.ts
  • packages/cli/src/commands/test.ts
  • packages/cli/src/utils/deprecations.ts
  • packages/cli/src/utils/createNextjsPages.ts
  • packages/cli/src/commands/start.ts
  • packages/cli/src/utils/directory.test.ts
  • packages/core/src/utils/myAccountRedirect.tsx
  • packages/core/src/server/index.ts
  • packages/cli/src/utils/hcms.test.ts
  • packages/cli/src/utils/runCommandSync.ts
  • packages/cli/src/utils/hcms.ts

Walkthrough

Standardizes dynamic imports across the CLI by converting filesystem path arguments to file:// URLs using Node's pathToFileURL(...).href and updates Node built-in imports to node: specifiers.

Changes

Dynamic Import Path-to-URL Conversion

Layer / File(s) Summary
Command-layer import conversions
packages/cli/src/commands/cache-graphql.ts, packages/cli/src/commands/cms-sync.ts, packages/cli/src/commands/generate-i18n.ts
Add pathToFileURL imports and switch dynamic import() calls for persisted documents, user store config, and discovery config to use pathToFileURL(...).href.
Utility and core command specifier updates
packages/cli/src/utils/commands.ts, packages/cli/src/utils/config.ts, packages/cli/src/commands/build.ts, packages/cli/src/commands/dev.ts, packages/cli/src/commands/start.ts, packages/cli/src/commands/test.ts
Add/adapt pathToFileURL/fileURLToPath where needed, convert single dynamic imports (package.json, discovery.config) to file URLs, and migrate Node built-ins to node: specifiers.
Generate utility multi-point conversions
packages/cli/src/utils/generate.ts
Convert multiple dynamic imports to file:// URLs: Cypress support paths, CMS webhook config, theme config, core/root package.json JSON imports, missing-dependency checks, and enableSearchSSR.
CMS and plugin utility conversions
packages/cli/src/utils/hcms.ts, packages/cli/src/utils/plugins.ts
Add pathToFileURL and convert dynamic imports for user store config, temporary stored plugins config, and each plugin's plugin.config.js to file URLs.
Misc Node specifier & test updates
packages/cli/src/utils/*.ts, packages/core/*, packages/storybook/.storybook/*, tests/*
Multiple files updated to use node:-prefixed built-ins (node:fs, node:path, node:child_process, node:url, etc.) and test imports reordered; no behavioral changes.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • lucasfp13
  • lariciamota

Poem

file:// paths now glide on rails,
Node's tidy imports tell the tales,
Dynamic loads resolve with grace,
Clean specifiers in their place,
The CLI hums in steadier trails.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: url resolution in windows' directly relates to the core change across the codebase: converting filesystem paths to file:// URLs using pathToFileURL for proper ESM import handling on Windows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci

codesandbox-ci Bot commented May 20, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/utils/generate.ts`:
- Around line 182-186: The dynamic import assignment blocks (assigning
userStoreConfig using pathToFileURL and path.resolve) need Biome-style
formatting: update the affected expressions (the userStoreConfig assignments in
generate.ts where pathToFileURL, path.resolve, and existsSync are used, and any
similar blocks at the other referenced locations) to follow project style—use
single quotes, remove semicolons, enforce 2-space indentation, and ensure ES5
trailing commas—then run Biome to reformat and commit the changes so CI
formatting checks pass.

In `@packages/cli/src/utils/plugins.ts`:
- Around line 172-173: Reformat the dynamic import expressions that load plugin
configs (e.g., the const { default: pluginConfig } = await
import(pathToFileURL(pluginConfigPath).href) occurrence and the other dynamic
imports later in the file) to conform to Biome style: use 2-space indentation,
single quotes for string literals, no semicolons, and include ES5-style trailing
commas where applicable; adjust whitespace/line breaks so the await import(...)
calls and their surrounding destructuring follow the project code-style rules
used elsewhere in packages/cli/src/utils/plugins.ts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f17aec4-16b8-403a-a5a3-959e7f5fd885

📥 Commits

Reviewing files that changed from the base of the PR and between 7d37922 and bba0ce8.

📒 Files selected for processing (8)
  • packages/cli/src/commands/cache-graphql.ts
  • packages/cli/src/commands/cms-sync.ts
  • packages/cli/src/commands/generate-i18n.ts
  • packages/cli/src/utils/commands.ts
  • packages/cli/src/utils/config.ts
  • packages/cli/src/utils/generate.ts
  • packages/cli/src/utils/hcms.ts
  • packages/cli/src/utils/plugins.ts

Comment thread packages/cli/src/utils/generate.ts Resolved
Comment thread packages/cli/src/utils/plugins.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented May 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@faststore/api

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/cli

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/components

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/core

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/diagnostics

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/lighthouse

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/sdk

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/ui

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

commit: 03620d0

@sonar-workflows

Copy link
Copy Markdown

Failed Quality Gate failed

  • 0.00% Coverage on New Code (is less than 80.00%)

Project ID: vtex_faststore_f0a862d5-9557-49f9-8d09-de40caa76622

View in SonarQube

@ommeirelles
ommeirelles merged commit 2476091 into dev May 21, 2026
9 of 10 checks passed
@ommeirelles
ommeirelles deleted the fix/windows branch May 21, 2026 18:06
hellofanny added a commit that referenced this pull request Sep 10, 2026
Unit tests alone did not cover the CLI paths where the Windows bugs
shipped to partners (#3337, #3419, #3440) actually fail. Pack the
workspace and build starter.store on windows-latest, which is where the
CLI is really invoked.

Yarn 1 resolutions get a relative POSIX tarball path: an absolute
Windows path is parsed as a protocol because of the drive letter. The
pack loop checks LASTEXITCODE by hand, since GitHub only propagates the
exit code of the last command in a block.

Co-authored-by: Cursor <[email protected]>
lokinmodar pushed a commit to lokinmodar/faststore that referenced this pull request Nov 20, 2026
Every path-handling bug we shipped to partners (vtex#3337, vtex#3419, vtex#3440) was
found on Windows, in production, because nothing in the pipeline has ever
run there. This job is informational while we measure how the suite behaves
on a real runner, so it cannot block merges yet.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants