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(esbuildDepPlugin): externalize built-in module during SSR #4904

Merged
merged 1 commit into from Sep 12, 2021

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Sep 11, 2021

fix #4700

Description

esbuildDepPlugin use path.resolve to resolve built-in module during SSR cause error, it should externalize built-in module during SSR

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.

@patak-dev
Copy link
Member

@ygj6 do you think it is possible to add a test case for this? @bluwy maybe you could also check this one?

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.

LGTM. One thing to note is that Vite already handles this in its resolve plugin:

// node built-ins.
// externalize if building for SSR, otherwise redirect to empty module
if (isBuiltin(id)) {
if (ssr) {

But using createResolver swallows the external info:

return (await container.resolveId(id, importer, undefined, ssr))?.id

So this makes the change necessary, unless we support the node: prefix in the future.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Ok, thanks for tge revies @bluwy. Lets merge this one, it would be good to issue a PR with a new test case also

@patak-dev patak-dev merged commit 5cc4587 into vitejs:main Sep 12, 2021
@ygj6
Copy link
Member Author

ygj6 commented Sep 13, 2021

Ok, thanks for tge revies @bluwy. Lets merge this one, it would be good to issue a PR with a new test case also

Great! Thanks for your reviews. I will do it.

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.

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