Skip to content

Commit f613a6d

Browse files
committed
Change importModuleSpecifierEnding default to .js
Change the default value of `importModuleSpecifierEnding` from `""` to `".js"`. This makes the generated TypeScript schema file work correctly for both CommonJS and ES module projects out of the box, since `.js` extensions are valid in CJS and required in ESM. - Update configSpecRaw.json default and description - Update generated TGratsConfig.ts types - Remove now-redundant explicit `.js` setting from example tsconfigs - Set explicit `""` for next-js (uses webpack bundler resolution) - Update all test snapshots to reflect new default
1 parent 905f540 commit f613a6d

73 files changed

Lines changed: 77 additions & 88 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/apollo-server/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"grats": {
3-
"nullableByDefault": false,
4-
"importModuleSpecifierEnding": ".js"
3+
"nullableByDefault": false
54
},
65
"compilerOptions": {
76
"outDir": "dist",

examples/express-graphql-http/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"grats": {
3-
"nullableByDefault": false,
4-
"importModuleSpecifierEnding": ".js"
3+
"nullableByDefault": false
54
},
65
"compilerOptions": {
76
"outDir": "dist",

examples/incremental-migration/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"tsSchema": "./schemas/gratsGeneratedSchema.ts",
55
"graphqlSchema": "gratsSchema.graphql",
66
"tsSchemaHeader": "// DO NOT USE DIRECTLY. Prefer the merged schema in `./mergedSchema.ts`.",
7-
"schemaHeader": "# DO NOT USE DIRECTLY. Prefer the merged schema in `../schema.graphql`.",
8-
"importModuleSpecifierEnding": ".js"
7+
"schemaHeader": "# DO NOT USE DIRECTLY. Prefer the merged schema in `../schema.graphql`."
98
},
109
"compilerOptions": {
1110
"outDir": "dist",

examples/next-js/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"grats": {
33
"nullableByDefault": false,
4-
"importModuleSpecifierEnding": ".js"
4+
"importModuleSpecifierEnding": ""
55
},
66
"compilerOptions": {
77
"target": "es5",

examples/production-app/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"grats": {
3-
"importModuleSpecifierEnding": ".js"
4-
},
2+
"grats": {},
53
"compilerOptions": {
64
"outDir": "dist",
75
"module": "NodeNext",

examples/strict-semantic-nullability/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"grats": {
33
"nullableByDefault": true,
4-
"strictSemanticNullability": true,
5-
"importModuleSpecifierEnding": ".js"
4+
"strictSemanticNullability": true
65
},
76
"compilerOptions": {
87
"outDir": "dist",

examples/yoga/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"grats": {
3-
"nullableByDefault": false,
4-
"importModuleSpecifierEnding": ".js"
3+
"nullableByDefault": false
54
},
65
"compilerOptions": {
76
"outDir": "dist",

llm-docs/getting-started/configuration.md

Lines changed: 2 additions & 4 deletions

scripts/TGratsConfig.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ export type GratsConfig = {
7171
*/
7272
tsClientEnumsHeader: string | null;
7373
/**
74-
* This option allows you configure an extension that will be appended to
75-
* the end of all import paths in the generated TypeScript schema file.
76-
* When building a package that uses ES modules, import paths must not
77-
* omit the file extension. In TypeScript code this generally means import
78-
* paths must end with `.js`. If set to null, no ending will be appended.
74+
* The extension appended to the end of all import paths in the generated
75+
* TypeScript schema file. Defaults to `.js` which works for both CommonJS
76+
* and ES module projects. Set to an empty string to omit the extension.
7977
*/
8078
importModuleSpecifierEnding: string;
8179
/**

src/configSpecRaw.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
"default": "/**\n * TypeScript enum definitions generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */"
5757
},
5858
"importModuleSpecifierEnding": {
59-
"description": "This option allows you configure an extension that will be appended to the end of all import paths in the generated TypeScript schema file.\nWhen building a package that uses ES modules, import paths must not omit the file extension. In TypeScript code this generally means import paths must end with `.js`. If set to null, no ending will be appended.",
59+
"description": "The extension appended to the end of all import paths in the generated TypeScript schema file. Defaults to `.js` which works for both CommonJS and ES module projects. Set to an empty string to omit the extension.",
6060
"type": { "kind": "string" },
6161
"nullable": false,
62-
"default": ""
62+
"default": ".js"
6363
},
6464
"EXPERIMENTAL__emitMetadata": {
6565
"description": "EXPERIMENTAL: THIS OPTION WILL BE RENAMED OR REMOVED IN A FUTURE RELEASE\nEmit a JSON file alongside the generated schema file which contains the metadata containing information about the resolvers.",

0 commit comments

Comments
 (0)