Skip to content

Commit

Permalink
build: bundle code into one JS module
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Nov 6, 2023
1 parent a161e1e commit f5dfbb8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
node-version: 20
- name: Install dependencies
run: npm install
- name: Compile sources
run: npm run compile
- name: Build bundle
run: npm run build:bundle
- name: Replace the entrypoint with a bundle
run: npm run build:bundle:replace
- name: Benchmark (async)
run: npm run bench:product:async
- name: Benchmark (stream)
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ jobs:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm install
- name: Compile sources
run: npm run compile
- name: Build bundle
run: npm run build:bundle
- name: Replace the entrypoint with a bundle
run: npm run build:bundle:replace
- name: Run Hygiene Checks
run: npm run lint
- name: Run unit tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ node_modules/
.tmp/
.benchmark/
out/
build/

# Other files
package-lock.json
Expand Down
25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"engines": {
"node": ">=16.14.0"
},
"main": "out/index.js",
"typings": "out/index.d.ts",
"main": "build/index.js",
"typings": "build/index.d.ts",
"files": [
"out",
"!out/{benchmark,tests}",
"!out/**/*.map",
"!out/**/*.spec.*"
"build",
"!build/{benchmark,tests}",
"!build/**/*.map",
"!build/**/*.spec.*"
],
"keywords": [
"glob",
Expand All @@ -35,6 +35,7 @@
"@types/picomatch": "^2.3.0",
"@types/sinon": "^10.0.15",
"bencho": "^0.1.1",
"esbuild": "^0.19.5",
"eslint": "^8.46.0",
"eslint-config-mrmlnc": "^4.0.1",
"execa": "^7.2.0",
Expand All @@ -56,16 +57,22 @@
"micromatch": "^4.0.5"
},
"scripts": {
"clean": "rimraf out",
"clean": "rimraf out build",
"lint": "eslint \"src/**/*.ts\" --cache",
"compile": "tsc",
"test": "mocha \"out/**/*.spec.js\" -s 0",
"test:e2e": "mocha \"out/**/*.e2e.js\" -s 0",
"test:e2e:sync": "mocha \"out/**/*.e2e.js\" -s 0 --grep \"\\(sync\\)\"",
"test:e2e:async": "mocha \"out/**/*.e2e.js\" -s 0 --grep \"\\(async\\)\"",
"test:e2e:stream": "mocha \"out/**/*.e2e.js\" -s 0 --grep \"\\(stream\\)\"",
"build": "npm run clean && npm run compile && npm run lint && npm test",
"watch": "npm run clean && npm run compile -- --sourceMap --watch",
"_build:compile": "npm run clean && npm run compile",
"build": "npm run _build:compile && npm run lint && npm test",
"watch": "npm run _build:compile -- --sourceMap --watch",
"_build:bundle:dts": "tsc --emitDeclarationOnly --outDir ./build",
"_build:bundle:ts": "esbuild --bundle ./src/index.ts --outfile=./build/index.js --platform=node --target=node16.14",
"_build:bundle": "npm run _build:bundle:dts && npm run _build:bundle:ts",
"build:bundle": "npm run _build:compile && npm run _build:bundle",
"build:bundle:replace": "npm run _build:bundle:ts -- --outfile=./out/index.js",
"bench:async": "npm run bench:product:async && npm run bench:regression:async",
"bench:stream": "npm run bench:product:stream && npm run bench:regression:stream",
"bench:sync": "npm run bench:product:sync && npm run bench:regression:sync",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/pattern.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as path from 'node:path';

import * as globParent from 'glob-parent';
// https://stackoverflow.com/a/39415662
// eslint-disable-next-line @typescript-eslint/no-require-imports
import globParent = require('glob-parent');
import * as micromatch from 'micromatch';

import type { MicromatchOptions, Pattern, PatternRe } from '../types';
Expand Down
4 changes: 3 additions & 1 deletion src/utils/stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as merge2 from 'merge2';
// https://stackoverflow.com/a/39415662
// eslint-disable-next-line @typescript-eslint/no-require-imports
import merge2 = require('merge2');

import type { Readable } from 'node:stream';

Expand Down

0 comments on commit f5dfbb8

Please sign in to comment.