Skip to content

fix(ssr): check esm file with normal file path#15307

Merged
patak-cat merged 1 commit intomainfrom
fix-imported-mod-ssr
Dec 11, 2023
Merged

fix(ssr): check esm file with normal file path#15307
patak-cat merged 1 commit intomainfrom
fix-imported-mod-ssr

Conversation

@bluwy
Copy link
Copy Markdown
Member

@bluwy bluwy commented Dec 11, 2023

Description

fix withastro/astro#9388

The filePath passed here:

function analyzeImportedModDifference(
mod: any,
filePath: string,
rawId: string,
metadata?: SSRImportMetadata,
packageCache?: PackageCache,
) {
// No normalization needed if the user already dynamic imports this module
if (metadata?.isDynamicImport) return
// If file path is ESM, everything should be fine
if (isFilePathESM(filePath, packageCache)) return

Is actually something like file:/Users/bjorn/... which would fail when we check the closest package.json, as findNearestPackageData only deals with normal absolute file path. This PR fixes by passing it that absolute file path instead.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) feat: ssr labels Dec 11, 2023
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-cat
Copy link
Copy Markdown
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link
Copy Markdown

📝 Ran ecosystem CI on c9784d7: Open

suite result latest scheduled
analogjs success success
astro success success
histoire success success
ladle success success
laravel failure failure
marko success success
nuxt failure failure
nx success success
previewjs success success
qwik success success
rakkas success success
sveltekit success success
unocss success success
vike success success
vite-plugin-pwa success success
vite-plugin-react success success
vite-plugin-react-pages success success
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success success
vite-setup-catalogue success success
vitepress success success
vitest success success

@patak-cat patak-cat enabled auto-merge (squash) December 11, 2023 09:19
@patak-cat patak-cat merged commit 1597170 into main Dec 11, 2023
@patak-cat patak-cat deleted the fix-imported-mod-ssr branch December 11, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lodash import issue in v4

2 participants