From 4e4df97bb941182abed041a60f1d6c08d0fc5c25 Mon Sep 17 00:00:00 2001 From: Josh Faigan Date: Mon, 10 Aug 2026 09:28:10 -0400 Subject: [PATCH 1/2] perf(vscode-extension): deep-import LSP types to keep the server out of the client bundle --- .changeset/tiny-cycles-arrive.md | 5 +++++ packages/vscode-extension/src/browser/extension.ts | 3 ++- .../vscode-extension/src/common/ReferencesProvider.ts | 10 ++++++---- .../vscode-extension/src/common/VsCodeFileSystem.ts | 6 +++++- packages/vscode-extension/src/common/commands.ts | 6 +++--- packages/vscode-extension/src/node/extension.ts | 3 ++- 6 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 .changeset/tiny-cycles-arrive.md diff --git a/.changeset/tiny-cycles-arrive.md b/.changeset/tiny-cycles-arrive.md new file mode 100644 index 000000000..f97968030 --- /dev/null +++ b/.changeset/tiny-cycles-arrive.md @@ -0,0 +1,5 @@ +--- +'theme-check-vscode': patch +--- + +Keep the language server out of the client bundle by deep-importing LSP types. diff --git a/packages/vscode-extension/src/browser/extension.ts b/packages/vscode-extension/src/browser/extension.ts index 074c1447b..528c659ed 100644 --- a/packages/vscode-extension/src/browser/extension.ts +++ b/packages/vscode-extension/src/browser/extension.ts @@ -1,5 +1,6 @@ /// -import { FileStat, FileTuple, path } from '@shopify/theme-check-common'; +import * as path from '@shopify/theme-check-common/dist/path'; +import type { FileStat, FileTuple } from '@shopify/theme-check-common/dist/AbstractFileSystem'; import { commands, ExtensionContext, languages, Uri, workspace } from 'vscode'; import { LanguageClient, diff --git a/packages/vscode-extension/src/common/ReferencesProvider.ts b/packages/vscode-extension/src/common/ReferencesProvider.ts index b08930701..bb262cc3f 100644 --- a/packages/vscode-extension/src/common/ReferencesProvider.ts +++ b/packages/vscode-extension/src/common/ReferencesProvider.ts @@ -1,12 +1,14 @@ -import { path } from '@shopify/theme-check-common'; +import * as path from '@shopify/theme-check-common/dist/path'; import { - AugmentedLocation, - AugmentedReference, ThemeGraphDependenciesRequest, ThemeGraphDidUpdateNotification, ThemeGraphReferenceRequest, ThemeGraphRootRequest, -} from '@shopify/theme-language-server-common'; +} from '@shopify/theme-language-server-common/dist/types'; +import type { + AugmentedLocation, + AugmentedReference, +} from '@shopify/theme-language-server-common/dist/types'; import { commands, Event, diff --git a/packages/vscode-extension/src/common/VsCodeFileSystem.ts b/packages/vscode-extension/src/common/VsCodeFileSystem.ts index 4a465e9d9..3d2764421 100644 --- a/packages/vscode-extension/src/common/VsCodeFileSystem.ts +++ b/packages/vscode-extension/src/common/VsCodeFileSystem.ts @@ -1,4 +1,8 @@ -import { AbstractFileSystem, FileTuple, FileStat } from '@shopify/theme-check-common'; +import type { + AbstractFileSystem, + FileStat, + FileTuple, +} from '@shopify/theme-check-common/dist/AbstractFileSystem'; import { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; diff --git a/packages/vscode-extension/src/common/commands.ts b/packages/vscode-extension/src/common/commands.ts index 12c5f59e7..2674eb430 100644 --- a/packages/vscode-extension/src/common/commands.ts +++ b/packages/vscode-extension/src/common/commands.ts @@ -1,9 +1,9 @@ -import { path } from '@shopify/theme-check-common'; +import * as path from '@shopify/theme-check-common/dist/path'; import { - AugmentedLocation, ThemeGraphDeadCodeRequest, ThemeGraphRootRequest, -} from '@shopify/theme-language-server-common'; +} from '@shopify/theme-language-server-common/dist/types'; +import type { AugmentedLocation } from '@shopify/theme-language-server-common/dist/types'; import { commands, Position, Range, Uri, window, workspace } from 'vscode'; import { BaseLanguageClient } from 'vscode-languageclient'; diff --git a/packages/vscode-extension/src/node/extension.ts b/packages/vscode-extension/src/node/extension.ts index 0bf9b99fc..a1a0c33ba 100644 --- a/packages/vscode-extension/src/node/extension.ts +++ b/packages/vscode-extension/src/node/extension.ts @@ -1,4 +1,5 @@ -import { FileStat, FileTuple, path as pathUtils } from '@shopify/theme-check-common'; +import * as pathUtils from '@shopify/theme-check-common/dist/path'; +import type { FileStat, FileTuple } from '@shopify/theme-check-common/dist/AbstractFileSystem'; import * as path from 'node:path'; import { commands, ExtensionContext, languages, Uri, workspace } from 'vscode'; import { From f3b7ea9fa52b30de8f6ee80e0368b823ce238604 Mon Sep 17 00:00:00 2001 From: Josh Faigan Date: Tue, 11 Aug 2026 10:23:20 -0400 Subject: [PATCH 2/2] refactor(theme-check-common): expose path and LSP types as public subpaths Replace the vscode-extension's `dist/` deep imports with root-level re-export stubs, so consumers get a supported entry point instead of reaching into build output. `@shopify/theme-check-common/path` and `@shopify/theme-language-server-common/types` re-export their `dist` modules. The extension imports values from those subpaths and takes types from the package barrels, keeping the language server out of the client bundle: browser/extension.js is 2,103,681 bytes and node/extension.js is 1,410,426 bytes, versus 6,722,159 and 6,497,684 when the same values come from a barrel. Purely additive. No package.json, tsconfig, or webpack changes, and the barrel imports behave exactly as before. --- .changeset/tiny-cycles-arrive.md | 8 +++++++- packages/theme-check-common/path.d.ts | 1 + packages/theme-check-common/path.js | 1 + packages/theme-language-server-common/types.d.ts | 1 + packages/theme-language-server-common/types.js | 1 + packages/vscode-extension/src/browser/extension.ts | 4 ++-- .../vscode-extension/src/common/ReferencesProvider.ts | 9 +++------ packages/vscode-extension/src/common/VsCodeFileSystem.ts | 6 +----- packages/vscode-extension/src/common/commands.ts | 6 +++--- packages/vscode-extension/src/node/extension.ts | 4 ++-- 10 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 packages/theme-check-common/path.d.ts create mode 100644 packages/theme-check-common/path.js create mode 100644 packages/theme-language-server-common/types.d.ts create mode 100644 packages/theme-language-server-common/types.js diff --git a/.changeset/tiny-cycles-arrive.md b/.changeset/tiny-cycles-arrive.md index f97968030..4a3b3f35a 100644 --- a/.changeset/tiny-cycles-arrive.md +++ b/.changeset/tiny-cycles-arrive.md @@ -1,5 +1,11 @@ --- +'@shopify/theme-language-server-common': minor +'@shopify/theme-check-common': minor 'theme-check-vscode': patch --- -Keep the language server out of the client bundle by deep-importing LSP types. +Add public subpath entry points for path utilities and LSP request types + +`@shopify/theme-check-common/path` and `@shopify/theme-language-server-common/types` are now public entry points. They re-export the same members as the package barrel, but importing them pulls in only that module instead of the whole package. + +The VS Code extension uses them to keep the language server out of the client bundle: `browser/extension.js` is 2.1 MB instead of 6.7 MB, and `node/extension.js` is 1.4 MB instead of 6.5 MB. The barrel imports still work exactly as before. diff --git a/packages/theme-check-common/path.d.ts b/packages/theme-check-common/path.d.ts new file mode 100644 index 000000000..cc2f65808 --- /dev/null +++ b/packages/theme-check-common/path.d.ts @@ -0,0 +1 @@ +export * from './dist/path'; diff --git a/packages/theme-check-common/path.js b/packages/theme-check-common/path.js new file mode 100644 index 000000000..886a4fcad --- /dev/null +++ b/packages/theme-check-common/path.js @@ -0,0 +1 @@ +module.exports = require('./dist/path'); diff --git a/packages/theme-language-server-common/types.d.ts b/packages/theme-language-server-common/types.d.ts new file mode 100644 index 000000000..7236c51a0 --- /dev/null +++ b/packages/theme-language-server-common/types.d.ts @@ -0,0 +1 @@ +export * from './dist/types'; diff --git a/packages/theme-language-server-common/types.js b/packages/theme-language-server-common/types.js new file mode 100644 index 000000000..d94f7183d --- /dev/null +++ b/packages/theme-language-server-common/types.js @@ -0,0 +1 @@ +module.exports = require('./dist/types'); diff --git a/packages/vscode-extension/src/browser/extension.ts b/packages/vscode-extension/src/browser/extension.ts index 528c659ed..ef4479b96 100644 --- a/packages/vscode-extension/src/browser/extension.ts +++ b/packages/vscode-extension/src/browser/extension.ts @@ -1,6 +1,6 @@ /// -import * as path from '@shopify/theme-check-common/dist/path'; -import type { FileStat, FileTuple } from '@shopify/theme-check-common/dist/AbstractFileSystem'; +import * as path from '@shopify/theme-check-common/path'; +import type { FileStat, FileTuple } from '@shopify/theme-check-common'; import { commands, ExtensionContext, languages, Uri, workspace } from 'vscode'; import { LanguageClient, diff --git a/packages/vscode-extension/src/common/ReferencesProvider.ts b/packages/vscode-extension/src/common/ReferencesProvider.ts index bb262cc3f..76bbc9508 100644 --- a/packages/vscode-extension/src/common/ReferencesProvider.ts +++ b/packages/vscode-extension/src/common/ReferencesProvider.ts @@ -1,14 +1,11 @@ -import * as path from '@shopify/theme-check-common/dist/path'; +import * as path from '@shopify/theme-check-common/path'; import { ThemeGraphDependenciesRequest, ThemeGraphDidUpdateNotification, ThemeGraphReferenceRequest, ThemeGraphRootRequest, -} from '@shopify/theme-language-server-common/dist/types'; -import type { - AugmentedLocation, - AugmentedReference, -} from '@shopify/theme-language-server-common/dist/types'; +} from '@shopify/theme-language-server-common/types'; +import type { AugmentedLocation, AugmentedReference } from '@shopify/theme-language-server-common'; import { commands, Event, diff --git a/packages/vscode-extension/src/common/VsCodeFileSystem.ts b/packages/vscode-extension/src/common/VsCodeFileSystem.ts index 3d2764421..e55e73b1f 100644 --- a/packages/vscode-extension/src/common/VsCodeFileSystem.ts +++ b/packages/vscode-extension/src/common/VsCodeFileSystem.ts @@ -1,8 +1,4 @@ -import type { - AbstractFileSystem, - FileStat, - FileTuple, -} from '@shopify/theme-check-common/dist/AbstractFileSystem'; +import type { AbstractFileSystem, FileStat, FileTuple } from '@shopify/theme-check-common'; import { Connection } from 'vscode-languageserver'; import { URI } from 'vscode-uri'; diff --git a/packages/vscode-extension/src/common/commands.ts b/packages/vscode-extension/src/common/commands.ts index 2674eb430..a2469544e 100644 --- a/packages/vscode-extension/src/common/commands.ts +++ b/packages/vscode-extension/src/common/commands.ts @@ -1,9 +1,9 @@ -import * as path from '@shopify/theme-check-common/dist/path'; +import * as path from '@shopify/theme-check-common/path'; import { ThemeGraphDeadCodeRequest, ThemeGraphRootRequest, -} from '@shopify/theme-language-server-common/dist/types'; -import type { AugmentedLocation } from '@shopify/theme-language-server-common/dist/types'; +} from '@shopify/theme-language-server-common/types'; +import type { AugmentedLocation } from '@shopify/theme-language-server-common'; import { commands, Position, Range, Uri, window, workspace } from 'vscode'; import { BaseLanguageClient } from 'vscode-languageclient'; diff --git a/packages/vscode-extension/src/node/extension.ts b/packages/vscode-extension/src/node/extension.ts index a1a0c33ba..bef002b6e 100644 --- a/packages/vscode-extension/src/node/extension.ts +++ b/packages/vscode-extension/src/node/extension.ts @@ -1,5 +1,5 @@ -import * as pathUtils from '@shopify/theme-check-common/dist/path'; -import type { FileStat, FileTuple } from '@shopify/theme-check-common/dist/AbstractFileSystem'; +import * as pathUtils from '@shopify/theme-check-common/path'; +import type { FileStat, FileTuple } from '@shopify/theme-check-common'; import * as path from 'node:path'; import { commands, ExtensionContext, languages, Uri, workspace } from 'vscode'; import {