Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Oct 9, 2021
0 parents commit 74ed444
Show file tree
Hide file tree
Showing 13 changed files with 5,337 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Node.js CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
matrix:
os: [ubuntu-latest]

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

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: 14.x

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps
run: npm i

# Runs a set of commands using the runners shell
- name: Build and Test
run: npm run test

- name: Release
run: npx semantic-release --branches main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store
dist
*.log
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@egoist/prettier-config"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright © 2021 EGOIST (https://github.com/sponsors/egoist)

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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**💛 You can help the author become a full-time open-source maintainer by [sponsoring him on GitHub](https://github.com/sponsors/egoist).**

---

# bundle-require

[![npm version](https://badgen.net/npm/v/bundle-require)](https://npm.im/bundle-require)

## Use Case

Projects like [Vite](https://vitejs.dev) need to load config files provided by the user, but you can't do it with just `require()` because it's not necessary a CommonJS module, it could also be a `.mjs` or event written in TypeScript, and that's where the `bundle-require` package comes in, it loads the config file regardless what module format it is.

This is implemented by pre-bundling the file with [esbuild](https://esbuild.github.io/) and then loading it with `require()`.

## Install

```bash
npm i bundle-require esbuild
```

`esbuild` is a peer dependency.

## Usage

```ts
import { bundleRequire } from 'bundle-require'

const mod = await bundleRequire({
filepath: './project/vite.config.ts',
})
```

## License

MIT © [EGOIST](https://github.com/sponsors/egoist)
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': '@sucrase/jest-plugin',
},
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/types/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
Loading

0 comments on commit 74ed444

Please sign in to comment.