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

feat: full Node.js ESM runtime support #86

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 0 additions & 18 deletions .babelrc

This file was deleted.

3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dist
lib
umd
coverage
.nyc_output
runtimes/deno
runtimes/node
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

45 changes: 45 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
},
plugins: ['@typescript-eslint', 'simple-import-sort', 'prettier'],
rules: {
'@typescript-eslint/no-explicit-any': 'error', // use the FIXME alias instead
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'no-console': 'error',
'no-shadow': 'error',
'no-warning-comments': ['warn', {location: 'start', terms: ['todo', '@todo', 'fixme']}],
'prettier/prettier': 'warn',
},

overrides: [
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['test/**/*.ts'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
}
4 changes: 2 additions & 2 deletions .github/workflows/bun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: antongolub/action-setup-bun@bc198f5cb868ce282f0a72bdd7da3a06a5387f83 # tag=v1
- uses: antongolub/action-setup-bun@bc198f5cb868ce282f0a72bdd7da3a06a5387f83 # v1
- run: bun install
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # tag=v9
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # v9
with:
message: 'chore(bun): update bun lockfile'
default_author: github_actions
163 changes: 109 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,65 @@ concurrency:
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [lts/-3, lts/-2, lts/-1, lts/*, current]
name: node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm test

build:
name: Build, lint and test coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
cache: 'npm'
- run: npm ci
- run: npx ls-engines
- run: npm run prepublishOnly
- uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3
- run: npm run lint -- --report-unused-disable-directives
- run: npm run coverage
- uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3
name: Cache build output
with:
name: build-output
path: |
dist/
lib/
umd/

test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Run the testing suite on each major OS with the latest LTS release of Node.js
os: [macos-latest, ubuntu-latest, windows-latest]
node: [lts/*]
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
include:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/-2
- os: ubuntu-latest
# Also test the previous LTS release
node: lts/-1
- os: ubuntu-latest
# Test the actively developed version that will become the latest LTS release next October
node: current
# The `build` job already runs the testing suite in ubuntu and lts/*
exclude:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/*
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: ${{ matrix.node }}
- run: npm install
- run: npx ls-engines
- run: npm run coverage

prod-deps:
name: Cache production dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
Expand All @@ -67,70 +92,101 @@ jobs:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- if: steps.prod-deps.outputs.cache-hit != 'true'
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
- if: steps.prod-deps.outputs.cache-hit != 'true'
run: npm install --omit=dev --ignore-scripts

# Disabled until the jest runtime works with ESM
# edge-runtime:
# runs-on: ubuntu-latest
# needs: [build, prod-deps]
# steps:
# - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
# - uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
# with:
# node-version: lts/*
# cache: 'npm'
# cache-dependency-path: runtimes/edge/package-lock.json
# - uses: actions/cache@1c73980b09e7aea7201f325a7aa3ad00beddcdda # tag=v3
# with:
# path: ./node_modules
# key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
# - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v3
# with:
# name: build-output
# - run: npm ci
# working-directory: runtimes/edge
# - run: npm test
# working-directory: runtimes/edge
edge-runtime:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- run: npm install
- uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
name: Restore build output
with:
name: build-output
- run: npm run test:edge-runtime -- --coverage

browser-runtime:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- run: npm install
- uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
name: Restore build output
with:
name: build-output
- run: npm run test:browser -- --coverage

deno-runtime:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
name: Restore build output
with:
name: build-output
- uses: denoland/setup-deno@v1
- name: deno test
run: |
deno fmt --check
deno lint
deno task test
working-directory: runtimes/deno
with:
deno-version: vx.x.x
- run: npm run test:deno

bun-runtime:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: antongolub/action-setup-bun@bc198f5cb868ce282f0a72bdd7da3a06a5387f83 # tag=v1
- run: bun wiptest
working-directory: runtimes/bun
- uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
name: Restore build output
with:
name: build-output
- uses: antongolub/action-setup-bun@bc198f5cb868ce282f0a72bdd7da3a06a5387f83 # v1
- run: npm run test:bun

node-runtimes:
runs-on: ubuntu-latest
needs: [build, prod-deps]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3
name: Install only production dependencies
with:
path: ./node_modules
key: prod-deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
- uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3
name: Restore build output
with:
name: build-output
- run: npm run test:node-runtimes

release:
needs: [build, test, deno-runtime, bun-runtime]
needs: [build, test, deno-runtime, bun-runtime, edge-runtime, browser-runtime, node-runtimes]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
Expand All @@ -140,13 +196,12 @@ jobs:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
cache: npm
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
# @TODO remove dry-run after everything is good to go
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Maintain deno/import_map.json

on:
push:
branches: [main]
paths:
- 'package.json'
workflow_dispatch:

jobs:
run:
name: deno run update_import_map.ts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
cache: npm
node-version: lts/*
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- run: npm run test:deno:update_import_map
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # v9
with:
message: 'chore(deno): update import_map.json'
default_author: github_actions
24 changes: 24 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: 'Lock Threads'

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
with:
issue-inactive-days: 0
pr-inactive-days: 0