diff --git a/package.json b/package.json index 4b525705..9d7d8454 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,8 @@ ], "icon": "images/icon-apollo-blue-400x400.png", "activationEvents": [ - "workspaceContains:**/apollo.config.[jt]s" + "workspaceContains:**/apollo.config.[jt]s", + "workspaceContains:**/apollo.config.cjs" ], "contributes": { "configuration": { diff --git a/src/language-server/config/loadConfig.ts b/src/language-server/config/loadConfig.ts index dd0725fb..852f51bb 100644 --- a/src/language-server/config/loadConfig.ts +++ b/src/language-server/config/loadConfig.ts @@ -22,6 +22,7 @@ const defaultFileNames = [ "package.json", `${MODULE_NAME}.config.js`, `${MODULE_NAME}.config.ts`, + `${MODULE_NAME}.config.cjs` ]; const envFileNames = [".env", ".env.local"]; @@ -29,6 +30,7 @@ const loaders = { // XXX improve types for config ".json": (cosmiconfig as any).loadJson as LoaderEntry, ".js": (cosmiconfig as any).loadJs as LoaderEntry, + ".cjs": (cosmiconfig as any).loadJs as LoaderEntry, ".ts": { async: TypeScriptLoader, }, diff --git a/src/language-server/project/base.ts b/src/language-server/project/base.ts index f57955f7..4bdf5cb0 100644 --- a/src/language-server/project/base.ts +++ b/src/language-server/project/base.ts @@ -102,7 +102,7 @@ export abstract class GraphQLProject implements GraphQLSchemaProvider { : config.service; const fileSet = new FileSet({ rootURI: this.rootURI, - includes: [...includes, ".env", "apollo.config.js"], + includes: [...includes, ".env", "apollo.config.js", "apollo.config.cjs"], // We do not want to include the local schema file in our list of documents excludes: [...excludes, ...this.getRelativeLocalSchemaFilePaths()], configURI: config.configURI, diff --git a/src/language-server/server.ts b/src/language-server/server.ts index b68ed081..f912b718 100644 --- a/src/language-server/server.ts +++ b/src/language-server/server.ts @@ -132,7 +132,7 @@ documents.onDidChangeContent( connection.onDidChangeWatchedFiles((params) => { for (const { uri, type } of params.changes) { - if (uri.endsWith("apollo.config.js") || uri.endsWith(".env")) { + if (uri.endsWith("apollo.config.js") || uri.endsWith("apollo.config.cjs") || uri.endsWith(".env")) { workspace.reloadProjectForConfig(uri); } diff --git a/src/language-server/workspace.ts b/src/language-server/workspace.ts index a972fff5..e6e25ff9 100644 --- a/src/language-server/workspace.ts +++ b/src/language-server/workspace.ts @@ -114,7 +114,7 @@ export class GraphQLWorkspace { -- ~/:user/server (GraphQLProject) as WorkspaceFolder */ - const apolloConfigFiles: string[] = fg.sync("**/apollo.config.@(js|ts)", { + const apolloConfigFiles: string[] = fg.sync("**/apollo.config.@(js|ts|cjs)", { cwd: URI.parse(folder.uri).fsPath, absolute: true, ignore: "**/node_modules/**",