theothergrantdavidson / opencv-ts

A place for the typescript bindings for OpencvJS
Apache License 2.0
52 stars 19 forks source link

Bundling Error using Webpack #1

Closed bemayr closed 3 years ago

bemayr commented 3 years ago

First of all, thanks for this great project! 👏


When trying to include this project into a preact-cli based PWA, I got the following error:

Build failed!

× ERROR ../node_modules/opencv-ts/src/opencv.js
Module not found: Error: Can't resolve 'fs' in '.\node_modules\opencv-ts\src'
 @ ../node_modules/opencv-ts/src/opencv.js 8:1395-1408 8:8592374-8592387     
 @ ../node_modules/babel-loader/lib??ref--4!./routes/home/index.tsx
 @ ./routes/home/index.tsx
 @ ./components/app.tsx
 @ ./index.ts
 @ ../node_modules/preact-cli/lib/lib/entry.js

After a bit of searching for this error I stumbled upon https://github.com/tensorflow/tfjs/issues/1274, with a proposed fix of adding

"browser": {
    "fs": false
}

to package.json. I tested it and it works, I am gonna open a PR in a minute. 👌

theothergrantdavidson commented 3 years ago

I hadn't tried bundling it with webpack yet so thanks for fixing that up in the PR :)

bemayr commented 3 years ago

No problem at all, thanks for the really fast merging and publishing!! 🙏