TechStark / opencv-js

OpenCV JavaScript version for node.js or browser
https://npmjs.com/@techstark/opencv-js
Apache License 2.0
439 stars 38 forks source link

ES Module (ESM) import compatibility #44

Open AronRubin opened 1 year ago

AronRubin commented 1 year ago

I need this patch script in my package.json to have opencv-js work with import in the browser (testing on Edge).

  "scripts": {
    ...
    "fix-opencv-import": "replace \"if[(]typeof window==='object'[)][{]root.cv=factory[(][)];[}]\" \"if(typeof window==='object'){window.cv=factory();}\" node_modules/@techstark/opencv-js/dist/opencv.js",
    ...
  },

Thank you

gameveloster commented 3 months ago

@AronRubin What error do you get if you did not apply this patch?