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 #54

Merged
merged 1 commit into from Jan 4, 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
44 changes: 0 additions & 44 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore
@@ -1,7 +1,4 @@
/coverage
/dist
/lib
/lib-node
/umd
# ESLint isn't configured to deal with ESM yet
/test-esm
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

37 changes: 37 additions & 0 deletions .eslintrc.cjs
@@ -0,0 +1,37 @@
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/interface-name-prefix': 'off',
'@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']}],
},

overrides: [
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
],
}
63 changes: 30 additions & 33 deletions .github/workflows/ci.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run lint -- --quiet
- run: npm run coverage

test:
Expand All @@ -43,24 +43,26 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
# Test the oldest Node.js version we support, and the latest in development
node: [12, current]
# 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:
# ubuntu and lts already runs tests in the `build` job, so we only need to add windows and mac here
- os: macos-latest
node: lts/*
- os: windows-latest
node: lts/*
- 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
# Test the actively developed version that will become the latest LTS release next October
node: current
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm i
- run: npm run build
- run: npm run coverage
- run: npm test
env:
SKIP_MTLS_TEST: "${{ matrix.os == 'ubuntu-latest' && 'true' || 'false' }}"

Expand All @@ -74,11 +76,10 @@ jobs:
with:
# The testing suite uses the native test runner introduced in Node.js v18
# https://nodejs.org/api/test.html
node-version: 18
node-version: lts/*
cache: npm
- run: npm ci
- run: npm run build
- run: npm run build:esm
- run: npm run test:esm
# This test will run both in a CJS and an ESM mode in Node.js to ensure backwards compatibility
name: Ensure pkg.exports don't break anything in modern Node.js envs
Expand All @@ -88,26 +89,22 @@ jobs:
name: Test the 'browser' conditional using Node.js

test-deno:
name: Test Deno in Node compatibility mode
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
cache: npm
- run: npm ci
- run: npm run build
- run: npm run build:esm
- uses: denoland/setup-deno@v1
with:
# @todo: stop overriding the version after migrating from `--compat` (https://github.com/sanity-io/get-it/issues/33)
deno-version: v1.24.x
- run: npm run test:esm:deno
# When not in Node Compat mode it's likely using something like https://esm.sh/get-it, which supports the same `deno` conditional
# and thus it's not necessary to run a test outside compat mode here
name: Test that pkg.exports supports Deno running in Node Compatibility mode
name: Test Deno in Node compatibility mode
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
with:
node-version: lts/*
cache: npm
- run: npm ci
- run: npm run build
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- run: npm run test:esm:deno
name: Test that pkg.exports supports Deno running in Node Compatibility mode

release:
name: Semantic release
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/lock.yml
@@ -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@c1b35aecc5cdb1a34539d14196df55838bb2f836 # v4
with:
issue-inactive-days: 0
pr-inactive-days: 0
35 changes: 35 additions & 0 deletions .github/workflows/prettier.yml
@@ -0,0 +1,35 @@
---
name: Prettier

on:
push:
branches: [main]
workflow_dispatch:

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

jobs:
run:
name: 🤔
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
with:
cache: npm
node-version: lts/*
- run: npm ci --ignore-scripts --only-dev
- uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3
with:
path: node_modules/.cache/prettier/.prettier-cache
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
- name: check if workflows needs prettier
run: npx prettier --cache --check ".github/workflows/**/*.yml" || (echo "An action can't make changes to actions, you'll have to run prettier manually" && exit 1)
- run: npx prettier --ignore-path .gitignore --cache --write .
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # tag=v9
with:
default_author: github_actions
commit: --no-verify
message: 'chore(prettier): 🤖 ✨'
9 changes: 1 addition & 8 deletions .gitignore
Expand Up @@ -9,15 +9,8 @@ pids

# Built sources
/dist
/lib
/lib-node
/umd

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

# Coverage directory used by tools like istanbul
.nyc_output
# Coverage directory used by tools like c8
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
Expand Down
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
legacy-peer-deps=true
3 changes: 0 additions & 3 deletions .nycrc

This file was deleted.

File renamed without changes.
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.