diff --git a/packages/vscode-graphql-execution/esbuild.js b/packages/vscode-graphql-execution/esbuild.js index f8f641cd372..811589660cb 100644 --- a/packages/vscode-graphql-execution/esbuild.js +++ b/packages/vscode-graphql-execution/esbuild.js @@ -11,7 +11,42 @@ build({ minify: arg === '--minify', platform: 'node', outdir: 'out/', - external: ['vscode', 'ts-node', 'tslib'], + external: [ + 'squirrelly', + 'teacup', + 'coffee-script', + 'marko', + 'slm', + 'vash', + 'plates', + 'babel-core', + 'htmling', + 'ractive', + 'mote', + 'eco', + 'jqtpl', + 'hamljs', + 'jazz', + 'hamlet', + 'whiskers', + 'haml-coffee', + 'hogan.js', + 'templayed', + 'walrus', + 'mustache', + 'just', + 'ect', + 'toffee', + 'twing', + 'dot', + 'bracket-template', + 'vscode', + 'velocityjs', + 'dustjs-linkedin', + 'atpl', + 'liquor', + 'twig', + ], format: 'cjs', sourcemap: true, watch: isWatchMode, diff --git a/packages/vscode-graphql-execution/package.json b/packages/vscode-graphql-execution/package.json index 511c3eefb14..04da5c546ee 100644 --- a/packages/vscode-graphql-execution/package.json +++ b/packages/vscode-graphql-execution/package.json @@ -25,14 +25,13 @@ "Programming Languages" ], "activationEvents": [ + "onCommand:vscode-graphql-execution.contentProvider.isDebugging", + "onCommand:vscode-graphql-execution.contentProvider.contentProvider", + "onLanguage:graphql", "workspaceContains:**/.graphqlrc", - "workspaceContains:**/.graphqlconfig", "workspaceContains:**/.graphqlrc.{json,yaml,yml,js,ts,toml}", "workspaceContains:**/graphql.config.{json,yaml,yml,js,ts,toml}", - "workspaceContains:**/package.json", - "onCommand:vscode-graphql-execution.isDebugging", - "onCommand:vscode-graphql-execution.contentProvider", - "onLanguage:graphql" + "workspaceContains:**/package.json" ], "contributes": { "commands": [ @@ -84,7 +83,8 @@ }, "homepage": "https://github.com/graphql/graphiql/blob/main/packages/vscode-graphql-execution/README.md", "scripts": { - "vsce:package": "vsce package --yarn", + "compile": "node esbuild.js", + "vsce:package": "yarn compile && vsce package --yarn", "vsce:prepublish": "npm run vsce:package", "vsce:publish": "vsce publish --yarn", "open-vsx:publish": "ovsx publish --yarn -i . --pat $OVSX_PAT", @@ -113,19 +113,5 @@ "graphql": "16.6.0", "nullthrows": "1.1.1", "@graphql-tools/code-file-loader": "8.0.1" - }, - "workspaces": { - "nohoist": [ - "graphql", - "graphql-config", - "dotenv", - "graphql-ws", - "graphql-tag", - "@urql/core", - "ws", - "nullthrows", - "capitalize", - "@whatwg-node/fetch" - ] } } diff --git a/packages/vscode-graphql-execution/src/extension.ts b/packages/vscode-graphql-execution/src/extension.ts index c0c4f4bd2d8..ef2d87a6019 100644 --- a/packages/vscode-graphql-execution/src/extension.ts +++ b/packages/vscode-graphql-execution/src/extension.ts @@ -63,7 +63,7 @@ export function activate(context: ExtensionContext) { registerCodeLens(); // } - // let commandContentProvider: Disposable; + let commandContentProvider: GraphQLContentProvider; const registerContentProvider = () => { return commands.registerCommand( @@ -78,7 +78,7 @@ export function activate(context: ExtensionContext) { {}, ); - const contentProvider = new GraphQLContentProvider( + commandContentProvider = new GraphQLContentProvider( uri, outputChannel, literal, @@ -86,10 +86,10 @@ export function activate(context: ExtensionContext) { ); const registration = workspace.registerTextDocumentContentProvider( 'graphql', - contentProvider, + commandContentProvider, ); context.subscriptions.push(registration); - panel.webview.html = contentProvider.getCurrentHtml(); + panel.webview.html = commandContentProvider.getCurrentHtml(); }, ); }; @@ -104,14 +104,11 @@ export function activate(context: ExtensionContext) { // // } // }); workspace.onDidSaveTextDocument(async e => { - await window.showErrorMessage('saved'); if ( e.fileName.includes('graphql.config') || e.fileName.includes('graphqlrc') ) { - provider.dispose(); - const newProvider = registerContentProvider(); - context.subscriptions.push(newProvider); + await commandContentProvider.loadConfig(); } }); } diff --git a/packages/vscode-graphql-execution/src/providers/exec-content.ts b/packages/vscode-graphql-execution/src/providers/exec-content.ts index a3405298635..44015a53787 100644 --- a/packages/vscode-graphql-execution/src/providers/exec-content.ts +++ b/packages/vscode-graphql-execution/src/providers/exec-content.ts @@ -14,7 +14,10 @@ import { loadConfig, GraphQLProjectConfig } from 'graphql-config'; import { visit, VariableDefinitionNode } from 'graphql'; import { NetworkHelper } from '../helpers/network'; import { SourceHelper, GraphQLScalarTSType } from '../helpers/source'; -import { LanguageServiceExecutionExtension } from '../helpers/extensions'; +import { + LanguageServiceExecutionExtension, + EndpointsExtension, +} from '../helpers/extensions'; import type { Endpoint, Endpoints } from '../helpers/extensions'; import type { ExtractedTemplateLiteral } from '../helpers/source'; @@ -255,7 +258,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider { throwOnEmpty: false, throwOnMissing: false, legacy: true, - extensions: [LanguageServiceExecutionExtension], + extensions: [LanguageServiceExecutionExtension, EndpointsExtension], }); this._projectConfig = config?.getProjectForFile(literal.uri);