Skip to content

Commit

Permalink
fix(build): move to esbuild and tweak using latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
V-ed committed May 10, 2022
1 parent 9a8ed38 commit 7d44b00
Show file tree
Hide file tree
Showing 9 changed files with 417 additions and 52 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
uses: anuraag016/Jest-Coverage-Diff@master
with:
accessToken: '${{ secrets.GH_BOT_TOKEN }}'
runCommand: "pnpm run test --coverage --collectCoverage=true --coverageReporters='json-summary' --coverageDirectory='./'"
runCommand: 'pnpm run --filter ./api test --coverage'
# delta: 0.5 # Delta of % changed that would make this job fail
afterSwitchCommand: 'pnpm i'
env:
COV_REPORTER: 'json-summary'
COV_DIRECTORY: '../'
45 changes: 45 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { build } = require('esbuild');
const { Generator } = require('npm-dts');

// @ts-ignore
const { dependencies, peerDependencies } = require('./package.json');

const depKeys = dependencies ? Object.keys(dependencies) : [];
const peerDepKeys = peerDependencies ? Object.keys(peerDependencies) : [];
const deps = depKeys.concat(peerDepKeys);

const outDir = 'dist';

/** @type {import('esbuild').BuildOptions } */
const shared = {
entryPoints: ['src/index.ts'],
bundle: true,
sourcemap: true,
// minify: true,
external: deps,
platform: 'node',
};

// Generate CommonJS code
build({
...shared,
outfile: `${outDir}/index.js`,
}).catch((err) => {
process.stderr.write(err.stderr);
process.exit(1);
});

// Generate ESM code
build({
...shared,
format: 'esm',
outfile: `${outDir}/index.esm.js`,
}).catch((err) => {
process.stderr.write(err.stderr);
process.exit(1);
});

// Generate Types
new Generator({
output: `${outDir}/types/index.d.ts`,
}).generate();
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@
"name": "quoted-string-space-split",
"version": "1.1.0",
"description": "npm package that allows to split a string by spaces, but bypassing quoted content",
"module": "dist/esm/index.js",
"main": "dist/commonjs/index.js",
"module": "dist/index.esm.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/commonjs/index.js"
"import": "./dist/index.esm.js",
"require": "./dist/index.js"
}
},
"scripts": {
"build": "npm-run-all -p build:*",
"build:esm": "tsc",
"build:commonjs": "tsc -p tsconfig.commonjs.json",
"build:types": "tsc -p tsconfig.types.json",
"build": "node build.js",
"lint": "npm-run-all lint:*",
"lint:src": "eslint \"src/**/*.ts\"",
"lint:tests": "eslint \"tests/**/*.ts\"",
"format": "npm-run-all format:*",
"format:src": "eslint --fix \"src/**/*.ts\"",
"format:tests": "eslint --fix \"tests/**/*.ts\"",
"test": "vitest run --config tests/vitest.config.ts"
"test": "vitest --config tests/.vitest/vitest.config.ts"
},
"files": [
"dist/**/*"
Expand Down Expand Up @@ -69,11 +66,13 @@
"@v-ed/prettier-config": "0.1.1",
"@v-ed/tsconfig": "0.2.0",
"c8": "7.11.2",
"esbuild": "0.14.38",
"eslint": "8.15.0",
"npm-dts": "1.3.11",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
"typescript": "4.6.4",
"vite-tsconfig-paths": "3.4.1",
"vitest": "0.12.1"
"vitest": "0.12.3"
}
}

0 comments on commit 7d44b00

Please sign in to comment.