Fork me on GitHub
#planck
<
2017-12-15
>
tbaldridge01:12:31

I'm feeling lazy and didn't search for longer than 3 minutes:

tbaldridge01:12:42

Can I import NPM or node modules via Planck?

mfikes02:12:06

@tbaldridge No… Planck is based on plain JavaScriptCore and doesn’t have support for js/require. You should be able to do this in Lumo, though. It is actually based on Node.

tbaldridge02:12:47

thanks for the info!

mfikes02:12:21

No problem. At times I’ve thought about implementing it in Planck. I haven’t done any research to see how much would be involved.

mfikes02:12:17

I suppose the real killer would be, even if Planck could successfully load some JavaScript properly via js/require, then that JavaScript might expect other Node capabilities to be available in the ambient environment, like the filesystem and process stuff. The Node API would be a huge thing to replicate.

hlolli12:12:52

I guess planck could easily run compiled node moules, or import CommonJs files?

hlolli12:12:12

But yeh, as soon as a module requires fs/url or what have you, id would fail I guess.

mfikes12:12:03

Yeah, it looks like implementing Node's module system might not be out of reach. That would let Planck successfully load things like https://www.npmjs.com/package/long

hlolli12:12:29

I was patching the require for a pr for lumo, didn't seem super complicated the logic here https://github.com/hlolli/lumo/blob/bb79bf95784a3d0fee76a65e23b5c889d22be406/scripts/requirePatch.js

hlolli12:12:40

if it's just compiling index.js in commonjs (main from package.json) into cljs environment it's not, but as soon as it's useing node binaries or something fancy, it gets quickly hard I guess.