Tree shaking in NextJS includes all of node_modules package even if not using it all Tree shaking in NextJS includes all of node_modules package even if not using it all reactjs reactjs

Tree shaking in NextJS includes all of node_modules package even if not using it all


In order for the tree-shaking to work properly react-color should add module property to the package.json which will point to esm version of the lib.

Since it doesn't have it, you will need import directly.

Before:

import React from 'react'import SketchPicker  from 'react-color'class Component extends React.Component {  render() {    return <SketchPicker />  }}

enter image description here

After:

import React from 'react'import SketchPicker  from 'react-color/lib/Sketch'class Component extends React.Component {  render() {    return <SketchPicker />  }}

enter image description here