• Stars
    star
    149
  • Rank 247,675 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Zero-config build tooling for Node

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 πŸ’–

More Repositories

1

nuxt-vitest

An vitest environment with support for testing code that needs a Nuxt runtime environment
TypeScript
369
star
2

typed-vuex

🏦 A typed store accessor for vanilla Vuex.
TypeScript
346
star
3

page-speed.dev

Vue
320
star
4

nuxt-zero-js

Remove all client-side JS from your Nuxt 3 app
TypeScript
191
star
5

nuxt-workers

SSR-safe, zero-config Web Workers integration for Nuxt.
TypeScript
186
star
6

unplugin-purge-polyfills

A tiny plugin to replace package imports with better native code.
TypeScript
184
star
7

sanity-typed-queries

A typed, zero-dependency schema generator and query builder for Sanity.
TypeScript
173
star
8

nuxt-time

⏰ SSR-safe time element for Nuxt 3
TypeScript
159
star
9

vue-bind-once

A tiny, SSR-safe directive for binding random data to an element.
TypeScript
120
star
10

nuxt-full-static

Full static implementation for Nuxt 3
TypeScript
117
star
11

roe.dev

This is the code and content for my personal website, built in Nuxt.
TypeScript
113
star
12

n3rdle

Vue
90
star
13

goff

Sync GitHub issues offline into a local folder
TypeScript
70
star
14

rollup-plugin-pure

Annotate functions as pure for Rollup
TypeScript
63
star
15

nuxt-capo

`capo.js` implementation for Nuxt 3
TypeScript
59
star
16

vue-sanity

Sanity integration for Vue Composition API
TypeScript
55
star
17

nuxt-vercel-isr

A tiny demo to show off Nuxt's route rules integration with Vercel.
Vue
55
star
18

nuxt-web-bundle

Generate web bundles with Nuxt
TypeScript
51
star
19

nuxt-pre-hydrate

TypeScript
46
star
20

spooon

This is a tiny recipe app built in Nuxt for a live-coding session at Vue.js Nation 2024.
Vue
33
star
21

nuxt-timings-module

TypeScript
32
star
22

n3dium

This is a tiny, incomplete example for a paywalled content site built in Nuxt 3 for a live-coding session at Vue.js Global Summit 2022.
Vue
30
star
23

trellis-valet-driver

A driver for Laravel Valet that supports the default Trellis install.
PHP
26
star
24

postcss-capsize

TypeScript
25
star
25

agent-conf-2023

A demo of integrating React, Vite and Nitro for AgentConf 2023.
JavaScript
25
star
26

nuxt-vue3-module

TypeScript
22
star
27

nuxt-vscode-template

TypeScript
20
star
28

nuxt-deno

TypeScript
18
star
29

stream-vue

Vue component for Cloudflare Stream.
TypeScript
16
star
30

jetbrains-2023

Vue
15
star
31

firstcommit.is

TypeScript
14
star
32

nuxt-hanko

TypeScript
12
star
33

frontend-nation-2024

Tiny Nuxt multiplayer app built for a live-coding session at Frontend Nation 2024.
TypeScript
11
star
34

iodigital-2024

Vue
11
star
35

vuejslive

A demo of integrating Vue, Vite and Nitro for Vue.js Live London 2023.
JavaScript
10
star
36

domain-sync

A tiny script that migrates all my Gandi domains to use Cloudflare DNS.
TypeScript
10
star
37

nuxt-turnstile

Cloudflare Turnstile integration for Nuxt
TypeScript
9
star
38

template

JavaScript
9
star
39

future-of-coding-2024

Vue
9
star
40

vuejs-de

TypeScript
7
star
41

unmeta

Simple tools for interacting with HTML metadata tags
TypeScript
7
star
42

vercel-kv

TypeScript
7
star
43

botornot

Vue
7
star
44

nuxt-emoji-blast

TypeScript
6
star
45

renovate

5
star
46

native-esm

JavaScript
4
star
47

nuxt-typed-vuex-example

Vue
4
star
48

vuejs-athens-2024

Vue
4
star
49

flowers

Vue
4
star
50

_productivity_app

Bicep
4
star
51

wearedevs

JavaScript
3
star
52

nuxt3-typed-routes

Vue
3
star
53

pigeon

Vue
3
star
54

danielroe

3
star
55

nuxt-nightly-action

TypeScript
3
star
56

gdg-portlaoise-2024

Vue
3
star
57

vue-subpath-conditions

TypeScript
3
star
58

nuxt-font-metrics

Font metric overrides to reduce CLS
TypeScript
2
star
59

nuxt-demo

TypeScript
2
star
60

partytown-example

TypeScript
2
star
61

viteconf

TypeScript
2
star
62

nuxt3-repros

TypeScript
2
star
63

vue3-pre-window-repro

JavaScript
2
star
64

digital-labin

JavaScript
2
star
65

nuxt-typed-vuex-vue-example

Vue
2
star
66

netlify-dynamic-builder

TypeScript
2
star
67

openflights-loader

TypeScript
1
star
68

building-better-with-nuxt-3

TypeScript
1
star
69

vuejs-berlin

Vue
1
star
70

.github

1
star
71

nuxt-fonts-demo

TypeScript
1
star
72

building-a-pwa-with-nuxt

JavaScript
1
star
73

sanity-module

1
star
74

critters-test

Vue
1
star
75

nuxi-upgrade-yarn3

TypeScript
1
star
76

nuxt-edge-preset

Vue
1
star
77

formkit-init

TypeScript
1
star
78

axios-types

Vue
1
star
79

nuxt-typed-vuex-ts-example

Vue
1
star
80

css-flash-repro

Vue
1
star