How do I exclude the “require('react')” from my Browserified bundle?

前端 未结 4 1314
失恋的感觉
失恋的感觉 2020-12-14 09:11

I\'m using Browserify to bundle a ReactJS application.

All my components include a require(\"react\") at the top. This causes

4条回答
  •  既然无缘
    2020-12-14 09:52

    I also wanted to do this, and found a possible solution.

    From the browserify -h help:

    --ignore, -i Replace a file with an empty stub. Files can be globs.

    Just use the ignore feature.

    browserify -i react -i react-dom ...
    

    I also added react and react-dom as peer dependencies, cause in my case, the package can be imported in other packages builds.

提交回复
热议问题