When webpack is packaged, do not package dependencies

as the title

developed a npm package based on react, but because there is

in the code

import React from "react";

so react is also packaged when it is packaged, resulting in a very large package size

now, when you want to pack a package, you don"t want to call in the dependency of react. Do you have any solutions?

Mar.30,2021

do you use webpack to pack?

try external?

module.exports = {
  //...
  externals: {
    React: 'react'
  }
};
For more information on the usage of

, please see idebar/Sidebar.jsx" rel=" nofollow noreferrer "> https://webpack.js.org/config.

.

extract the general module of course

Menu