Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Commit

Permalink
chore(init): unplugin-rescript
Browse files Browse the repository at this point in the history
  • Loading branch information
r17x committed Jun 25, 2024
0 parents commit fba8e67
Show file tree
Hide file tree
Showing 39 changed files with 8,677 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [r17x]
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Lint
run: nr lint

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [16.x, 18.x, 20.x, 21.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Build
run: nr build

- name: Test
run: nr test
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: lts/*

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
85 changes: 85 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE
.idea
### direnv
.direnv
.envrc

3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

pnpm lint-staged
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-workspace-root-check=true
shamefully-hoist=true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Rin <https://github.com/r17x>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
140 changes: 140 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<div align="center">
<h1>unplugin-rescript</h1>
<p>
a plugin for integration <a href="https://rescript-lang.org/"><b>ReScript</b></a> with most Bundler (Vite, Rollup, Webpack, Esbuild, etc).
</p>
<p>
🚧 <b>Status: Work in progress (Unstable) - <a href="./TODO.md">TODO</a>"</b> 🚧
<a href="https://www.npmjs.com/package/unplugin-rescript">
<img src="https://img.shields.io/npm/v/unplugin-rescript?color=a1b858&label="/>
</a>
</p>
</div>

## Install

```bash
npm i unplugin-rescript
```

## Usage

> Example: [`playground/`](./playground/)
<details>
<summary>Vite</summary><br>

```ts
// vite.config.ts
import ReScript from 'unplugin-rescript/vite'

export default defineConfig({
plugins: [
ReScript({ /* options */ }),
],
})
```
<br></details>

<details>
<summary>Farm</summary><br>

```ts
// farm.config.ts
import ReScript from 'unplugin-rescript/farm'

export default defineconfig({
plugins: [
ReScript({ /* options */ }),
],
})
```
<br></details>

<details>
<summary>Rspack</summary><br>

```ts
// rspack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-rescript/rspack')({ /* options */ })
]
}
```
<br></details>


<details>
<summary>Rollup</summary><br>

```ts
// rollup.config.js
import ReScript from 'unplugin-rescript/rollup'

export default {
plugins: [
ReScript({ /* options */ }),
],
}
```

<br></details>


<details>
<summary>Webpack</summary><br>

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-rescript/webpack')({ /* options */ })
]
}
```

<br></details>

<details>
<summary>Esbuild</summary><br>

```ts
// esbuild.config.js
import { build } from 'esbuild'
import ReScript from 'unplugin-rescript/esbuild'

build({
plugins: [ReScript()],
})
```

<br></details>

<details>
<summary>Astro</summary><br>

```ts
// astro.config.mjs
import { defineConfig } from 'astro/config'
import ReScript from 'unplugin-rescript/astro'

build({
plugins: [ReScript()],
})
```

<br></details>

## Compatibility

## 🔭 Troubleshooting

## ❤️ Credits

Inspired by

* [jihchi/vite-plugin-rescript](https://github.com/jihchi/vite-plugin-rescript) - [@jihchi](https://github.com/jihchi)
* [unplugin/unplugin-starter](https://github.com/unplugin/unplugin-starter) - [@antfu](https://github.com/antfu)
12 changes: 12 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# TODO
> High priority tasks
* [ ] `Watch` capabilities.
* [ ] Fix `farm` plugin.
* [ ] E2E tests for all bundlers.

## Roadmap
* [ ] Backwards compatibility for `rescript` compiler.
* [ ] `rescript@v9` support.
* [ ] `rescript@v10` support.
* [ ] `rescript@v11` support.
28 changes: 28 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "tab",
"indentWidth": 2,
"lineWidth": 80,
"lineEnding": "lf"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off"
},
"style": {
"useNodejsImportProtocol": "off"
}
}
}
}
Loading

0 comments on commit fba8e67

Please sign in to comment.