pradel / cartable

A fast, zero-config toolkit to develop, build and test node.js applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cartable

A fast, zero-config toolkit to develop node.js applications.

npm version

Cartable aims to provide you the best DX to develop your node.js applications. It's focused on server-only applications. Heavily inspired by backpack, the idea is a zero-config tool giving you all the tools you need. You can use it for new apps as well as existing ones.

Features

  • TypeScript support out of the box
  • Fast, using swc to transpile the code
  • Great DX, readable error messages, live reloading etc
  • Fast tests with jest and swc
  • Zero-config, one dependency
  • Easily customizable

Documentation

Installation

Install the package:

# with npm
npm install --save-dev @cartable/core

# with yarn
yarn add --dev @cartable/core

# with pnpm
pnpm add --save-dev @cartable/core

Add the cartable scripts to your package.json like this:

{
  "scripts": {
    "dev": "cartable",
    "build": "cartable build",
    "test": "cartable test"
  }
}

Usage

Using in development

Run the dev command that will reload your server when you edit:

npm run dev

Successful builds will show a console like this. Note: screenshot taken from running the basic typescript example.

Dev mode

Building for Production

Run the build command and start your app:

npm run build
node ./dist/index.js

Testing your application

Runs your tests using Jest:

npm run test

Configuration

Customizing webpack config

To extend webpack, you can define a function that extends its config via cartable.config.js.

// cartable.config.js
module.exports = {
  webpack: (config) => {
    // Perform customizations to config
    // Important: return the modified config
    return config;
  },
};

Customizing swc config

To extend our usage of swc, you can define a .swcrc file at the root of your app. This file is optional.

If found, cartable will consider it to be the source of truth.

Here's an example .swcrc file:

{
  "jsc": {
    "target": "es2020",
    "parser": {
      "syntax": "typescript"
    }
  }
}

Commands

cartable dev

Runs cartable in development mode. Your code will reload if you make edits.

cartable build

Builds the app for production to the dist folder. It correctly bundles your production mode and optimizes the build for the best performance.

You can run your production application with the following command:

node ./dist/index.js

cartable test

Test the app with jest. For better performance, compiling the JavaScript / TypeScript code is done via swc.

You can pass any option to jest, for example to generate coverage:

cartable test --coverage

Inspiration

License

MIT License © Léo Pradel

About

A fast, zero-config toolkit to develop, build and test node.js applications.

License:MIT License


Languages

Language:TypeScript 98.9%Language:Shell 0.6%Language:JavaScript 0.5%