xode v0.0.3
xode
Create a customized node binary with additional features
The xode project is a hackable, customizable binary that wraps node and adds additional features to it. The additional features are:
- Native support for modern ECMAScript syntax.
- Native support for ECMAScript Modules in
.jsfiles (via a CommonJS transform). - Native support for parsing flow, TypeScript and React JSX syntax.
- Note that xode doesn't do any type-checking; it's just able to parse the additional syntax added by flow and TypeScript.
- Additional builtin modules (if you wish). You can add any module from npm as an additional builtin module, and then you don't need to install it from npm; it'll be built-in to
xode.
The xode project is built on top of nexe.
Use-cases
- Execute flow and typescript code without a build step
- Quickly prototype ideas using your favorite tools and npm packages, without needing to
npm install - Bundle up your node_modules as builtins and run scripts in CI without needing to install node_modules
Try it out
To try out a xode binary based on node 12.16.2 with no additional builtin modules, you can install xode from npm:
npm install -g xodeThen, run it on the command line with the name of a script as its first argument:
xode myscript.tsCompiling a xode binary (no customizations)
- Clone the repo and open it.
- Run
npm install. - Run
npm run build. xodebinaries will be created in thebuildfolder.
Customizing the base node version
- Clone the repo and open it.
- Run
npm install. - Edit
node-version.jsto whichever version of node you want yourxodebinary to be based on. - Run
npm run build. xodebinaries based off of your specified node version will be created in thebuildfolder.
Adding additional builtin modules from npm
- Clone the repo and open it.
- Run
npm install. - Use npm to install additional packages you'd like to add as builtins. I recommend you install them as non-dev dependencies, so you can tell them apart from dependencies internal to xode itself.
- Edit
xode/builtins.jsand add your additional packages to thexodeBuiltinsobject near the bottom of the file, using the example comment as a guide. - Run
npm run build. xodebinaries with your additional builtin modules will be created in thebuildfolder.
Adding support for additional native syntax features
xode uses babel internally to compile your source code to normal JavaScript right before it's run. By modifying the babel configuration xode uses, you can add support for additional syntax features.
- Clone the repo and open it.
- Run
npm install. - Use npm to install any additional babel transforms you'd like xode to have built-in.
- If desired, upgrade the existing babel packages xode uses to their latest versions.
- Add the transforms you installed to
xode/compile.js. - Run
npm run build. xodebinaries that use your customized babel configuration will be created in thebuildfolder.
Caveats
If you add builtin modules that use native code, you'll notice that a node_modules folder containing .node files gets created next to the xode/xode.exe binary in your build folder. You need to keep this node_modules folder next to the xode/xode.exe file for the native code to work correctly.
License
MIT