Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

siroc

unjs8.4kMIT0.16.0TypeScript support: included

Zero-config build tooling for Node

node, nodejs, typescript, javascript, rollup, bundle, package

readme

siroc

🌬️ siroc

npm version Github Actions alerts grade

siroc is a zero-config but extensible framework for developing Node applications and libraries

Features

  • 💯 Zero-config required: Intelligent support for your package
    • Supports running and compiling TypeScript and the latest JavaScript syntax
  • ⚒️ Extensible: Write your own commands and build hooks
  • 💪 Typescript: Fully typed and self-documenting

siroc is still a work in progress. Feedback is welcome, and changes will be frequent.

Quick start

Just install siroc.

# You can install siroc as a development dependency
yarn add siroc --dev

# ... or install globally
yarn global add siroc

Configuration

You can configure siroc by creating a siroc.config.ts, siroc.config.js or siroc.config.json file at the same level as your package.json.

In a monorepo, any configuration options at the root level are inherited by your workspaces, though of course you can override them.

import { defineSirocConfig } from 'siroc'

export default defineSirocConfig({
  // fully typed options
})

Commands

siroc build

siroc knows what to build based on your package.json.

By default, siroc will build your src/index.js or src/index.ts file into whatever output file is specified in your package.json's main field.

If you have specified additional binaries, siroc will look for input files matching their names.

Under the hood, siroc uses rollup and esbuild to build and produce type definitions for your files.

Monorepos

If you have enabled yarn workspaces, siroc will build each of your workspaces. You can choose to build only some of these by specifying what to build.

yarn siroc build @mypackage/cli

Watch mode

You can build in watch mode, which will rebuild as necessary when source files change:

yarn siroc build --watch

Configuration

At the most basic level, your entrypoints are configured in your package.json:

  • bin (see npm docs)
  • main, module and browser (see npm docs)
  • types if you want a TS declaration file to be generated for your main/module/browser entrypoints
  • exports (see npm docs)

There are some conventions in place of configuration that are worth noting:

  • the file type is inferred from the file name if possible (e.g. babel.es.js will be in 'es' format)
  • main defaults to CJS, module to ES, browser to UMD, and bin to CJS
  • if you have a folder mapped using subpath patterns and it matches a folder within your src folder, the files within will be copied across and lightly transpiled using mkdist.
Example
{
  "exports": {
    ".": {
      // This will be compiled in CJS and matched to src/index.ts
      "require": "./dist/index.js",
      // This will be compiled in ES and matched to src/index.ts
      "import": "./dist/index.es.js"
    },
    // src/templates will be lightly transpiled with mkdist and copied to dist/templates
    "./templates/*": "./dist/templates/*",
    // siroc will not touch this
    "./package.json": "./package.json"
  },
  // This will be compiled in CJS and matched to src/index.ts
  "main": "./dist/index.js",
  // This will be compiled in ES and matched to src/index.ts
  "module": "./dist/index.es.js",
  // Types will be generated for src/index.ts
  "types": "./dist/index.d.ts",
  "bin": {
    // This will be compiled in CJS and matched to src/cli/index.ts
    "siroc": "bin/cli.js",
    // This will be compiled in CJS and matched to src/cli/runtime.ts
    "siroc-runner": "bin/runtime.js"
  }
}

Build hooks

siroc makes available three hooks for customising your build, if you need it.

  1. build:extend
  2. build:extendRollup
  3. build:done

siroc dev

If you're working in a monorepo, it can be helpful to have accurate and up-to-date intellisense when importing from other libraries in a monorepo, without having to rebuild every time you make changes.

Running siroc dev will replace your package entrypoints with stubs that point to your source files. Your binaries will run your source files directly using jiti.

siroc run

You can run arbitrary shell commands or node scripts using the power of the jiti runtime.

For example:

# You can run a node script written in TypeScript
yarn siroc run myfile.ts

# You can run a command in all your workspaces
yarn siroc run ls --workspaces

Contributors

Contributions are very welcome.

  1. Clone this repo

    git clone https://github.com/unjs/siroc
  2. Install dependencies and build project

    yarn
    
    # Stub modules for rapid development
    yarn siroc dev
    
    # Test (on changes)
    yarn siroc jest

Tip: You can also run yarn link within a package directory to test the module locally with another project.

License

MIT License - Made with 💖

changelog

0.16.0 (2021-08-24)

Bug Fixes

0.15.0 (2021-08-06)

⚠ BREAKING CHANGES

  • major version changes in @rollup/plugin-commonjs and @rollup/plugin-replace

Bug Fixes

  • core: generate .d.ts files for .mjs exports (#218) (7a14d21)

Miscellaneous Chores

0.14.0 (2021-07-17)

Features

  • add support for exports with patterns (1b1cd59)

0.13.0 (2021-07-15)

Features

  • support minifying outputs based on .min.* dist name (#215) (4713443), closes #214

0.12.0 (2021-07-09)

⚠ BREAKING CHANGES

  • use regexps to match dependency externals (#213)

Bug Fixes

  • use regexps to match dependency externals (#213) (58de5db)

0.11.1 (2021-06-23)

Bug Fixes

  • core: generate es exports dts files correctly (#212) (b0f29c6)
  • core: preserve package.json indent (#211) (14a7ffc)

0.11.0 (2021-05-31)

⚠ BREAKING CHANGES

  • esbuild upgrade to 0.12

Miscellaneous Chores

0.10.1 (2021-05-17)

Features

  • allow setting mkdist options in siroc.config (05d44bc)

0.10.0 (2021-05-12)

⚠ BREAKING CHANGES

  • Requires Node 12+
  • produces .mjs in subpath exports

Miscellaneous Chores

0.9.3 (2021-05-12)

0.9.2 (2021-04-07)

Bug Fixes

  • don't include root directory in cleanup (808bb9d)

0.9.1 (2021-04-06)

Bug Fixes

  • switch main dts generation location (2c220d7)

0.9.0 (2021-04-06)

⚠ BREAKING CHANGES

Bug Fixes

  • generate .dts correctly (e7d90d5)

Miscellaneous Chores

0.8.0 (2021-03-08)

⚠ BREAKING CHANGES

  • this currently includes all published files but changes to exports can potentially cause import issues

Features

  • add initial support for using mkdist (#208) (1cd0127)

Bug Fixes

  • exclude .json exports from build (5fb0c9f)

Miscellaneous Chores

0.7.0 (2021-02-26)

⚠ BREAKING CHANGES

  • esbuild has a number of breaking changes since 0.7

Miscellaneous Chores

0.6.7 (2021-02-22)

0.6.6 (2021-02-15)

Bug Fixes

  • only produce type if defined in package.json (c186038)

0.6.5 (2021-02-11)

Features

  • allow custom sources for package types (ebc5a02)

0.6.4 (2021-02-11)

Bug Fixes

  • fix build failures in windows environments caused by paths (f5f01c1)

0.6.3 (2021-01-20)

Bug Fixes

  • invert json matching requirement (6767c0f)

0.6.2 (2021-01-16)

Bug Fixes

  • support matching entrypoints in subdirectories (60c9920)

0.6.1 (2021-01-16)

0.6.0 (2020-12-06)

Features

  • add ability to build custom entrypoint (17714c7), closes #84

Bug Fixes

  • exit code 1 with bulid errors (95f5f2e), closes #196
  • use module format with mjs extension (0159b26), closes #201

0.5.0 (2020-11-29)

⚠ BREAKING CHANGES

  • upgrade deps to typescript 4.1

Features

  • add optional logging of entry -> output (ee95d8d), closes #192

Miscellaneous Chores

  • upgrade deps to typescript 4.1 (be6f6c9)

0.4.3 (2020-11-24)

Bug Fixes

  • don't use .flat() (to support node 10) (c816faa)

0.4.2 (2020-11-23)

Bug Fixes

  • don't build exports if also in main/browser/module (72f1b35), closes #195
  • don't swallow errors in hooks - fix cleaning build directory (43cc5fa), closes #194

0.4.1 (2020-11-17)

Bug Fixes

  • exclude json files from type generation (6781286), closes #193

0.4.0 (2020-10-11)

Features

  • add support for multiple entrypoints using exports (4bc4d1d), closes #71

0.3.3 (2020-09-30)

Bug Fixes

  • export default package options (78e4757)

0.3.2 (2020-09-30)

Features

  • allow specifying esbuild plugin options directly (0125825)

0.3.1 (2020-08-29)

Features

  • :children_crossing: improve siroc config experience (3ea1e3f)

Bug Fixes

  • 🔇 set exports to auto mode (716e858), closes #85

0.3.0 (2020-07-27)

⚠ BREAKING CHANGES

  • changelog is no longer a valid command and @siroc/jest-preset and @siroc/eslint-config must be installed separately

  • @siroc/core and @siroc/cli are no longer separate packages but must be accessed through siroc

Code Refactoring

  • merge siroc, @siroc/core and @siroc/cli into single package (0bcbbe9)

  • remove changelog command and rethink presets (9fd5e8a)

0.2.0 (2020-07-26)

Features

  • core: print filesizes on build (63e2c2c)

Bug Fixes

  • core: treat optionalDeps as external (fee3ff7)
  • pin rollup-plugin-esbuild (f109a90)

0.1.2 (2020-06-27)

Bug Fixes

  • eslint-config: depend on [@typescript-eslint](https://github.com/typescript-eslint) (52c4d29)

0.1.1 (2020-06-27)

Features

  • eslint-config: make prettier support optional (57938f1)

Bug Fixes

  • treat peerDeps as external (692a791)

Reverts

  • Revert "chore: upgrade deps" (4bbafb9)

0.1.0 (2020-06-16)

Features

  • cli: allow custom commands (8a2a232)
  • cli: default to running commands in parallel (43ea6c8)
  • cli, eslint-config: add support for eslint command (7cdc0b1)
  • cli, jest-preset: add jest config (2fea3be)
  • core: look in parent directories for package config (ad77639)
  • core, cli: add support for dev stubbing (fa77a7b)
  • jest-preset: add basic jest preset (68f93c5)
  • jest-preset: allow extending jest (e20c294)
  • add support for json config (901609f)
  • allow typescript siroc config (79976d1)

Bug Fixes

  • cli: allow tests to pass with no tests (1383ed1)
  • jest-preset: support js transform (e2b0c6a)
  • add Object.entries polyfill for node 10 (5566a16)
  • add Object.fromEntries polyfill for node 10 (0c9d8e6)
  • ix allSettled polyfill for node 10 (e91e8c8)
  • remove circular dependency (9053c27)
  • remove nuxt known authors (23c0019)
  • core: only create stubs for buildable packages (32ca50d)
  • revert allSettled polyfill temporarily (3d136f2)
  • use relative path for module stubs (610c7d0)

Performance Improvements

  • core: reduce code execution in build (be34f6c)
  • use v8-compile-cache for cli (e601f30)

0.0.2 (2020-06-09)

Features

  • add --dev mode for building (a7554b2)
  • add jiti runtime support (dc245ba)
  • add node timing (57ab8e5)
  • add support for running files in all workspaces (47d7265)
  • build speed improvement and dx (e036a9f)
  • compile binaries (c2c6642)
  • improve rollup config generation (0e322bb)
  • set permissions on binaries (05b92d1)
  • support legacy file name (3f50db0)
  • use es build of cli (5a4db66)
  • use siroc (and jiti) to compile siroc (51c1cf4)

Bug Fixes

Performance Improvements