Compiling Actions from multiple source files

I’m trying to implement my Actions in Typescript. In order to maximize both clarity and testability, I would like to be able to split the action into multiple files. Unfortunately, the only module modes under which tsc will honor the “outFile” compiler option (System and AMD) yield code that won’t compile when deployed.

Any tips or tricks to achieve this would be welcome!

The solution I finally landed on was to drive my build using Rollup, and invoking tsc via a Rollup plugin:

import typescript from '@rollup/plugin-typescript';
import eslint from "@rbnlffl/rollup-plugin-eslint";

export default {
    input: [
        "src/action1.ts",
        "src/action2.ts"
    ],
    output: {
        format: "cjs",
        dir: "dist",
    },
    external: ["auth0","immutable"],
    plugins: [
      eslint(),
      typescript({ module: 'es6' })
    ]
}

This setup neatly pulls together exactly what’s needed for each action, duplicating imported classes only as needed, and skipping things like test files. I hope this helps someone else!

2 Likes

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.