Skip to content

Commit

Permalink
Merge pull request #11 from curveball/strip-cjs
Browse files Browse the repository at this point in the history
Remove all traces of CJS
  • Loading branch information
evert authored Jan 14, 2024
2 parents e0567b3 + 687af25 commit c5c0675
Show file tree
Hide file tree
Showing 13 changed files with 771 additions and 3,689 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"mocha": true
},
"extends": [
"eslint:recommended",
Expand Down Expand Up @@ -61,7 +62,6 @@
"args": "none"
}],
"@typescript-eslint/prefer-for-of": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/prefer-ts-expect-error": ["error"]
}
}
25 changes: 2 additions & 23 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:

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

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

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

steps:
Expand All @@ -31,27 +31,6 @@ jobs:
- run: npm run build --if-present
- run: npm test

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@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

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm test

Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
Expand All @@ -39,11 +39,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@curveball'
- run: npm publish
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/node_modules

# typescript output
/esm
/cjs
/dist

# Directory used for running tests in CommonJS mode
/cjs-test
Expand Down
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) 2018-2023 Bad Gateway Inc.
Copyright (c) 2018-2024 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
31 changes: 7 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ VERSION:=$(shell node -e "process.stdout.write(require('./package.json').version
all: build

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

.PHONY:test
test:
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 --r ../test/polyfills.cjs

.PHONY:lint
lint:
npx eslint --quiet 'src/**/*.ts' 'test/**/*.ts'
Expand All @@ -38,19 +31,9 @@ start: build

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

cjs/build: $(SOURCE_FILES)
npx tsc --module commonjs --outDir cjs/
sed -i 's/VERSION = '\''Curveball\/dev.*$$/VERSION = '\''Curveball\/$(VERSION) \(cjs\)'\'';/g' cjs/application.js
echo '{"type": "commonjs"}' > cjs/package.json
@# Creating a small file to keep track of the last build time
touch cjs/build


esm/build: $(SOURCE_FILES)
npx tsc --module es2022 --outDir esm/
sed -i 's/VERSION = '\''Curveball\/dev.*$$/VERSION = '\''Curveball\/$(VERSION) \(esm\)'\'';/g' esm/application.js
echo '{"type": "module"}' > esm/package.json
@# Creating a small file to keep track of the last build time
touch esm/build
rm -rf dist

dist/build: $(SOURCE_FILES)
npx tsc
sed -i 's/VERSION = '\''Curveball\/dev.*$$/VERSION = '\''Curveball\/$(VERSION)'\'';/g' dist/application.js
touch dist/build
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

1.0.0 (????-??-??)
------------------

* CommonJS support has been dropped. The previous version of this library had
compatibility with both CJS and ESM. The effort and pain no longer feels
worth it, so we're dropping CommonJS support.
* Now requires Node 18.


0.21.2 (2023-02-17)
-------------------

Expand Down Expand Up @@ -143,6 +152,7 @@ Identical release as the previous alpha.




0.18.0-alpha.0 (2022-04-09)
---------------------------

Expand Down
Loading

0 comments on commit c5c0675

Please sign in to comment.