This Meteor package lets you write code in
Civet in .civet files, and automatically compiles
them to JavaScript.
For context:
- Civet is a modern successor to CoffeeScript that is roughly a superset of TypeScript, plus many other features and syntax, and which compiles to TypeScript/JavaScript.
- Meteor is an (aging) full-stack JavaScript framework with powerful real-time data synchronization. I use it to build Cosuite.
meteor add edemaine:civet
meteor npm install --save-dev @danielx/civetNote that the Civet compiler @danielx/civet is a
peer NPM dependency,
so that you can control which version to install.
But that means you need to install it yourself.
This package offers broad compatibility with Meteor versions 2 and 3. In particular, for older Meteor releases that ship an older Node.js, Babel transpiles the Civet compiler itself, so that it runs despite modern JavaScript syntax.
For an example Meteor app using Civet, see meteor-civet-test-react.
- Enables
comptimeblocks - Compiles Civet to TypeScript, letting Meteor handle transpilation to JavaScript. This should support all TypeScript features.
edemaine:civet supports a lightweight protocol for Meteor compiler plugins
to customize the use of BabelCompiler.
For example, edemaine:solid
uses this protocol to conditionally switch from React to Solid JSX transforms.
In particular, this allows edemaine:civet and edemaine:solid to be used
together to support .civet files with Solid JSX.
The protocol is defined by two optional properties on Meteor:
globalThis.babelFeatures: object merged into theextraFeaturesfirst argument passed tonew BabelCompiler(...)globalThis.modifyBabelConfig(babelOptions, inputFile): callback for mutating Babel options on a per-file basis
See further details.
This implementation is based on Meteor's CoffeeScript compiler, which is MIT licensed:
- https://github.com/meteor/meteor/blob/devel/packages/non-core/coffeescript-compiler/coffeescript-compiler.js
- https://github.com/meteor/meteor/blob/devel/packages/non-core/coffeescript/compile-coffeescript.js
npm install
meteor test-packages ./If you're having weird compilation issues
(particularly during development, or perhaps when upgrading edemaine:civet),
clear the cache and restart Meteor:
rm -rf .meteor/local/plugin-cache/edemaine_civetThis package publishes two release tracks:
- v0.x.x releases are for Meteor 2
- v1.x.x releases are for Meteor 3
Release workflow:
- Increment both version tracks in
package.js. git commit -anpm run publish, or separately:npm run publish:2to release for Meteor 2npm run publish:3to release for Meteor 3
Ideally we would integrate more with Meteor's TypeScript support, such as zodern:types.