Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in daff.js for when running in Deno JavaScript runtime instead of NodeJS #160

Open
shah opened this issue Sep 8, 2020 · 2 comments

Comments

@shah
Copy link

shah commented Sep 8, 2020

@paulfitz this is a great library and seems to work in NodeJS. I'm trying to use bin/daff.js in Deno TypeScript and JavaScript runtime but am getting the following error:

> deno run -A bin/daff.js
error: Uncaught TypeError: Cannot read property 'Coopy' of undefined
    for (f in coopy.Coopy) { 
                    ^
    at file:///home/snshah/workspaces/github.com/paulfitz/daff/bin/daff.js:10607:21

This is probably a problem in the Haxe JS generator but other Haxe generated JS files seem to run in Deno's JavaScript runtime. Any thoughts?

Thanks!

@paulfitz
Copy link
Owner

paulfitz commented Sep 8, 2020

I tried running deno run -A bin/daff.js and fixing up problems ad-hoc, just to assess how much was broken. There were a bunch of trivial problems - code for picking what global object (exports/windows/...) to put the library in was failing - hacking it to use self worked, I'd be interested to know how libraries should behave in deno. Then there were some syntax issues (missing "var" declarations) - easy. But then there were complaints about require is not defined (e.g. require('fs')) and I don't know what to replace that with. As a library, daff doesn't need requires, but as a console tool it does. I'd welcome any advice.

@shah
Copy link
Author

shah commented Sep 8, 2020

Excellent sleuthing @paulfitz thanks for checking into this. Deno has its own fs module and cannot use the Node fs module so that might be tricky to fix (since, I suppose, Haxe is generating the require fs?). For the 'require' replacement, that's easy -- Deno supports EcmaScript imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants