Tree shaking is not performed on `RegExp` in Webpack
mxdvl opened this issue · comments
The regular expressions from regex.ts
are not dropped by tree-shaking in Webpack.
Sample built file, with its associated source
You are right. But that's a problem with the webpack configuration and not with Valibot, right?
There's nothing readily apparent, but I wondered if the lack of pure annotations prevented tree-shaking of literal regular expressions.
Let me do a reproduction repository with popular bundlers.
I was able to reproduce the lack of tree-shaking with Webpack & ts-loader
can be seen in dist/typescript.js
. It’s worth nothing that when the entry files are JavaScript, tree shaking is performed adequately in dist/javascript.js
.
If you believe this is an issue best flagged with Webpack or ts-loader
, happy to do that instead.
Thank you for your research! Yes, it seems that there is nothing Valibot can do and the problem is related to ts-loader
or Webpack.