Skip to content

Commit

Permalink
Merge pull request #59 from davidmyersdev/setup-ci
Browse files Browse the repository at this point in the history
Setup CI
  • Loading branch information
davidmyersdev authored Nov 29, 2023
2 parents 5fb8f7e + 0631ec6 commit 428edff
Show file tree
Hide file tree
Showing 17 changed files with 1,981 additions and 190 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: [
'artisan',
],
overrides: [
{
files: [
'./.github/**/*.yml',
],
rules: {
'yml/no-empty-mapping-value': 'off',
},
},
],
}
27 changes: 27 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Install dependencies
description: Install and cache dependencies
runs:
using: composite
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2.4.0
with:
run_install: false
version: 8
- name: Get the pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup the pnpm cache
uses: actions/cache@v3
with:
key: v1-${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
path: |
${{ env.STORE_PATH }}
restore-keys: v1-${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci
on:
pull_request:
push:
branches:
- main
jobs:
install-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
lint:
needs:
- install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
- name: Run the linter
run: pnpm lint
test-unit:
needs:
- install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
- run: pnpm build:core
- run: pnpm build:shims
- run: pnpm build:shims:banner
- run: pnpm test
typecheck:
needs:
- install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
- run: pnpm build:core
- run: pnpm build:shims
- run: pnpm build:shims:banner
- run: pnpm typecheck
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineConfig({
plugins: [
nodePolyfills({
// To add only specific polyfills, add them here. If no option is passed, adds all polyfills
include: ['path']
include: ['path'],
// To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect
exclude: [
'http', // Excludes the polyfill for `http` and `node:http`.
Expand All @@ -80,8 +80,10 @@ export default defineConfig({

### All polyfills

- If protocolImports is true, also adds node:[module]
- If protocolImports is true, also adds node:[module]

```js
[
'_stream_duplex',
'_stream_passthrough',
'_stream_readable',
Expand Down Expand Up @@ -122,4 +124,5 @@ export default defineConfig({
'util',
'vm',
'zlib',
]
```
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"type": "module",
"private": true,
"scripts": {
"build": "vite build",
"dev": "vite",
Expand Down
3 changes: 2 additions & 1 deletion examples/react/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function App() {
</button>
</p>
<p>
{/* eslint-disable-next-line n/prefer-global/buffer */}
The following text is encoded and decoded with Buffer: {Buffer.from('Hello!').toString()}
</p>
</div>
Expand All @@ -32,6 +33,6 @@ export const app = () => {
<App />
<ReactQueryDevtools initialIsOpen={true} />
</QueryClientProvider>
</React.StrictMode>
</React.StrictMode>,
)
}
2 changes: 1 addition & 1 deletion examples/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"type": "module",
"private": true,
"scripts": {
"build": "vite build",
"dev": "vite",
Expand Down
6 changes: 3 additions & 3 deletions examples/vanilla/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { Buffer } from 'node:buffer'
import { resolve } from 'node:path'
import * as process from 'node:process'
import fs from 'fs'
import { readFileSync } from 'node:fs'
import fs, { readFileSync } from 'node:fs'
import { cloneDeep } from 'lodash-es'
import { fetch } from 'ohmyfetch'

Expand All @@ -22,7 +22,7 @@ console.log(resolve('.'))
console.log(process)
console.log(process.env)
console.log(globalThis.Array)
console.log(Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]).readBigUInt64BE(0))
console.log(Buffer.from([0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]).readBigUInt64BE(0))
console.log(Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]))
console.log(Array)
console.log(readFileSync('./test.txt', 'utf-8'))
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"type": "module",
"private": true,
"scripts": {
"build": "vite build",
"dev": "vite",
Expand Down
1 change: 1 addition & 0 deletions examples/vue/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineComponent, ref } from 'vue'
export default defineComponent({
setup() {
// eslint-disable-next-line n/prefer-global/buffer
const msg = ref(Buffer.from(Buffer.from('Hello, friend!').toString('base64'), 'base64').toString('ascii'))
return {
Expand Down
44 changes: 24 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "vite-plugin-node-polyfills",
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",
"type": "module",
"version": "0.16.0",
"packageManager": "pnpm@8.4.0",
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",
"author": "David Myers <hello@davidmyers.dev>",
"license": "MIT",
"funding": "https://github.com/sponsors/davidmyersdev",
"homepage": "https://github.com/davidmyersdev/vite-plugin-node-polyfills",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/davidmyersdev/vite-plugin-node-polyfills.git"
Expand All @@ -19,15 +21,11 @@
"vite",
"vite-plugin"
],
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
"import": "./dist/index.js"
},
"./shims": {
"require": "./shims/dist/index.cjs",
Expand All @@ -38,6 +36,9 @@
"import": "./shims/banner/dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"shims"
Expand All @@ -48,6 +49,8 @@
"build:shims": "vite build ./shims",
"build:shims:banner": "vite-node ./shims/banner/build.ts",
"build:types": "run-s typecheck",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "run-s test:build",
"test:build": "run-p test:build:*",
"test:build:react": "pnpm -C ./examples/react run build",
Expand All @@ -62,28 +65,29 @@
"typecheck:vanilla": "pnpm -C ./examples/vanilla run typecheck",
"typecheck:vue": "pnpm -C ./examples/vue run typecheck"
},
"packageManager": "pnpm@8.4.0",
"peerDependencies": {
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
},
"dependencies": {
"@rollup/plugin-inject": "^5.0.5",
"buffer-polyfill": "npm:buffer@^6.0.3",
"node-stdlib-browser": "^1.2.0",
"process": "^0.11.10"
},
"devDependencies": {
"@types/node": "^18.18.8",
"esbuild": "^0.18.20",
"esbuild": "^0.19.8",
"eslint": "^8.54.0",
"eslint-config-artisan": "^0.2.1",
"npm-run-all": "^4.1.5",
"rollup": "^3.29.4",
"rollup": "^4.6.0",
"typescript": "4.8.3",
"vite": "^5.0.2",
"vite-node": "^0.34.6",
"vite-plugin-externalize-deps": "^0.1.5",
"vite-plugin-inspect": "^0.7.42",
"vite-plugin-node-polyfills": "workspace:*"
},
"dependencies": {
"@rollup/plugin-inject": "^5.0.5",
"buffer-polyfill": "npm:buffer@^6.0.3",
"node-stdlib-browser": "^1.2.0",
"process": "^0.11.10"
},
"peerDependencies": {
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
},
"publishConfig": {
"access": "public"
},
Expand Down
Loading

0 comments on commit 428edff

Please sign in to comment.