Node module babel inline polyfill - babeljs

I'm using babel to transpile ES5 and above into ExtendScript. So far the only thing that I haven't figured out yet is how to include/require Node modules. E.g. I'd like to use path.join() in the non-node environment (require is not available). I thought babel could include polyfill modules inline, but apparently that's not possible. Are there any other options?

Related

use-package does not download packages

I don't quite get the use-package package. I thought of it as a replacement of the older require statement in config files but on github it reads
This loads in the package XYZ, but only if XYZ is available on your system
So do I have to ensure that I have the package before?
Because sometimes it seems, all I need is the use-package statement for a fresh Emacs install to get the dependency.
Please clarify.
I think the point is to let you share your init.el across systems and simply have it ignore packages which are not available on any particular system.
It also appears to allow you to specify, but defer the evaluation of, your own customizations for any package you use until the package is actually loaded, so unlike require, it doesn't force you to load a package you are not going to use in this session.
There is a facility for requiring a package to be installed if it's not installed; look for the :ensure keyword and the use-package-always-ensure configuration variable in the documentation.

How to use jQuery in Coffeescript Interactive (REPL)?

So I've done...
npm install -g jquery
and I run coffee in terminal...
then I type in require 'jquery'
And I get an error :/. I've tried variations of the above to no avail.
How can I use jQuery functions in my Coffeescript REPL ?
You installed a jquery module as global module.
Loading local modules
If the module identifier passed to require() is not a native module (e.g. http), and does not begin with '/', '../', or './', then Node.js starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location.
If it is not found there, then it moves to the parent directory, and so on, until the root of the file system is reached.
Loading global modules
To make global modules available to the Node.js (and CoffeeScript) REPL, it might be useful to also add the /usr/lib/node_modules folder to the $NODE_PATH environment variable. Since the module lookups using node_modules folders are all relative, and based on the real path of the files making the calls to require(), the packages themselves can be anywhere.
It appears the quirk was that I had jquery installed in the global dependency folder (i.e. the -g flag in npm install -g jquery).
Doing a simple npm install jquery does the trick and gets everything to work :).

How to set sass with compass and coffeescript in meanio

I find mean.io (MongoDB Espress Angular Node) very interesting.
I'm used to work with coffeescript, sass and compass.
I would like to start a project with all these and not with pure js and css as the default setup does.
Is it possible to do it?
Yes it is possible but right now there is a bit of overhead required to get setup.
Have a look at https://github.com/gruntjs/grunt-contrib-coffee for info about converting coffescript to js using grunt. mean.io uses a lot of the grunt tools.
I would also recommend emailing a colleage of mine lior#linnovate.net. He has recently been building a sass package using the mean package system.
To see currently available packages have a look at http://www.mean.io/#!/packages

How to use packages installed by quicklisp?

I've installed the CL-PNG package using quicklisp.
(ql:quicklisp 'png)
Now I want to define my own package which depends on the CL-PNG package. Like so:
(defpackage :FOO
(:use :CL :PNG)
(:export :BAR))
When compiling it I get this error:
The name "PNG" does not designate any package.
[Condition of type SB-KERNEL:SIMPLE-PACKAGE-ERROR]
It seems that I have to call (require :PNG) on the REPL before compiling my package.
What do I have to do to make the CL-PNG package available for the compiler without manually call require on the REPL?
UPDATE: I'm using SBCL.
You confuse two separate notions: a system and a package. A package is defined by Common Lisp standard and it's a collection of symbols, a way to control their visibility and usage. A system is not defined by the standard, it's a notion introduced by ASDF, which is a collection of metadata to manage files inter-dependencies in a single project in order to be able to properly compile and load it. Quicklisp is built on top of ASDF to provide a way to distribute projects, described in the form of ASDF systems.
So when you install (quickload) a system, called PNG, this doesn't mean, that this system has a package, called PNG. Does the system define any packages (usually it defines one, or even several of them) and how they are called is at the discretion of its author. Most of the projects will have package.lisp or packages.lisp files, where their packages are defined.
But in the case of CL-PNG system you're loading, it actually defines the package PNG, and it should be available in the running process after you quickload it. But you should somehow load it every time you start your Lisp system. ASDF provides a means to define a dependency on CL-PNG system, so that you can just load only your own system, and all of the systems it depends on will be loaded automatically, making available all packages you want to use.

Where should a Quicklisp QUICKLOAD go in my source? Nowhere?

Let's say I build an application on top of net.aserve and bordeaux-threads. My package declaration might look like this:
(defpackage :my-package
(:use :cl :net.aserve :bordeaux-threads)
(:export …))
I use Quicklisp, so I run (ql:quickload "aserve") (ql:quickload "bordeaux-threads") in SLIME before compiling my package, and everything is fine.
Of course, tomorrow I start up SLIME again and I have to remember to issue the QUICKLOADs before I compile, otherwise I'm in for trouble.
I could put something like
(eval-when (:compile-toplevel)
(ql:quickload "aserve")
(ql:quickload "bordeaux-threads"))
at the top of my package—it's what I've done for development—but I have a feeling it's not a good idea to force a package manager on a user.
Is there a better alternative?
In your asd file, you should define the depends realtion as below:''
(asdf:defsystem #:aserve
:serial t
:depends-on (#:hunchentoot :hunchentoot-cgi
#::bordeaux-threads
#:parenscript)
...)
After then you just need to (ql:quickload :aserve) .
Use quickproject (accessible via (ql:quickload :quickproject)) to create a system for your application. As z_axis described, you can then fill the list of dependencies in the defsystem declaration (if you missed any when you called quickproject:make-project).
If you create your new project in the local-projects path of you Quicklisp installation, you can quickload your project too (even if it's not part of the Quicklisp distribution yet). Quickloading your project will of course download the dependencies (if they are part of the Quicklisp distribution), then load them.
If you don't want to include a quicklisp call in the deployed source code at all, separate the quickproject system definition file from the rest of the source.
At the top of the source, just before the defpackage call, add the necessary (require ...)'s for your package dependencies. This guarantees that those lisp packages are loaded (somehow) before proceeding, but does not specify 'how' those packages get loaded. They could be loaded by running the ql:quickload :my-package call (using quickproject), which would first load the dependencies, and then run through the require calls when loading the source. Or possibly a user could load the source directly (without calling ql:quickload), and the dependencies would be loaded during the require call, if those dependencies can be found on the *module-search-path*. This technique, as you said, would allow the end user to use whatever build tool he/she wants to load your source.
After experimenting with this for a few minutes, it seems that quicklisp latches into the require function call, so that if quicklisp is installed, and (require :bordeaux-threads) e.g., is called, lisp will use quicklisp to download and install that dependency. This is a very nice feature (IMO), because it allows the Common Lisp standard require function to act as the interface layer, and abstracts the specific build tool used to satisfy the dependency. Quicklisp can latch into the require, asdf latches into it (IIRC), etc.
So to answer your question, quicklisp calls should not go anywhere in the deployed source code, and requires should be used to ensure that dependencies are loaded before the package definition file is evaluated. If someone has quicklisp installed before loading the package definition file, those requires will be satisfied by using quicklisp to download and install the dependencies. If someone has asdf installed, those dependencies will be satisfied with that build tool. And if someone already has the dependencies installed (using some other technique), the requires will simply be passed over.
I had exactly the same question and I agree I should not force a package manager on a user. Before quicklisp's time I was using clbuild and it puts all .asd files into a systems/ directory. As long as the `systems/' directory is in asdf:central-registry, one can simply (require "a-package"), at least in SBCL and CCL, to load all relevant packages. The new clbuild2 retains this feature if you do install-from-upstream, and its integrated quicklisp does respect the separately installed-from-upstream packages, but quicklisp installed packages don't expose their .asd files anymore.
So my solution is to write a shell script that scans all quicklisp installed packages, usually under dists/quicklisp/software/, and link all .asd files there to a central place. In this way one doesn't need to load quicklisp into the cl image if one only wants to use quicklisp installed packages. I hope quicklisp could ship this feature by default.