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

Using bun #443

Merged
merged 58 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5a9b756
Replacing vitest, tsx and tsup with bun.
RobinTail May 8, 2024
86e925f
Running unit tests.
RobinTail May 8, 2024
9a1b7fa
Using bun in CI job unitTest.
RobinTail May 8, 2024
e9e91df
Trying without --bun.
RobinTail May 8, 2024
594ad9e
Fix benchmark report processing.
RobinTail May 8, 2024
dacef96
Building and integration testing commands.
RobinTail May 8, 2024
69637f2
Adjusting the CI on integration tests.
RobinTail May 8, 2024
f1ce939
Making DTS build and adjusting the integration test itself.
RobinTail May 8, 2024
803b538
Using bun link for integration test.
RobinTail May 8, 2024
74b701d
Single DTS for all bundles.
RobinTail May 8, 2024
a381905
Rev, Ref: building CJS and restoring D.CTS.
RobinTail May 8, 2024
07c0352
Split commands.
RobinTail May 8, 2024
c09f4fa
Adjust eslint exceptions.
RobinTail May 8, 2024
105fa98
Using recommended tsconfig base for bun.
RobinTail May 8, 2024
9f62017
Trying vitest 2 beta2.
RobinTail May 9, 2024
5a6228f
Add missing dependency.
RobinTail May 9, 2024
ae67c65
Revert "Trying vitest 2 beta2."
RobinTail May 9, 2024
35d5b4a
Merge branch 'master' into try-bun
RobinTail Jun 22, 2024
7237c39
Fix: rem tsup and tsx.
RobinTail Jun 22, 2024
f9d621d
Enabling lcov.
RobinTail Jun 23, 2024
f4db3f5
Rm redundant prop in build script.
RobinTail Jun 23, 2024
41c3a4b
Update .github/workflows/ci.yml
RobinTail Jun 23, 2024
b9b71b4
Using bun-plugin-isolated-decl for DTS (ESM only).
RobinTail Jul 5, 2024
dca1f52
Merge branch 'master' into try-bun
RobinTail Jul 5, 2024
b8d4d7e
Merge branch 'master' into try-bun
RobinTail Jul 5, 2024
32243b6
Copy DTS generated by bun for CJS.
RobinTail Jul 5, 2024
592d686
Fix type import in bench tool.
RobinTail Jul 5, 2024
9926078
Upgrade DTS tool.
RobinTail Jul 5, 2024
eee6c4a
Moved build script to tools.
RobinTail Jul 5, 2024
2c83595
Upgrade bun setup action in the integration test.
RobinTail Jul 5, 2024
7eb9bed
Ref: naming CJS config.
RobinTail Jul 5, 2024
20900f3
Removing tsconfig.unit.json.
RobinTail Jul 5, 2024
e9fcaa2
Removed node types.
RobinTail Jul 5, 2024
a258e63
Easier overrides for eslint import plugin.
RobinTail Jul 5, 2024
655b915
Adjust prepublishOnly command.
RobinTail Jul 5, 2024
a27bf22
Updating publishing workflow.
RobinTail Jul 5, 2024
553dfe3
Reading file using Bun.file() instead of node:fs.
RobinTail Jul 5, 2024
13fba15
Removing unicorn plugin (no node imports).
RobinTail Jul 5, 2024
633ce38
Removing node references in eslint config.
RobinTail Jul 5, 2024
427638b
All deps external.
RobinTail Jul 5, 2024
8ea320b
Merge branch 'master' into try-bun
RobinTail Jul 5, 2024
09e0c0c
Updating dependencies.
RobinTail Jul 5, 2024
ac9927e
Fix JSON reading.
RobinTail Jul 5, 2024
fa60065
Clean comments in JS (CJS).
RobinTail Jul 5, 2024
4852d6c
Updating lock file and fix resolution.
RobinTail Jul 7, 2024
56949ee
Trying vitest 2.0 with --bun.
RobinTail Jul 7, 2024
590b68d
Revert "Trying vitest 2.0 with --bun."
RobinTail Jul 7, 2024
b247130
Merge branch 'master' into try-bun
RobinTail Jul 7, 2024
b64eb23
Minify CJS.
RobinTail Jul 7, 2024
445e98d
Minify commands.
RobinTail Jul 7, 2024
ec61604
Remove dependabot - does not support bun, will use Renovate.
RobinTail Jul 7, 2024
ed77dc0
Merge branch 'master' into try-bun
RobinTail Jul 7, 2024
2c96ede
Changelog: 3.0.0.
RobinTail Jul 7, 2024
fa9b638
3.0.0-beta.1
RobinTail Jul 7, 2024
75686f4
Rev: preserve Node installation in the publishing script.
RobinTail Jul 7, 2024
365e590
Using uglify-js instead of jsmin.
RobinTail Jul 7, 2024
ec781b7
3.0.0-beta.2
RobinTail Jul 7, 2024
5e6ef1d
Lock file updated for some reason.
RobinTail Jul 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/dependabot.yml

This file was deleted.

57 changes: 29 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ jobs:
unitTest:
runs-on: ubuntu-latest
steps:
- name: Get yarn cache dir
id: yarnCache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
- name: Install bun
uses: oven-sh/setup-bun@v2
with:
node-version: 18.x
bun-version: latest
- name: Get bun cache dir
id: bunCache
run: echo "dir=$(bun pm cache)" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-yarn
cache-name: cache-bun
with:
path: ${{ steps.yarnCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.bunCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/bun.lockb') }}
- name: Install dependencies
run: yarn install
run: bun install
- name: Testing
run: |
yarn lint
yarn test
bun run lint
bun run test
- name: Coveralls
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
uses: coverallsapp/github-action@v2
continue-on-error: true
with:
github-token: ${{ secrets.github_token }}
- name: Benchmark
run: yarn vitest bench --run
run: bunx vitest bench --run --outputJson bench.json
- name: Benchmark processing
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "# Performance benchmark" >> bench.txt
echo ${{ github.event.pull_request.head.sha }} >> bench.txt
echo '```' >> bench.txt
yarn tsx tools/benchmark.processor.ts >> bench.txt
bun run tools/benchmark.processor.ts >> bench.txt
echo '```' >> bench.txt
- name: Store results
if: ${{ github.event_name == 'pull_request' }}
Expand Down Expand Up @@ -109,43 +109,44 @@ jobs:
- 5.15.0
- latest
steps:
- name: Get yarn cache dir
id: yarnCache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
- name: Install bun
uses: oven-sh/setup-bun@v2
with:
node-version: 18.x
bun-version: latest
- name: Get bun cache dir
id: bunCache
run: echo "dir=$(bun pm cache)" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-yarn
cache-name: cache-bun
with:
path: ${{ steps.yarnCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.bunCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/bun.lockb') }}
- name: Install dependencies
run: yarn install
run: bun install
- name: Build
run: yarn build
run: bun run build
- name: Test
env:
MUI_VERSION: ${{ matrix.mui-version }}
run: |
bun link
cat >integration-test/package.json <<EOF
{
"name": "integration-test",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"merge-sx": "link:./..",
"merge-sx": "link:merge-sx",
"@mui/material": "${MUI_VERSION}",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
EOF
cat integration-test/package.json
yarn install --cwd=integration-test
yarn intTest
bun --cwd=integration-test install
bun run intTest
7 changes: 6 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ jobs:
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: yarn install
- name: Install bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- run: npm publish --tag ${{ inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_KEY}}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Version 3

### v3.0.0

- There are no breaking changes, but the distribution build process has changed:
- ESM is built using [bun](https://bun.sh/);
- DTS is built using [bun plugin Isolated Declarations](https://github.com/ryoppippi/bun-plugin-isolated-decl)
that runs [oxc transformer](https://www.npmjs.com/package/oxc-transform) under the hood;
- CJS is built using [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html)
and minified using [uglify-js](https://www.npmjs.com/package/uglify-js).

## Version 2

### v2.0.3
Expand Down
Binary file added bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[test]
coverage = true # always enable coverage
coverageReporter = ["text", "lcov"]
16 changes: 3 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@ import jsPlugin from "@eslint/js";
import tsPlugin from "typescript-eslint";
import prettierOverrides from "eslint-config-prettier";
import prettierRules from "eslint-plugin-prettier/recommended";
import unicornPlugin from "eslint-plugin-unicorn";
import importPlugin from "eslint-plugin-import";

export default [
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
unicorn: unicornPlugin,
import: importPlugin,
},
languageOptions: { globals: globals.browser },
plugins: { import: importPlugin },
settings: {
// "import-x" plugin installed as "import", in order to suppress the warning from the typescript resolver
// @link https://github.com/import-js/eslint-import-resolver-typescript/issues/293
"import-x/resolver": { typescript: true, node: true },
"import-x/resolver": { typescript: true },
},
},
jsPlugin.configs.recommended,
Expand All @@ -33,7 +24,6 @@ export default [
// Things to turn on globally
{
rules: {
"unicorn/prefer-node-protocol": "error",
"import/named": "error",
"import/export": "error",
"import/no-duplicates": "warn",
Expand Down
2 changes: 1 addition & 1 deletion integration-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package.json
yarn.lock
bun.lockb
2 changes: 1 addition & 1 deletion integration-test/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SxProps, Theme } from "@mui/system";
import { mergeSx } from "merge-sx";
import { describe, test, expect } from "vitest";
import { describe, test, expect } from "bun:test";

describe("Integration", () => {
test("mergeSx() operates SxProps", () => {
Expand Down
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "merge-sx",
"version": "2.0.3",
"version": "3.0.0-beta.2",
"description": "Combines multiple SxProps for Material UI components.",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down Expand Up @@ -34,37 +34,38 @@
},
"license": "MIT",
"scripts": {
"build": "tsup && attw --pack",
"build:cjs": "tsc -p tsconfig.cjs.json && uglifyjs dist/index.js -c -m -o dist/index.cjs",
"build": "bun run build:cjs && bun run tools/build.ts && cp dist/index.d.ts dist/index.d.cts && attw --pack",
"lint": "eslint",
"test": "tsc -p tsconfig.unit.json && vitest run src --coverage",
"intTest": "tsc -p integration-test/tsconfig.json && vitest run -r integration-test",
"test": "tsc --noEmit && bun test src",
"intTest": "tsc -p integration-test/tsconfig.json && bun test integration-test",
"mdfix": "prettier *.md --write",
"postversion": "git push && git push --tags",
"prepublishOnly": "yarn lint && yarn test && yarn build"
"prepublishOnly": "bun run lint && bun run test && bun run build"
},
"peerDependencies": {
"@mui/material": "^5.1.0"
"@mui/material": "^5.15.17"
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.0",
"@mui/system": "^5.15.0",
"@tsconfig/node18": "^18.2.2",
"@types/node": "^20.10.4",
"@vitest/coverage-istanbul": "^1.6.0",
"@arethetypeswrong/cli": "^0.15.3",
"@emotion/styled": "^11.11.5",
"@mui/system": "^5.16.0",
"@tsconfig/bun": "^1.0.7",
"@tsconfig/node18": "^18.2.4",
"@types/bun": "latest",
"bun-plugin-isolated-decl": "^0.1.1",
"eslint": "^9.6.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-0.5.2.tgz",
"eslint-plugin-import": "npm:eslint-plugin-import-x@^0.5.3",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^54.0.0",
"globals": "^15.3.0",
"globals": "^15.8.0",
"oxc-transform": "^0.17.0",
"prettier": "3.3.2",
"react": "^18.3.1",
"tsup": "^8.0.1",
"tsx": "^4.6.2",
"typescript": "^5.3.3",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0-alpha.39",
"vitest": "^1.6.0"
"uglify-js": "^3.18.0"
},
"resolutions": {
"**/@typescript-eslint/utils": "=8.0.0-alpha.39"
Expand Down
2 changes: 1 addition & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SxProps, Theme } from "@mui/system";
import { mergeSx } from "./index";
import { describe, it, expect } from "vitest";
import { describe, it, expect } from "bun:test";

describe("mergeSx()", () => {
describe("simple cases", () => {
Expand Down
2 changes: 1 addition & 1 deletion tools/benchmark.bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SxProps, Theme } from "@mui/system";
import type { SxProps, Theme } from "@mui/system";
import { mergeSx } from "../src";
import { bench, describe } from "vitest";

Expand Down
5 changes: 1 addition & 4 deletions tools/benchmark.processor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { readFileSync } from "node:fs";

const text = readFileSync("bench.json", "utf-8");
const json = JSON.parse(text);
const json = await Bun.file("bench.json", { type: "application/json" }).json();
const data = json.files[0].groups[0];
const suite = data.fullName.split(">")[1].trim();

Expand Down
14 changes: 14 additions & 0 deletions tools/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import isolatedDecl from "bun-plugin-isolated-decl";

await Bun.build({
entrypoints: ["src/index.ts"],
outdir: "dist",
/** @link https://github.com/oven-sh/bun/issues/159 */
format: "esm",
splitting: false,
sourcemap: "none",
minify: true,
plugins: [isolatedDecl()],
target: "browser",
external: ["*"],
});
11 changes: 11 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"moduleResolution": "node",
"target": "ES6",
"removeComments": true
},
"include": ["src/index.ts"]
}
11 changes: 3 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"strict": true,
"target": "ES6",
"module": "ES2022",
"moduleResolution": "Bundler",
"skipLibCheck": true
}
"extends": "@tsconfig/bun/tsconfig.json",
"compilerOptions": {},
"include": ["src"]
}
7 changes: 0 additions & 7 deletions tsconfig.unit.json

This file was deleted.

12 changes: 0 additions & 12 deletions tsup.config.ts

This file was deleted.

16 changes: 0 additions & 16 deletions vitest.config.ts

This file was deleted.

Loading