othiym23 / node-deeper

slightly better structural equality testing
BSD 2-Clause "Simplified" License
24 stars 6 forks source link

Cannot resolve module 'buffertools' #3

Open yapro opened 8 years ago

yapro commented 8 years ago
$ webpack
Hash: fa21190dc85f7f306103
Version: webpack 1.12.14
Time: 4517ms
                   Asset    Size  Chunks             Chunk Names
personalDataComponent.js  890 kB       0  [emitted]  personalDataComponent
    + 194 hidden modules

WARNING in /var/www/promo/~/react-jsonschema-form/~/deeper/index.js
Module not found: Error: Cannot resolve module 'buffertools' in /var/www/promo/node_modules/react-jsonschema-form/node_modules/deeper
 @ /var/www/promo/~/react-jsonschema-form/~/deeper/index.js 14:21-43
matias-sandell commented 8 years ago

Probably due to the fact that the module tries to require buffertools but fails?

try {
  deeper.fastEqual = require('buffertools').equals
} catch (e) {
  // whoops, nobody told buffertools it wasn't installed
}
n1k0 commented 8 years ago

Most definitely an issue for people using bundlers like browserify or webpack, aka ~95% of the frontend developers community :)

Shooting in the dark here, but I wonder if something like global["require"]("buffertools") or similar hack would prevent bundlers to parse the statement at compilation time? (yeah, that's ugly anyway)

Maybe a cleaner way would be to expose two different entry points, one expecting buffertools to be available and the other not, so you could import either deeper or deeper/no-buffertools.