Skip to content

Commit

Permalink
feat(pacakge): support cjs (#1246)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Nov 1, 2024
1 parent a094a80 commit f233683
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 39 deletions.
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

0 comments on commit f233683

Please sign in to comment.