Skip to content

Commit 3a3f637

Browse files
committed
chore: improve the build pipeline with esbuild
1 parent d5eec32 commit 3a3f637

File tree

13 files changed

+1859
-2733
lines changed

13 files changed

+1859
-2733
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ packages/core/build
130130
# moon
131131
.moon/cache
132132
.moon/docker
133-
.rollup.cache
133+
.rollup.cache/

.moon/project.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ tasks:
4444
- "tsconfig.json"
4545
- "/tsconfig.json"
4646
- "/tsconfig.base.json"
47+
deps:
48+
- "^:build"
4749

4850
build:
4951
command: "rollup -c rollup.config.ts --configPlugin typescript"
@@ -55,6 +57,7 @@ tasks:
5557
deps:
5658
- "clean"
5759
- "typecheck"
60+
- "^:build"
5861
env:
5962
NODE_NO_WARNINGS: "1"
6063

.moon/toolchain.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# https://moonrepo.dev/docs/config/toolchain
2-
$schema: 'https://moonrepo.dev/schemas/toolchain.json'
2+
$schema: "https://moonrepo.dev/schemas/toolchain.json"
33

44
node:
55
version: 16.17.0
6-
syncVersionManagerConfig: 'nvm'
6+
syncVersionManagerConfig: "nvm"
77
addEnginesConstraint: true
88

9-
packageManager: 'pnpm'
9+
packageManager: "pnpm"
1010
pnpm:
11-
version: '7.18.2'
11+
version: "7.18.2"
1212

13-
aliasPackageNames: 'name-only'
13+
aliasPackageNames: "name-only"
1414

1515
dedupeOnLockfileChange: false
16-
dependencyVersionFormat: 'workspace'
16+
dependencyVersionFormat: "workspace"
1717

1818
inferTasksFromScripts: true
1919

2020
syncProjectWorkspaceDependencies: true
2121

2222
typescript:
2323
createMissingConfig: false
24-
rootConfigFileName: 'tsconfig.json'
25-
rootOptionsConfigFileName: 'tsconfig.base.json'
24+
rootConfigFileName: "tsconfig.json"
25+
rootOptionsConfigFileName: "tsconfig.base.json"
2626

2727
routeOutDirToCache: false
28-
syncProjectReferences: true
29-
syncProjectReferencesToPaths: true
28+
syncProjectReferences: false
29+
syncProjectReferencesToPaths: false

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"@rollup/plugin-commonjs": "^24.0.0",
99
"@rollup/plugin-json": "^6.0.0",
1010
"@rollup/plugin-node-resolve": "^15.0.1",
11-
"@rollup/plugin-sucrase": "^5.0.1",
1211
"@rollup/plugin-typescript": "^11.0.0",
1312
"@types/jest": "^23.3.14",
1413
"@types/node": "^18.11.18",
1514
"@typescript-eslint/eslint-plugin": "^5.37.0",
1615
"@typescript-eslint/parser": "^5.48.1",
16+
"esbuild": "^0.17.0",
1717
"eslint": "^7.32.0",
1818
"eslint-import-resolver-typescript": "^3.5.1",
1919
"eslint-plugin-import": "^2.26.0",
@@ -23,7 +23,8 @@
2323
"prettier": "^2.7.1",
2424
"prettier-plugin-organize-imports": "^2.3.4",
2525
"rollup": "^3.10.0",
26-
"ts-jest": "^23.10.2",
26+
"rollup-plugin-dts": "^5.1.1",
27+
"rollup-plugin-esbuild": "^5.0.0",
2728
"ts-node": "^7.0.1",
2829
"tslib": "^2.4.1",
2930
"typescript": "4.9.4"

packages/benchmark.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": [],
66
"main": "dist/index.cjs.js",
77
"module": "dist/index.es5.js",
8-
"typings": "dist/index.d.ts",
8+
"types": "dist/index.d.ts",
99
"files": [
1010
"dist"
1111
],
Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import { defineConfig } from "rollup";
2-
import { plugins } from "../../rollup.options";
32
import pkg from "./package.json" assert { type: "json" };
3+
import { declarationsPlugin, jsPlugins } from "../../rollup.options";
44

5-
export default defineConfig({
6-
input: `src/index.ts`,
7-
output: [
8-
{
9-
file: pkg.main,
10-
format: "cjs",
11-
sourcemap: true,
12-
},
13-
{ file: pkg.module, format: "es", sourcemap: true },
14-
],
15-
external: ["@codspeed/core"],
16-
watch: {
17-
include: "src/**",
5+
const entrypoint = "src/index.ts";
6+
7+
export default defineConfig([
8+
{
9+
input: entrypoint,
10+
output: [
11+
{
12+
file: pkg.types,
13+
format: "es",
14+
sourcemap: true,
15+
},
16+
],
17+
plugins: declarationsPlugin,
18+
external: ["@codspeed/core"],
19+
},
20+
{
21+
input: entrypoint,
22+
output: [
23+
{
24+
file: pkg.main,
25+
format: "cjs",
26+
sourcemap: true,
27+
},
28+
{ file: pkg.module, format: "es", sourcemap: true },
29+
],
30+
plugins: [...jsPlugins],
31+
external: ["@codspeed/core"],
1832
},
19-
plugins,
20-
});
33+
]);

packages/benchmark.js/tsconfig.json

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"declaration": true,
5-
"outDir": "dist/types",
6-
"rootDir": "src",
7-
"paths": {
8-
"@codspeed/core": [
9-
"../core/src/index.ts"
10-
],
11-
"@codspeed/core/*": [
12-
"../core/src/*"
13-
]
14-
}
4+
"outDir": "dist",
5+
"rootDir": "src"
156
},
167
"include": [
178
"src/**/*.ts"
18-
],
19-
"exclude": [
20-
"dist"
21-
],
22-
"references": [
23-
{
24-
"path": "../core"
25-
}
269
]
2710
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"gypfile": true,
77
"main": "dist/index.cjs.js",
88
"module": "dist/index.es5.js",
9-
"typings": "dist/types/index.d.ts",
9+
"types": "dist/index.d.ts",
1010
"files": [
1111
"dist"
1212
],

packages/core/rollup.config.ts

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
import { defineConfig } from "rollup";
22
import nativePlugin from "rollup-plugin-natives";
3-
import { plugins } from "../../rollup.options";
3+
import { declarationsPlugin, jsPlugins } from "../../rollup.options";
4+
45
import pkg from "./package.json" assert { type: "json" };
56

6-
export default defineConfig({
7-
input: `src/index.ts`,
8-
output: [
9-
{
10-
file: pkg.main,
11-
format: "cjs",
12-
sourcemap: true,
13-
},
14-
{ file: pkg.module, format: "es", sourcemap: true },
15-
],
16-
external: ["@codspeed/core"],
17-
watch: {
18-
include: "src/**",
7+
const entrypoint = "src/index.ts";
8+
9+
export default defineConfig([
10+
{
11+
input: entrypoint,
12+
output: [
13+
{
14+
file: pkg.types,
15+
format: "es",
16+
sourcemap: true,
17+
},
18+
],
19+
plugins: declarationsPlugin,
20+
},
21+
{
22+
input: entrypoint,
23+
output: [
24+
{
25+
file: pkg.main,
26+
format: "cjs",
27+
sourcemap: true,
28+
},
29+
{ file: pkg.module, format: "es", sourcemap: true },
30+
],
31+
plugins: [
32+
...jsPlugins,
33+
nativePlugin({
34+
copyTo: "dist/lib",
35+
destDir: "./lib",
36+
}),
37+
],
1938
},
20-
plugins: [
21-
...plugins,
22-
nativePlugin({
23-
copyTo: "dist/lib",
24-
destDir: "./lib",
25-
}),
26-
],
27-
});
39+
]);

packages/core/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"declaration": true,
5-
"outDir": "dist/types",
4+
"outDir": "dist",
65
"rootDir": "src"
76
},
87
"include": [

0 commit comments

Comments
 (0)