Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly ignore optional dependencies when bundling vite deps
Fixes vitejs#3977 Fixes vitejs#3850 😅 I've accidentally committed the actual fix in vitejs@25d86eb#diff-d17472499351c5bf75d44c67aaa203337dcce321fb578ff05302c61b2b2a3a8aR172 So this PR just removes the erroneous `ingoreDepPlugin`, and moves the 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, the `require` expression is turned into: ```js var bufferutil = { __proto__: null }; var require$$1 = /*@__PURE__*/getAugmentedNamespace(bufferutil); // ... const bufferUtil = require$$1; ``` No error is throwed, so the code executes into the wrong branch. After the fix, the `require` expression is left as-is. As `bufferutil` is not installed in the user project, the error is thrown as expected.
- Loading branch information