-
Notifications
You must be signed in to change notification settings - Fork 58
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
CommonJS and npm integration #16
Comments
Is there any way to use CommonJS or npm modules in CocoaScript for now? @jacobrask |
No there isn't. |
Yes you can: https://github.com/mathieudutour/sketch-builder |
Neat |
@ccgus I worked on this a bit and have a POC working in Sketch, going to be released in 49. Basically, I added a For now, it has a very simple resolver algorithm:
So it doesn’t handle nested relative require very well (it's working if you have your require in the top level; but not if they are in a function, it will look for the package starting from where the function is executed), nor looking for a In parallel, I started to create a few packages to mirror the NodeJS API:
Later, when those packages are finished, we will probably ship them with Sketch directly. I understand that it's vision that might not match the one you have for |
Yep, make the PR. This would be pretty cool to have. |
Allowing require() in addition to the import macro would enable you to use a bunch of modules from the npmjs repository in your CocoaScript code.
If a depended on module is using Node APIs it would obviously not run in a CocoaScript environment, but a lot of the modules in npm are simple cross-platform JavaScript libraries like underscore.js.
CocoaScript modules could be submitted to npm, and you have a package manager for free.
The text was updated successfully, but these errors were encountered: