Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: updated rollup and plugins #200

Closed
wants to merge 12 commits into from
Closed
12 changes: 7 additions & 5 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache node_modules
id: cacheModules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand All @@ -25,12 +25,14 @@ jobs:
name: Debug
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- uses: hmarr/debug-action@v3

checks:
name: Check
needs: [install]
uses: ./.github/workflows/checks.yml
with:
ref: ${{ github.sha }}

# The security job can't run on pull requests opened from forks because
# Github doesn't pass down the SNYK_TOKEN environment variable.
Expand All @@ -39,8 +41,8 @@ jobs:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand Down
39 changes: 27 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: v4.x checks

on: [workflow_call]
on:
workflow_call:
inputs:
ref:
description: 'The commit the workflow should check out'
required: true
default: ${{ github.sha }}
type: string

jobs:
test-node:
Expand All @@ -9,16 +16,18 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [14.x, 16.x, 18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install --prefer-offline
Expand All @@ -28,13 +37,15 @@ jobs:
name: Browser Test Specs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install --prefer-offline
Expand All @@ -44,8 +55,10 @@ jobs:
name: Code Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand All @@ -56,8 +69,10 @@ jobs:
name: Types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ jobs:
name: Debug
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- uses: hmarr/debug-action@v3

install:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache node_modules
id: cacheModules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand All @@ -43,3 +45,5 @@ jobs:
name: Checks
needs: [install]
uses: ./.github/workflows/checks.yml
with:
ref: ${{ github.event.pull_request.head.sha }}
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache node_modules
id: cacheModules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm # cache where "npm install" uses before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand All @@ -31,7 +31,7 @@ jobs:
name: Debug
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- uses: hmarr/debug-action@v3

checks:
name: Check
Expand All @@ -45,8 +45,8 @@ jobs:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm # cache where "npm install" uses before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand All @@ -60,13 +60,13 @@ jobs:
runs-on: ubuntu-latest
needs: [checks, security]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Setup .npmrc file to publish to npm
registry-url: 'https://registry.npmjs.org'
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
20
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ all: test lint typecheck

.PHONY: clean
clean:
@echo ""
@echo "=> cleaning dependencies and builds..."
@rm -Rf node_modules dist

.PHONY: commit
commit:
npx cz
@npx cz

.PHONY: publish
publish:
Expand All @@ -29,7 +31,9 @@ server:
# Builds

node_modules: package.json
npm install && /usr/bin/touch node_modules
@echo ""
@echo "=> installing dependencies..."
@npm install && /usr/bin/touch node_modules

dist: package.json rollup.config.js $(wildcard src/*.js) node_modules
@echo ""
Expand All @@ -47,11 +51,15 @@ test/fetch-api/api.spec.js: test/fetch-api/api.spec.ts

.PHONY: commitlint
commitlint: node_modules
npx commitlint --from origin/main --to HEAD --verbose
@echo ""
@echo "=> linting commits..."
@npx commitlint --from origin/main --to HEAD --verbose

.PHONY: cov
cov:
npx nyc report --reporter=text-lcov > .reports/coverage.lcov && npx codecov
@echo ""
@echo "=> checking code coverage..."
@npx nyc report --reporter=text-lcov > .reports/coverage.lcov && npx codecov

.PHONY: lint
lint:
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,18 @@
"url": "https://github.com/lquixada/cross-fetch/issues"
},
"dependencies": {
"node-fetch": "^2.6.12"
"node-fetch": "^2.7.0"
},
"devDependencies": {
"@commitlint/cli": "17.6.6",
"@commitlint/config-conventional": "17.6.6",
"@rollup/plugin-terser": "0.4.3",
"@types/chai": "4.3.5",
"@types/mocha": "10.0.1",
"@types/mocha": "10.0.10",
"@types/node": "18.15.13",
"body-parser": "1.20.2",
"body-parser": "1.20.3",
"chai": "4.3.7",
"codecov": "3.8.3",
"commitizen": "4.3.0",
"commitizen": "4.3.1",
"cz-conventional-changelog": "3.3.0",
"express": "4.18.2",
"husky": "8.0.3",
Expand All @@ -90,16 +89,18 @@
"nock": "13.3.1",
"nyc": "15.1.0",
"rimraf": "5.0.1",
"rollup": "3.26.0",
"rollup-plugin-copy": "3.4.0",
"rollup": "4.28.1",
"rollup-plugin-copy": "3.5.0",
"rollup-plugin-esbuild": "6.1.1",
"rollup-plugin-esbuild-minify": "1.2.0",
"semver": "7.5.3",
"serve-index": "1.9.1",
"standard": "17.1.0",
"standard": "17.1.2",
"standard-version": "9.5.0",
"typescript": "5.1.6",
"webpack": "5.88.1",
"webpack-cli": "5.1.4",
"whatwg-fetch": "3.6.2",
"whatwg-fetch": "3.6.20",
"yargs": "17.7.2"
},
"files": [
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Rollup creates the browser version of the polyfill and ponyfill. */
import path from 'path'
import copy from 'rollup-plugin-copy'
import terser from '@rollup/plugin-terser'
import { minify } from 'rollup-plugin-esbuild'

const input = path.join(__dirname, 'node_modules', 'whatwg-fetch', 'fetch.js')

Expand Down Expand Up @@ -128,7 +128,7 @@ export default [
`)
},
plugins: [
terser()
minify()
]
}
]
Loading