Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/tiny-cycles-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@shopify/theme-language-server-common': minor
'@shopify/theme-check-common': minor
'theme-check-vscode': patch
---

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.
1 change: 1 addition & 0 deletions packages/theme-check-common/path.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/path';
1 change: 1 addition & 0 deletions packages/theme-check-common/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/path');
1 change: 1 addition & 0 deletions packages/theme-language-server-common/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/types';
1 change: 1 addition & 0 deletions packages/theme-language-server-common/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/types');
3 changes: 2 additions & 1 deletion packages/vscode-extension/src/browser/extension.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the outcome of this PR but not a huge fan of how we're getting there. Reaching into the dist folder is creating an implicit connection to theme-check-common's build process. I'd rather fix this in theme-check-common itself by adding some public subpath exports that we intend for consumers to use.

Also side note: I don't think the type imports need this? I don't think these are included at runtime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion Gray.

Type imports - you were totally right so I put it back the way it was.

Instead of reaching into the dist folder they got moved into the packages themselves and they each have an entry point pointing to the actual file. No more weird connections.

I tried the subpath exports but I ran into a couple problems. Our TS setup falls back to the older resolution mode and it ignores exports completely. When I tried setting up the new mode if a path wasn't explicitly listed it stopped resolving. It messed up deep-imports of MockTheme and MockFileSystem`. My concern is if any user of the libraries has deep links we would probably break for them as well.

What do you think about this current method vs the subpath export?

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference lib="webworker" />
import { FileStat, FileTuple, path } from '@shopify/theme-check-common';
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,
Expand Down
7 changes: 3 additions & 4 deletions packages/vscode-extension/src/common/ReferencesProvider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { path } from '@shopify/theme-check-common';
import * as path from '@shopify/theme-check-common/path';
import {
AugmentedLocation,
AugmentedReference,
ThemeGraphDependenciesRequest,
ThemeGraphDidUpdateNotification,
ThemeGraphReferenceRequest,
ThemeGraphRootRequest,
} from '@shopify/theme-language-server-common';
} from '@shopify/theme-language-server-common/types';
import type { AugmentedLocation, AugmentedReference } from '@shopify/theme-language-server-common';
import {
commands,
Event,
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/src/common/VsCodeFileSystem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbstractFileSystem, FileTuple, FileStat } from '@shopify/theme-check-common';
import type { AbstractFileSystem, FileStat, FileTuple } from '@shopify/theme-check-common';
import { Connection } from 'vscode-languageserver';
import { URI } from 'vscode-uri';

Expand Down
6 changes: 3 additions & 3 deletions packages/vscode-extension/src/common/commands.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { path } from '@shopify/theme-check-common';
import * as path from '@shopify/theme-check-common/path';
import {
AugmentedLocation,
ThemeGraphDeadCodeRequest,
ThemeGraphRootRequest,
} from '@shopify/theme-language-server-common';
} 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';

Expand Down
3 changes: 2 additions & 1 deletion packages/vscode-extension/src/node/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FileStat, FileTuple, path as pathUtils } from '@shopify/theme-check-common';
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 {
Expand Down
Loading