Flipboard / react-canvas

High performance <canvas> rendering for React components
BSD 3-Clause "New" or "Revised" License
13.16k stars 923 forks source link

webpack2 #165

Open andylei18 opened 7 years ago

andylei18 commented 7 years ago

Module not found: Error: Can't resolve 'fs' in node_modules/linebreak/src' @ .//linebreak/src/linebreaker.js 7:7-20 @ .//react-canvas/lib/measureText.js @ ./~/react-canvas/lib/ReactCanvas.js

kaytrance commented 7 years ago

I am having the same error, hoping to get some answer

twoam commented 7 years ago

If you're not actually relying on the brfs/fs module I think you're safe to adjust the postLoader section specified at https://github.com/Flipboard/react-canvas#using-with-webpack to something like this:

module: {
  postLoaders: [
    {  
      include: __dirname + '/node_modules/linebreak', 
      loader: "transform?brfs" 
    }
  ]
}

This used to work for an older webpack 1.13 project... for which the brfs global npm install also was no longer needed.

fabiosantoscode commented 6 years ago

^ When using this with webpack 2, if it complains that you're using "import" and "export" then it's acorn and this hasn't been merged yet: https://github.com/substack/static-module/pull/32. In which case, check workaround inside.