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

refactor(resolve): remove commonjs plugin handling #9460

Merged
merged 2 commits into from
Aug 9, 2022
Merged

refactor(resolve): remove commonjs plugin handling #9460

merged 2 commits into from
Aug 9, 2022

Conversation

sagargurtu
Copy link
Contributor

@sagargurtu sagargurtu commented Jul 31, 2022

Description

This PR fixes the commonjs HELPERS_ID (reference link) in resolve plugin.

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.

@sapphi-red
Copy link
Member

sapphi-red commented Jul 31, 2022

In fact, after #8743, this condition was never met because commonjs plugin is always the first one.
https://github.com/rollup/plugins/blob/add3a350e99505e15790b4915c33b1fcc5bf00ec/packages/commonjs/src/index.js#L186-L199

Maybe we could simply remove this condition?

@sagargurtu
Copy link
Contributor Author

I'm not sure. I don't have much knowledge of the codebase but could a custom plugin change the ordering of internal plugins by implementing the options hook? If yes, then, you might still need to keep this condition. Or do you not care about what custom plugins do?

@bluwy
Copy link
Member

bluwy commented Aug 6, 2022

Interesting find @sapphi-red. I'd also prefer if we remove this condition instead since it won't be called. I don't think there will be a custom plugin that would sort Vite's resolve plugin to first, that would break many things.

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.

@bluwy @sapphi-red this looks safe to me for a patch, would you approve if you think the same? Also, interesting to see rollup injecting plugins in options in this way.

@sapphi-red
Copy link
Member

sapphi-red commented Aug 9, 2022

FYI This reordering behavior was introduced in plugin-commonjs v22.0.0. The reason is described here.

@bluwy bluwy changed the title fix(resolve): fix commonjs plugin 'HELPERS_ID' refactor(resolve): remove commonjs plugin handling Aug 9, 2022
@bluwy bluwy merged commit 2042b91 into vitejs:main Aug 9, 2022
@sagargurtu sagargurtu deleted the fix/resolve branch August 10, 2022 17:50
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.

4 participants