mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
26.14k stars 1.85k forks source link

Tree shaking not working for tiptap package #3118

Closed OrkhanAlikhanov closed 1 year ago

OrkhanAlikhanov commented 1 year ago

What package has an issue

@mantine/tiptap

Describe the bug

Tree shaking not working for @mantine/tiptap package. Looks like "sideEffects": false is missing from mantine-tiptap/package.json. Is this intentional?

What version of @mantine/hooks page do you have in package.json?

N/A

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

No response

OrkhanAlikhanov commented 1 year ago

It seems @tiptap/core is not treeshaking well enough too

OrkhanAlikhanov commented 1 year ago

tiptap is doing global function calls to create extensions.

Due to that those calls, those extensions/marks/nodes are not tree shaken. They can be marked as tree shakeable if the calls have /*#__PURE__*/ preceding comment. Check out this repl, MyExtension3 is not tree shaken.

If they had a simple function calls it would be tree shaken as the pattern mantine follows

rtivital commented 1 year ago

Fixed in 5.9.4, sideEffects: false was added to the @mantine/tiptap package, cannot fix issue in Tiptap on my side, feel free to report an issue in tiptap repo