xaviergonz / js-angusj-clipper

Polygon and line clipping and offsetting library (Javascript) - a port of Angus Johnson's clipper
MIT License
162 stars 19 forks source link

Import into Angular #13

Closed danielfrunza closed 2 years ago

danielfrunza commented 4 years ago

"ReferenceError: process is not defined" when try to "loadNativeClipperLibInstanceAsync" at:

var devMode = typeof "process" !== "undefined" && process.env && process.env.NODE_ENV !== "production"; in (clipFunctions.js:7)

xaviergonz commented 4 years ago

Try import * as clipperLib from "js-angusj-clipper/dist/web"

See https://github.com/xaviergonz/js-angusj-clipper/issues/2

anlumo commented 3 years ago

I think the reason for this issue is that typeof "process" is a string, which is never undefined. Some JS preprocessors catch this and just remove the check.

The web version also contains this line and thus importing it doesn't fix it.

blayzen-w commented 3 years ago

I ran into this same issue using webpack with the web version and had to manually define process on the window/self in order to get it to work. I'm also using the exact same import as @xaviergonz mentioned. It would be nice to see this fixed.

I can provide a small example project demonstrating the problem if needed.

xaviergonz commented 3 years ago

I can provide a small example project demonstrating the problem if needed.

that would be really helpful

blayzen-w commented 3 years ago

https://github.com/blayzen-w/clipper-process-undefined

Let me know if I'm missing anything in there

xaviergonz commented 2 years ago

I just tested and it seems to work ok now (I changed the emscripten build type a few weeks ago), so closing :)

blayzen-w commented 2 years ago

Awesome! Thanks for working on it