Skip to content

Commit 93258d4

Browse files
authored
fix: esm exports by building with tsup (#252)
* fix: esm exports by building with tsup * call build before check-exports * try without optional dependencies
1 parent ea71de2 commit 93258d4

File tree

8 files changed

+784
-67
lines changed

8 files changed

+784
-67
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,14 @@ jobs:
4343

4444
- name: Install from network when no cache hit
4545
if: steps.yarn-cache.outputs.cache-hit != 'true'
46-
run: yarn install --ignore-optional --prefer-offline
46+
run: yarn install --prefer-offline
4747

4848
- name: Install from cache on cache-hit
4949
if: steps.yarn-cache.outputs.cache-hit == 'true'
50-
run: yarn install --ignore-optional --offline
50+
run: yarn install --offline
5151

5252
- name: Format and Lint check
53-
run: yarn check-format && yarn lint
53+
run: yarn check-format && yarn check-tsc && yarn lint && yarn build && yarn check-exports
5454

5555
- name: Tests and Coverage
5656
run: yarn test --coverage
57-
58-
- name: Build
59-
run: yarn build

package.json

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,46 @@
88
"type": "git",
99
"url": "https://github.com/zalando-incubator/graphql-jit.git"
1010
},
11-
"main": "dist/cjs/index.js",
12-
"module": "dist/esm/index.js",
11+
"main": "dist/index.js",
12+
"module": "dist/index.mjs",
1313
"exports": {
14+
"./package.json": "./package.json",
1415
".": {
15-
"import": "./dist/esm/index.js",
16-
"require": "./dist/cjs/index.js"
16+
"import": "./dist/index.mjs",
17+
"require": "./dist/index.js"
1718
},
1819
"./dist": {
19-
"import": "./dist/esm/index.js",
20-
"require": "./dist/cjs/index.js"
20+
"import": "./dist/index.mjs",
21+
"require": "./dist/index.js"
2122
},
2223
"./dist/*": {
23-
"import": "./dist/esm/*.js",
24-
"require": "./dist/cjs/*.js"
24+
"import": "./dist/*.mjs",
25+
"require": "./dist/*.js"
26+
},
27+
"./dist/*.mjs": {
28+
"import": "./dist/*.mjs",
29+
"require": "./dist/*.js"
2530
},
2631
"./dist/*.js": {
27-
"import": "./dist/esm/*.js",
28-
"require": "./dist/cjs/*.js"
32+
"import": "./dist/*.mjs",
33+
"require": "./dist/*.js"
2934
}
3035
},
3136
"scripts": {
32-
"precommit": "lint-staged",
33-
"prepublishOnly": "yarn && yarn build",
34-
"format": "prettier --write 'src/**/*.ts'",
37+
"benchmark": "NODE_ENV=production ./src/__benchmarks__/benchmarks.ts",
38+
"build": "yarn tsup-node",
39+
"check-exports": "attw --pack .",
3540
"check-format": "prettier -l 'src/**/*.ts'",
36-
"lint": "eslint --ext .ts .",
37-
"lint-fix": "eslint --ext .ts . --fix",
38-
"build": "yarn build:esm && yarn build:cjs",
39-
"build:esm": "tsc --project tsconfig.esm.json",
40-
"build:cjs": "tsc --project tsconfig.cjs.json",
41-
"test": "jest",
42-
"mutation-test": "stryker run",
41+
"check-tsc": "tsc --noEmit",
4342
"codecov": "codecov",
44-
"benchmark": "NODE_ENV=production ./src/__benchmarks__/benchmarks.ts"
43+
"eslint": "eslint --ext .ts .",
44+
"format": "prettier --write 'src/**/*.ts'",
45+
"lint-fix": "yarn eslint --fix",
46+
"lint": "yarn eslint",
47+
"mutation-test": "stryker run",
48+
"precommit": "lint-staged",
49+
"prepublishOnly": "yarn && yarn build",
50+
"test": "jest"
4551
},
4652
"files": [
4753
"dist/*"
@@ -75,6 +81,7 @@
7581
"graphql": ">=15"
7682
},
7783
"devDependencies": {
84+
"@arethetypeswrong/cli": "^0.16.2",
7885
"@graphql-tools/schema": "^10.0.0",
7986
"@stryker-mutator/core": "^7.1.1",
8087
"@stryker-mutator/jest-runner": "^7.1.1",
@@ -99,6 +106,7 @@
99106
"jest": "^29.7.0",
100107
"lint-staged": "^14.0.1",
101108
"prettier": "^3.0.3",
109+
"tsup": "^8.2.4",
102110
"typescript": "^5.2.2"
103111
},
104112
"dependencies": {

tsconfig.build.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

tsconfig.cjs.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

tsconfig.esm.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"lib": ["esnext.asynciterable", "ES2022"],
1818
"typeRoots": ["./types", "./node_modules/@types"]
1919
},
20-
"include": ["src/**/*", "types/**/*"]
20+
"include": ["src/**/*", "types/**/*", "tsup.config.ts"]
2121
}

tsup.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entryPoints: ["src/*.ts"],
5+
bundle: false,
6+
format: ["cjs", "esm"],
7+
dts: true,
8+
sourcemap: true,
9+
outDir: "dist",
10+
clean: true,
11+
minify: false
12+
});

0 commit comments

Comments
 (0)