Skip to content

Commit

Permalink
Merge pull request #27 from curveball/esm
Browse files Browse the repository at this point in the history
ESM support
  • Loading branch information
evert authored Feb 15, 2023
2 parents 2732566 + e4bf108 commit 9214a54
Show file tree
Hide file tree
Showing 18 changed files with 913 additions and 747 deletions.
13 changes: 0 additions & 13 deletions .github/dependabot.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/bun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Bun Test Runner

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

jobs:
bun-test:
name: Bun tests

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Bun
uses: antongolub/action-setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run mocha
41 changes: 25 additions & 16 deletions .github/workflows/ci.yml → .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI
name: Node.js Test Runner

on:
push:
Expand All @@ -11,48 +11,57 @@ on:

jobs:
node-test:
name: Node.js tests
name: Node.js tests (ESM)

runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test

bun-test:
name: Bun tests
cjs-test:
name: Node.js tests (CommonJS)

runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Bun
uses: antongolub/action-setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run mocha
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} (CommonJS)
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: make test-cjs

lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm ci
- run: npm run lint
- run: npm run lint
22 changes: 11 additions & 11 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
Expand All @@ -36,14 +36,14 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
- run: npm ci
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
registry-url: 'https://npm.pkg.github.com'
scope: '@curveball'
- run: npm publish
Expand Down
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
/node_modules

# typescript output
/dist
/esm
/cjs

# Directory used for running tests in CommonJS mode
/cjs-test

# vim
.*.swp

# nyc
/.nyc_output

# vscode
/.vscode
# bun!
/bun.lockb
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Bad Gateway Inc.
Copyright (c) 2021-2023 Bad Gateway Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 24 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,50 @@ SOURCE_FILES:=$(shell find src/ -type f -name '*.ts')
all: build

.PHONY:build
build: dist/build
build: cjs/build esm/build

.PHONY:test
test:
node_modules/.bin/nyc node_modules/.bin/mocha
npx nyc mocha

.PHONY:test-cjs
test-cjs:
mkdir -p cjs-test
cd test; npx tsc --module commonjs --outdir ../cjs-test
echo '{"type": "commonjs"}' > cjs-test/package.json
cd cjs-test; npx mocha --no-package

.PHONY:lint
lint:
node_modules/.bin/eslint --quiet 'src/*.ts' 'test/*.ts'
npx eslint --quiet 'src/**/*.ts' 'test/**/*.ts'

.PHONY:lint-fix
lint-fix: fix

.PHONY:fix
fix:
node_modules/.bin/eslint --quiet 'src/**/*.ts' 'test/**/*.ts' --fix
npx eslint --quiet 'src/**/*.ts' 'test/**/*.ts' --fix

.PHONY:watch
watch:
node_modules/.bin/tsc --watch
npx tsc --watch

.PHONY:start
start: build

.PHONY:clean
clean:
rm -r dist
rm -rf dist esm cjs cjs-test

cjs/build: $(SOURCE_FILES)
npx tsc --module commonjs --outDir cjs/
echo '{"type": "commonjs"}' > cjs/package.json
@# Creating a small file to keep track of the last build time
touch cjs/build


dist/build: $(SOURCE_FILES)
node_modules/.bin/tsc
esm/build: $(SOURCE_FILES)
npx tsc --module es2022 --outDir esm/
echo '{"type": "module"}' > esm/package.json
@# Creating a small file to keep track of the last build time
touch dist/build
touch esm/build
23 changes: 15 additions & 8 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
Changelog
=========

0.11.0 (????-??-??)
-------------------

* This package now supports ESM and CommonJS modules.
* No longer supports Node 14. Please use Node 16 or higher.


0.10.0 (2022-09-03)
------------------
-------------------

* Upgraded from `@curveball/core` to `@curveball/kernel`.


0.9.0 (2022-06-11)
------------------

* The plugin now creates a `.schemas` and `.ajv` properties on `Context`,
to make it easy to access the ajv instance from other contexts.
* The plugin now creates a `.schemas` and `.ajv` properties on `Context`, to
make it easy to access the ajv instance from other contexts.


0.8.4 (2022-03-14)
-----------------
------------------

* Add a `quiet` setting to suppress all logging. (@defrex)


0.8.3 (2022-01-15)
------------------

* Update all dependencies, fixing a potential upstream security bug
in `json-pointer`.
* Update all dependencies, fixing a potential upstream security bug in
`json-pointer`.


0.8.2 (2021-05-28)
------------------

* Switch from `better-ajv-errors` to `@stoplight/better-ajv-errors`. The
former no longer appears to be maintained.
* Switch from `better-ajv-errors` to `@stoplight/better-ajv-errors`. The former
no longer appears to be maintained.


0.8.1 (2021-05-18)
Expand Down
Loading

0 comments on commit 9214a54

Please sign in to comment.