Skip to content

Commit f233683

Browse files
authored
feat(pacakge): support cjs (#1246)
1 parent a094a80 commit f233683

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

package.json

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,40 @@
99
},
1010
"exports": {
1111
".": {
12-
"import": {
13-
"default": "./build/entrypoints/main.js"
14-
}
12+
"default": "./build/entrypoints/main.js"
1513
},
1614
"./generator": {
17-
"import": {
18-
"default": "./build/entrypoints/generator.js"
19-
}
15+
"default": "./build/entrypoints/generator.js"
2016
},
2117
"./extensions/upload": {
22-
"import": {
23-
"default": "./build/entrypoints/extensions/upload/runtime.js"
24-
}
18+
"default": "./build/entrypoints/extensions/upload/runtime.js"
2519
},
2620
"./extensions/throws": {
27-
"import": {
28-
"default": "./build/entrypoints/extensions/throws/runtime.js"
29-
}
21+
"default": "./build/entrypoints/extensions/throws/runtime.js"
3022
},
3123
"./extensions/opentelemetry": {
32-
"import": {
33-
"default": "./build/entrypoints/extensions/opentelemetry/runtime.js"
34-
}
24+
"default": "./build/entrypoints/extensions/opentelemetry/runtime.js"
3525
},
3626
"./extensions/introspection": {
37-
"import": {
38-
"default": "./build/entrypoints/extensions/introspection/runtime.js"
39-
}
27+
"default": "./build/entrypoints/extensions/introspection/runtime.js"
4028
},
4129
"./extensions/schema-errors": {
42-
"import": {
43-
"default": "./build/entrypoints/extensions/schema-errors/runtime.js"
44-
}
30+
"default": "./build/entrypoints/extensions/schema-errors/runtime.js"
4531
},
4632
"./extensions/schema-errors/generator": {
47-
"import": {
48-
"default": "./build/entrypoints/extensions/schema-errors/gentime.js"
49-
}
33+
"default": "./build/entrypoints/extensions/schema-errors/gentime.js"
5034
},
5135
"./client": {
52-
"import": {
53-
"default": "./build/entrypoints/client.js"
54-
}
36+
"default": "./build/entrypoints/client.js"
5537
},
5638
"./schema": {
57-
"import": {
58-
"default": "./build/entrypoints/schema.js"
59-
}
39+
"default": "./build/entrypoints/schema.js"
6040
},
6141
"./generator-helpers/standard-scalar-types": {
62-
"import": {
63-
"default": "./build/entrypoints/generator-helpers/standardScalarTypes.js"
64-
}
42+
"default": "./build/entrypoints/generator-helpers/standardScalarTypes.js"
6543
},
6644
"./utilities-for-generated": {
67-
"import": {
68-
"default": "./build/entrypoints/utilities-for-generated.js"
69-
}
45+
"default": "./build/entrypoints/utilities-for-generated.js"
7046
}
7147
},
7248
"files": [

website/content/guides/20_getting-started.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ pnpm add graffle@next graphql
5353

5454
Graffle is an [ESM only package built around package `exports`](https://github.com/graffle-js/graffle/discussions/863). This imposes a few requirements on your project configuration.
5555

56-
1. Your `package.json` must set `type` to `module`.
57-
2. If you are using TypeScript your `tsconfig.json` must set `module` and `moduleResolution` to `Node16` or `Bundler`. Otherwise TypeScript will not be able to find the types when you attempt to import entrypoints from `graffle`.
58-
3. If you are using React Native you need to [do this](https://reactnative.dev/blog/2023/06/21/package-exports-support#enabling-package-exports-beta).
56+
1. One of the following:
57+
- Your project is using ESM (your `package.json` [`type` is set to `module`](https://nodejs.org/api/packages.html#type))
58+
- Your CJS proejct uses `node@^20.17` with [`--experimental-require-module`](https://nodejs.org/api/cli.html#--experimental-require-module) or `node@^23` (where that flag is the default).
59+
2. _If you are using TypeScript_:
60+
1. If you are using TypeScript your `tsconfig.json` must set `module` and [`moduleResolution`](https://www.typescriptlang.org/tsconfig/#moduleResolution) to `Node16` or `Bundler`. Otherwise TypeScript will not be able to find the types when you attempt to import entrypoints from `graffle`.
61+
2. Your TypeScript version must be `typescript@^4.9`.
62+
3. _If you are using React Native_:
63+
1. [Do this](https://reactnative.dev/blog/2023/06/21/package-exports-support#enabling-package-exports-beta) to enable support for package `exports`.
5964

6065
## 🚀 Send Your First Document
6166

0 commit comments

Comments
 (0)