fix: correctly ignore optional deps when bundling vite deps #4223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3977
Fixes #3850
😅 I've accidentally committed the actual fix in 25d86eb#diff-d17472499351c5bf75d44c67aaa203337dcce321fb578ff05302c61b2b2a3a8aR172
So this PR just removes the erroneous
ingoreDepPlugin
, and movesthe comments to the
ignore
option of the commonjs plugin.The cause of the issues is this line: https://github.com/websockets/ws/blob/4c1849a61e773fe0ce016f6eb59bc3877f09aeee/lib/buffer-util.js#L105
When we ignore the optional deps when bundling, we expect
require('bufferutil')
to throw an error.However, with the previous
ignoreDepPlugin
implementation, therequire
expression is turned into:No error is thrown, so the code executes into the wrong branch.
After the fix, the
require
expression is left as-is. Asbufferutil
is not installed in the user project, the error is thrown as expected.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).