Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): apply alias to resolvable dependencies during dev #15602

Merged

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Jan 15, 2024

Description

I found this dev/build inconsistency while investigating the issue #15503 (comment), but the issue itself seems to be more complicated and currently it's waiting for proper reproduction. (EDIT: I think this is the only vite side issue, so we can close it if this PR is merged.)

Given that there is a big warning in https://vitejs.dev/guide/ssr.html#ssr-externals, I suppose relying on resolve.alias might not be recommended in general. However, considering this is one source of dev/build inconsistency for non-external modules, so I thought this is worth making it consistent. Please let me know if this fix is appropriate here.

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.

Copy link

stackblitz bot commented Jan 15, 2024

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

@hi-ogawa hi-ogawa marked this pull request as ready for review January 15, 2024 01:30
@hi-ogawa hi-ogawa changed the title fix(ssr): apply alias to resolvable modules during dev fix(ssr): apply alias to resolvable dependencies during dev Jan 15, 2024
Comment on lines +4 to +11
test.runIf(isServe)('dev', async () => {
const mod = await viteServer.ssrLoadModule('/src/main.js')
expect(mod.default).toEqual({
dep: 'ok',
nonDep: 'ok',
builtin: 'ok',
})
})
Copy link
Collaborator Author

@hi-ogawa hi-ogawa Jan 16, 2024

Choose a reason for hiding this comment

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

Previous behavior was that:

  {
    dep: 'original',
    nonDep: 'ok',
    builtin: undefined,
  }

which is inconsistent with build mode.

@patak-dev patak-dev added this to the 5.2 milestone Feb 12, 2024
@bluwy bluwy merged commit 8e54af6 into vitejs:main Mar 12, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ssrLoadModule fails to respect preact/compat aliases, while the SSR bundle does respect preact/compat aliases
3 participants