rmx-cli

0.3.6 • Public • Published

rmx-cli

All Contributors

A CLI tool for Remix applications. Future versions will support adding external commands.

🛠 Installation

npm install -D rmx-cli

Commands

🪂 eject-ras

Eject your Remix project from Remix App Server to Express

npx rmx-cli eject-ras

📦 get-esm-packages

Scan for ESM package to add to remix.config.js serverDependenciesToBundle

npx rmx-cli get-esm-packages [package-name ...]

🏷️ version

List all Remix package versions installed in node_modules

npx rmx-cli version

🚀 gen-remix

THis script will generate a remix.ts file which re-exports all exports from specified packages. This essentially works like the magic remix package from early Remix.

Why is this useful?

  1. Go back to importing from one file instead of adapter specific packages. If you ever switch adapters, just re-generate the remix.ts file.
  2. Adds support for overrides. Now you can override a standard Remix export with your own function. Like replacing json, useLoaderData, etc. with the remix-typedjson functions.
  3. Add "postinstall": "rmx gen-remix" to package.json to ensure the file is regenerated when upgrading Remix packages.

Usage

Usage:
    $ npx rmx gen-remix [options]

  Options:
    --config PATH       Config path (default: ./gen-remix.config.json)
    --packages PACKAGES List of packages to export
    --output PATH       Output path (default: ./app/remix.ts)

  Example:
    rmx gen-remix --packages @remix-run/node @remix-run/react

Config

You can also include an optional config (defaults to gen-remix.config.json) where you can specify overrides.

{
  "exports": ["packageA", "packageB"],
  "overrides": {
    "<source-package>": [
      "<original-package>": {
        "<original-export>": "<new-source-export>",
        ...
      },
      "<original-package>": {
        "<original-export>": "<new-source-export>",
        ...
      }
    ],
    ...
  }
}

Example config:

This config replaces the Remix json, redirect, useActionData, etc. with the versions for remix-typedjson.

{
  "exports": ["@remix-run/node", "@remix-run/react", "remix-typedjson"],
  "overrides": {
    "remix-typedjson": {
      "@remix-run/node": {
        "json": "typedjson",
        "redirect": "redirect"
      },
      "@remix-run/react": {
        "useActionData": "useTypedActionData",
        "useFetcher": "useTypedFetcher",
        "useLoaderData": "useTypedLoaderData"
      }
    }
  }
}

😍 Contributors

Thanks goes to these wonderful people (emoji key):


Kiliman

💻 📖

Roy Revelt

📖

Kent C. Dodds

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Install

npm i rmx-cli

DownloadsWeekly Downloads

443

Version

0.3.6

License

MIT

Unpacked Size

26.2 kB

Total Files

9

Last publish

Collaborators

  • kiliman