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: exclude missing dependencies from optimization during SSR #5017

Merged
merged 1 commit into from Sep 23, 2021

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Sep 22, 2021

Description

Optimized based on #4904 , fixed #4700 , and added test cases.

After I submitted the RP #4904 , I am going to add test cases according to the comment of @patak-js .

In the process of building test cases, I found a problem.

For testing, I did not add the script entry point in the index.html, it will be dynamically added during SSR.

First, if you import a missing dependency that contains multiple entries during SSR, it will execute server._registerMissingImport and build a server-based output.

Then, when the client imports the same missing dependency that contains multiple entries, it will directly consume the build result of the SSR stage. The build result is only applicable to the server, and importing on the client will cause an error.

In my opinion, there is no need to execute server._registerMissingImport during the SSR, because the build result is based on the server, and the optimized dependencies are for the client.

If there is anything missing, please remind me.

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.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • 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).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

This may also fix #4968

@antfu antfu merged commit 2204afa into vitejs:main Sep 23, 2021
@ygj6 ygj6 deleted the issue-4700-test branch September 23, 2021 06:27
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
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.

ssr: Nested built-in dependencies of ESM dependencies can't be resolved
6 participants