Skip to content

Commit 9187998

Browse files
authored
Merge pull request #303 from thefrontside/fnd-fix-pnpm-resolution
exports and ESM for foundation resolution with pnpm
2 parents cfe6431 + 1a2894d commit 9187998

File tree

6 files changed

+65
-21
lines changed

6 files changed

+65
-21
lines changed

.changes/fnd-fix-pnpm-resolution.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@simulacrum/foundation-simulator": patch:bug
3+
---
4+
5+
Fix `exports` in `package.json` and `tsconfig.json` with ESM for improved compatibility with `pnpm`.

packages/foundation/package.json

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"bugs": {
88
"url": "https://github.com/thefrontside/simulacrum/issues"
99
},
10-
"homepage": "https://github.com/thefrontside/simulacrum#readme",
1110
"repository": {
1211
"type": "git",
1312
"url": "git+https://github.com/thefrontside/simulacrum.git",
@@ -21,22 +20,22 @@
2120
"integration testing"
2221
],
2322
"files": [
24-
"dist"
23+
"README.md",
24+
"dist",
25+
"src"
2526
],
26-
"main": "dist/cjs/index.js",
27-
"exports": {
28-
"development": "./src/index.ts",
29-
"default": "./dist/cjs/index.js"
30-
},
3127
"scripts": {
3228
"start": "node --import=tsx ./example/singleFileServer/start.ts",
3329
"start:singlefile": "node --import=tsx ./example/singleFileServer/start.ts",
3430
"start:extensive": "node --import=tsx ./example/extensiveServer/start.ts",
35-
"prepack": "tsc --build tsconfig.dist.json",
3631
"test": "vitest run",
3732
"test:watch": "vitest watch",
3833
"bench": "vitest bench",
39-
"lint": "echo \"eventually run \"eslint src example\" but it currently fails to parse\""
34+
"lint": "echo \"eventually run \"eslint src example\" but it currently fails to parse\"",
35+
"prepack": "npm run build",
36+
"build": "npm run build:cjs && npm run build:esm",
37+
"build:cjs": "tsc -build tsconfig.dist.json",
38+
"build:esm": "tsc --build tsconfig.esm.json"
4039
},
4140
"dependencies": {
4241
"ajv-formats": "^3.0.1",
@@ -57,6 +56,24 @@
5756
"typescript": "^5.4.5",
5857
"vitest": "^1.6.0"
5958
},
59+
"exports": {
60+
"development": "./src/index.ts",
61+
"import": {
62+
"types": "./dist/esm/index.d.ts",
63+
"default": "./dist/esm/index.js"
64+
},
65+
"require": {
66+
"types": "./dist/cjs/index.d.ts",
67+
"default": "./dist/cjs/index.js"
68+
}
69+
},
70+
"typesVersions": {
71+
"*": {
72+
"*": [
73+
"dist/esm/index.d.ts"
74+
]
75+
}
76+
},
6077
"volta": {
6178
"extends": "../../package.json"
6279
}

packages/foundation/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ type SimulationHandlerFunctions = (
4747
export type SimulationHandlers = Record<string, SimulationHandlerFunctions>;
4848
export type {
4949
ExtendSimulationActions,
50+
ExtendSimulationActionsInput,
5051
ExtendSimulationSelectors,
52+
ExtendSimulationSelectorsInput,
5153
ExtendSimulationSchema,
54+
ExtendSimulationSchemaInput,
5255
SimulationStore,
5356
Document,
5457
};

packages/foundation/tsconfig.esm.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.dist.json",
3+
"compilerOptions": {
4+
"outDir": "dist/esm",
5+
"rootDir": "src",
6+
"target": "ESNext",
7+
"module": "ESNext"
8+
},
9+
"exclude": ["test"]
10+
}

packages/foundation/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "@frontside/tsconfig",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"noEmit": true,
6-
"declarationMap": true
5+
"noEmit": true
76
},
87
"include": ["src/**/*.ts", "test/**/*.ts"]
98
}

packages/github-api/package.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
{
22
"name": "@simulacrum/github-api-simulator",
33
"version": "0.5.3",
4-
"private": false,
54
"description": "Provides common functionality to frontend app and plugins.",
65
"license": "Apache-2.0",
6+
"bugs": {
7+
"url": "https://github.com/thefrontside/simulacrum/issues"
8+
},
79
"repository": {
810
"type": "git",
911
"url": "git+https://github.com/thefrontside/simulacrum.git",
1012
"directory": "packages/github-api"
1113
},
14+
"keywords": [
15+
"github-api",
16+
"simulation",
17+
"emulation",
18+
"mock",
19+
"mocking",
20+
"integration testing"
21+
],
1222
"files": [
1323
"README.md",
1424
"dist",
@@ -18,17 +28,17 @@
1828
],
1929
"bin": "bin/start.js",
2030
"scripts": {
21-
"lint": "echo noop",
22-
"prepack": "npm run build",
23-
"build:cjs": "tsc -build tsconfig.dist.json",
24-
"build:esm": "tsc --build tsconfig.esm.json",
25-
"build": "npm run generate && npm run build:cjs && npm run build:esm && copyfiles -f src/schema/* dist/schema",
2631
"start": "node --import=tsx ./example/start.ts",
2732
"start:bin": "node ./bin/start.js",
28-
"generate": "graphql-codegen",
2933
"test": "vitest run",
3034
"test:watch": "vitest watch",
31-
"bench": "vitest bench"
35+
"bench": "vitest bench",
36+
"lint": "echo noop",
37+
"prepack": "npm run build",
38+
"build": "npm run generate && npm run build:cjs && npm run build:esm && copyfiles -f src/schema/* dist/schema",
39+
"generate": "graphql-codegen",
40+
"build:cjs": "tsc -build tsconfig.dist.json",
41+
"build:esm": "tsc --build tsconfig.esm.json"
3242
},
3343
"dependencies": {
3444
"@faker-js/faker": "^9.3.0",
@@ -48,9 +58,9 @@
4858
"typescript": "^5.4.5"
4959
},
5060
"exports": {
61+
"development": "./src/index.ts",
5162
"import": {
5263
"types": "./dist/esm/index.d.ts",
53-
"development": "./src/index.ts",
5464
"default": "./dist/esm/index.js"
5565
},
5666
"require": {

0 commit comments

Comments
 (0)