1.23.0 â€ĸ Published 3 years ago

import-runner v1.23.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

👟 Import Runner

Low code control flow using dynamic imports

⚙ī¸ Install

npm install import-runner

🏃 Run

Import runner provides a shorthand for executing complex control flows using dynamic imports:

import importRunner from "import-runner"

export default async (input: {
  someOption: boolean
}): Promise<any> => {
  return await importRunner({
    input,
    each: [
      import("./myFunction"),
      import("./thatFunction"),
      {
        all: [
          import("./otherFunction"),
          import("./andAnotherFunction"),
          {
            route: [
              import("./wowAnotherFunction"),
              import("./enoughFunction"),
            ],
          },
        ],
      },
    ],
  })
}

ℹī¸ Import runner calls the default function of the dynamic import (export default)

ℹī¸ If a function call returns an object, it is assigned to the final output (Object.assign)

OptionDescription
inputInput object
allConcurrent execution
eachSequential execution
routeConcurrent conditional execution (uses "or" on input types)

🤖 Low code

Wait a second! What is up with the any output of the importRunner call? Did I just lose all my types? How do the child functions know what their inputs will be?

Because we have a somewhat formal structure, we can programmatically parse importRunner calls and generate input and output types for the runner function and its component functions.

Example code to process source files with chokidar, eslint, prettier, file-replacer, and fs-extra:

import chokidar from "chokidar"
import { ESLint } from "eslint"
import fileReplacer from "file-replacer"
import fsExtra from "fs-extra"
import prettier from "prettier"
import sourceProcessor from "import-runner/dist/cjs/sourceProcessor"

chokidar.watch("./**/*.ts").on("change", (event, path) => {
  sourceProcessor({
    eslint: new ESLint({ fix: true }),
    fileReplacer,
    fsExtra,
    path,
    prettier,
    srcRootPath: __dirname,
  })
})
1.23.0

3 years ago

1.22.0

3 years ago

1.22.3

3 years ago

1.22.4

3 years ago

1.22.1

3 years ago

1.22.2

3 years ago

1.22.5

3 years ago

1.21.1

3 years ago

1.21.0

3 years ago

1.18.0

3 years ago

1.19.0

3 years ago

1.20.0

3 years ago

1.16.0

3 years ago

1.17.0

3 years ago

1.14.0

3 years ago

1.6.0

3 years ago

1.15.0

3 years ago

1.9.0

3 years ago

1.10.0

3 years ago

1.12.0

3 years ago

1.8.0

3 years ago

1.11.0

3 years ago

1.13.0

3 years ago

1.7.0

3 years ago

1.4.0

3 years ago

1.5.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.29.0

3 years ago

0.29.8

3 years ago

0.29.7

3 years ago

0.29.6

3 years ago

0.29.5

3 years ago

0.29.4

3 years ago

0.29.3

3 years ago

0.29.2

3 years ago

0.29.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.2

3 years ago

0.28.1

3 years ago

0.28.0

3 years ago

0.28.4

3 years ago

0.28.3

3 years ago

0.28.2

3 years ago

0.27.0

3 years ago

0.26.3

3 years ago

0.26.2

3 years ago

0.26.1

3 years ago

0.26.0

3 years ago

0.26.7

3 years ago

0.26.6

3 years ago

0.26.5

3 years ago

0.26.4

3 years ago

0.20.0

3 years ago

0.19.0

3 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.13.0

3 years ago

0.11.2

3 years ago

0.13.1

3 years ago

0.11.3

3 years ago

0.15.0

3 years ago

0.13.2

3 years ago

0.17.0

3 years ago

0.25.0

3 years ago

0.23.0

3 years ago

0.21.0

3 years ago

0.18.1

3 years ago

0.12.0

3 years ago

0.12.1

3 years ago

0.14.0

3 years ago

0.14.1

3 years ago

0.16.0

3 years ago

0.14.2

3 years ago

0.14.3

3 years ago

0.18.0

3 years ago

0.10.0

3 years ago

0.24.0

3 years ago

0.22.0

3 years ago

0.9.0

3 years ago

0.8.0

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago