Code Monkey home page Code Monkey logo

cartable's Introduction

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

cartable's People

Contributors

github-actions[bot] avatar pradel avatar

Watchers

 avatar  avatar

cartable's Issues

Investigate switching from webpack to swcpack

Features that need to be migrated

  • livereload server in dev mode via nodemon
  • source map module injected at the top of the compiled file webpack.BannerPlugin
  • if using typescript should do type checking in a separate process ForkTsCheckerWebpackPlugin
  • should display errors with a nice output for easier readability FriendlyErrorsWebpackPlugin
  • node_modules are not bundled node-externals

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.