Install
To install Saffron, run:
ESM
Saffron is a pure ESM package. If your application is also written as and compiled to pure ESM, you can import Saffron using ESM import syntax:
Or, if you prefer named imports:
CommonJS
If your application is written in CommonJS, don't worry! You can still use Saffron with a dynamic import. However, dynamic imports must be await
-ed, and CommonJS does not support top-level await
statements, so the logic in your CLI must be wrapped in a function where we can then properly import Saffron:
If you are writing source using ESM syntax and then transpiling to CommonJS, you must make sure that your transpiler preserves dynamic import()
statements (rather than transpiling them to require()
calls). If dynamic imports are converted to require calls, your end-users will get an ERR_REQUIRE_ESM
error when they try to use your application's CLI.
Examples in this guide will use ESM import syntax for its simplicity and brevity.
Last updated