Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pacakge): support cjs #1246

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 12 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,40 @@
},
"exports": {
".": {
"import": {
"default": "./build/entrypoints/main.js"
}
"default": "./build/entrypoints/main.js"
},
"./generator": {
"import": {
"default": "./build/entrypoints/generator.js"
}
"default": "./build/entrypoints/generator.js"
},
"./extensions/upload": {
"import": {
"default": "./build/entrypoints/extensions/upload/runtime.js"
}
"default": "./build/entrypoints/extensions/upload/runtime.js"
},
"./extensions/throws": {
"import": {
"default": "./build/entrypoints/extensions/throws/runtime.js"
}
"default": "./build/entrypoints/extensions/throws/runtime.js"
},
"./extensions/opentelemetry": {
"import": {
"default": "./build/entrypoints/extensions/opentelemetry/runtime.js"
}
"default": "./build/entrypoints/extensions/opentelemetry/runtime.js"
},
"./extensions/introspection": {
"import": {
"default": "./build/entrypoints/extensions/introspection/runtime.js"
}
"default": "./build/entrypoints/extensions/introspection/runtime.js"
},
"./extensions/schema-errors": {
"import": {
"default": "./build/entrypoints/extensions/schema-errors/runtime.js"
}
"default": "./build/entrypoints/extensions/schema-errors/runtime.js"
},
"./extensions/schema-errors/generator": {
"import": {
"default": "./build/entrypoints/extensions/schema-errors/gentime.js"
}
"default": "./build/entrypoints/extensions/schema-errors/gentime.js"
},
"./client": {
"import": {
"default": "./build/entrypoints/client.js"
}
"default": "./build/entrypoints/client.js"
},
"./schema": {
"import": {
"default": "./build/entrypoints/schema.js"
}
"default": "./build/entrypoints/schema.js"
},
"./generator-helpers/standard-scalar-types": {
"import": {
"default": "./build/entrypoints/generator-helpers/standardScalarTypes.js"
}
"default": "./build/entrypoints/generator-helpers/standardScalarTypes.js"
},
"./utilities-for-generated": {
"import": {
"default": "./build/entrypoints/utilities-for-generated.js"
}
"default": "./build/entrypoints/utilities-for-generated.js"
}
},
"files": [
Expand Down
11 changes: 8 additions & 3 deletions website/content/guides/20_getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ pnpm add graffle@next graphql

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.

1. Your `package.json` must set `type` to `module`.
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`.
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).
1. One of the following:
- Your project is using ESM (your `package.json` [`type` is set to `module`](https://nodejs.org/api/packages.html#type))
- 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).
2. _If you are using TypeScript_:
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`.
2. Your TypeScript version must be `typescript@^4.9`.
3. _If you are using React Native_:
1. [Do this](https://reactnative.dev/blog/2023/06/21/package-exports-support#enabling-package-exports-beta) to enable support for package `exports`.

## 🚀 Send Your First Document

Expand Down