From f49bfd1428b4a4e9b1ae6823d5e209e54d6f266f Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 16 Oct 2025 11:11:23 -0400 Subject: [PATCH] Let's give bun a try Bun is a new JavaScript runtime with everything built in. It seems like it could be a lot easier than using a bunch of tools. It also is a bit faster and has some improvements to security. This replaces node, c8, esbuild, taze, maybe some other things. This commit also upgrades our eslint config to work with v9. --- .eslintrc | 63 ---------- .github/workflows/build.yml | 17 +-- .gitignore | 13 +- CONTRIBUTING.md | 31 +++++ README.md | 8 +- RELEASE.md | 32 +++-- bun.lock | 218 +++++++++++++++++++++++++++++++++ bunfig.toml | 8 ++ eslint.config.js | 101 +++++++++++++++ package.json | 45 +++---- scripts/build.ts | 29 +++++ index.d.ts => src/diff3.d.ts | 0 index.mjs => src/diff3.mjs | 1 - src/index.ts | 2 + test/LCS.test.js | 11 +- test/diff3Merge.test.js | 23 ++-- test/diff3MergeRegions.test.js | 11 +- test/diffComm.test.js | 11 +- test/diffIndices.test.js | 11 +- test/diffPatch.test.js | 35 +++--- test/merge.test.js | 15 +-- test/mergeDiff3.test.js | 15 +-- test/mergeDigIn.test.js | 13 +- tsconfig.json | 20 +++ 24 files changed, 543 insertions(+), 190 deletions(-) delete mode 100644 .eslintrc create mode 100644 CONTRIBUTING.md create mode 100644 bun.lock create mode 100644 bunfig.toml create mode 100644 eslint.config.js create mode 100644 scripts/build.ts rename index.d.ts => src/diff3.d.ts (100%) rename index.mjs => src/diff3.mjs (99%) create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index a4201be..0000000 --- a/.eslintrc +++ /dev/null @@ -1,63 +0,0 @@ -{ - "env": { - "node": true, - "es6": true - }, - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "extends": [ - "eslint:recommended" - ], - "rules": { - "dot-notation": "error", - "eqeqeq": ["error", "smart"], - "indent": ["off", 4], - "keyword-spacing": "error", - "linebreak-style": ["error", "unix"], - "no-caller": "error", - "no-catch-shadow": "error", - "no-console": "warn", - "no-div-regex": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-floating-decimal": "error", - "no-implied-eval": "error", - "no-invalid-this": "error", - "no-iterator": "error", - "no-labels": "error", - "no-label-var": "error", - "no-lone-blocks": "error", - "no-loop-func": "error", - "no-multi-str": "error", - "no-native-reassign": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-wrappers": "error", - "no-octal": "error", - "no-octal-escape": "error", - "no-process-env": "error", - "no-proto": "error", - "no-return-assign": "off", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-shadow": "off", - "no-shadow-restricted-names": "error", - "no-throw-literal": "error", - "no-unneeded-ternary": "error", - "no-unused-expressions": "error", - "no-unexpected-multiline": "error", - "no-unused-vars": "warn", - "no-void": "error", - "no-warning-comments": "warn", - "no-with": "error", - "no-use-before-define": ["off", "nofunc"], - "semi": ["error", "always"], - "semi-spacing": "error", - "space-unary-ops": "error", - "wrap-regex": "off", - "quotes": ["error", "single"] - } -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a60071..f2e7fae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,13 +16,16 @@ jobs: strategy: fail-fast: false matrix: - node-version: ['18', '20', '22'] + bun-version: ['1.3'] steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + - uses: actions/checkout@v5 + - name: Use Bun ${{ matrix.bun-version }} + uses: oven-sh/setup-bun@v2 with: - node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm run all + bun-version: ${{ matrix.bun-version }} + - run: bun install + - run: | + echo "::remove-matcher owner=eslint-compact::" + echo "::remove-matcher owner=eslint-stylish::" + - run: bun run all diff --git a/.gitignore b/.gitignore index 347fc98..0b4b4b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,9 @@ +/coverage +/dist +/node_modules + .DS_Store -.esm-cache .vscode -.coverage - -.nyc_output/ -built/ -coverage/ -dist/ -node_modules/ - npm-debug.log lerna-debug.log package-lock.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6976ddb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing + +This project uses **GitHub** to track issues and manage our source code. +- Check out the [Git Guides](https://github.com/git-guides) to learn more. + +This project uses the **JavaScript** programming language. +- [MDN's JavaScript guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide) is a great resource for learning about JavaScript. + +This project uses the **TypeScript** programming language. +- Check out the [TypeScript Docs](https://www.typescriptlang.org/docs/) to learn more. +- (It's a superset of JavaScript, so knowing that already will help you a lot). + +This project uses **Bun** as our development environment. +- Check out the [Bun Docs](https://bun.com/docs) to learn more. +- (It's similar to other JavaScript tools like Node/Jest/Esbuild/Vite, so knowing any of those already will help you a lot). +- Bun supports both JavaScript and TypeScript. + +If you want to contribute to node-diff3, you'll probably need to: +- [Install Bun](https://bun.com/docs/installation) +- `git clone` node-diff3 +- `cd` into the project folder +- `bun install` the dependencies + +As you change things, you'll want to `bun run all` to ensure that things are working. +(This command just runs `clean`, `lint`, `build`, and `test`.) + +It's also good to check on the dependencies sometimes with commands like: +- `bun outdated` - what packages have updates available? +- `bun update --interactive` - choose which updates to apply + +Try to keep things simple! diff --git a/README.md b/README.md index 082accc..12f451e 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ You can also use **node-diff3** directly in a web browser. A good way to do thi When you load this file in a ` +