Skip to content

fix(vite): cross-package bare imports also fail for workspace-member modules (#156) - #157

Merged
antosubash merged 10 commits into
mainfrom
githubissues
May 18, 2026
Merged

fix(vite): cross-package bare imports also fail for workspace-member modules (#156)#157
antosubash merged 10 commits into
mainfrom
githubissues

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

Closes #156. The moduleBareImportResolver Vite plugin added in #154 short-circuits when the importer path sits under fsRoot/projectRoot, which was meant to skip host-internal files but ends up skipping workspace-member module pages too.

In an npm-workspaces scaffold (workspaces: ["host/client_app", "modules/*"]) deps hoist to the workspace root, so fsRoot resolves to the workspace root — and workspace-member modules at modules/<name>/<pkg>/pages/ sit under it. The early-return excluded the very modules that need workspace-root re-resolution, so bare imports like maplibre-gl / pmtiles failed with "could not be resolved" during dev resolveId.

The fix drops the fsRoot/projectRoot containment check; the modulePagesPrefixes guard already pins the plugin to module-page importers regardless of whether they live inside or outside the workspace tree. Applied to both the scaffold template (Vite 6) and the framework's host config (Vite 8).

The dep-scanner path is already covered by the workspace-node_modules NODE_PATH-style fallback seeded via optimizeDeps.esbuildOptions.nodePaths (scaffold template) / optimizeDeps.rolldownOptions.resolve.modules (host) from #152.

Test plan

  • New content-level regression test asserts the startsWith(fsRootPrefix) early-return doesn't reappear (test_scaffold_vite_resolver_does_not_skip_workspace_modules).
  • Watched test fail first (RED), applied fix, watched it pass (GREEN).
  • uv run pytest framework/cli/tests/ framework/hosting/tests/ — 217 passed.
  • make lint clean (preexisting biome warning unrelated to this change).

…ross-package bare imports from module pages (#152)
…modules (#156)

The moduleBareImportResolver plugin added in #154 short-circuits when the
importer path sits under fsRoot/projectRoot, which was meant to skip
host-internal files but ends up skipping workspace-member module pages
too. In an npm-workspaces scaffold (`workspaces: ["host/client_app",
"modules/*"]`) deps hoist to the workspace root, so fsRoot resolves to
the workspace root — and workspace-member modules at `modules/<name>/...`
sit *under* it. The early-return excluded the very modules that need
workspace-root re-resolution, so bare imports like `maplibre-gl` /
`pmtiles` failed with "could not be resolved" during dev resolveId.

Drop the fsRoot/projectRoot containment check; the `modulePagesPrefixes`
guard already pins the plugin to module-page importers regardless of
whether they live inside or outside the workspace tree. Apply the fix to
both the scaffold template (Vite 6) and the framework's host config
(Vite 8). Add a content-level regression test ensuring the bad early-
return doesn't reappear.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 18, 2026

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: ce0322e
Status: ✅  Deploy successful!
Preview URL: https://352b6095.simple-module-python.pages.dev
Branch Preview URL: https://githubissues.simple-module-python.pages.dev

View logs

# Conflicts:
#	CHANGELOG.md
#	framework/cli/tests/test_scaffolding_host.py
@antosubash
antosubash merged commit c42d615 into main May 18, 2026
12 checks passed
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.

v0.0.13 cross-package fix doesn't cover workspace-member modules + dep-scan still errors

1 participant