Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid downstream need node polyfill for browser #70

Merged
merged 2 commits into from Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -11,7 +11,6 @@
"test": "vitest run"
},
"devDependencies": {
"@types/node": "latest",
"typescript": "latest",
"vite": "latest",
"vitest": "latest"
Expand Down
3 changes: 3 additions & 0 deletions packages/kit/package.json
Expand Up @@ -18,6 +18,9 @@
"vscode-languageserver-textdocument": "^1.0.11",
"vscode-uri": "^3.0.8"
},
"devDependencies": {
"@types/node": "latest"
},
"peerDependencies": {
"typescript": "*"
}
Expand Down
1 change: 1 addition & 0 deletions packages/labs/package.json
Expand Up @@ -81,6 +81,7 @@
"size": "npm run prepack -- --metafile && esbuild-visualizer --metadata ./meta.json && open ./stats.html"
},
"devDependencies": {
"@types/node": "latest",
"@types/vscode": "^1.82.0",
"@volar/language-server": "1.10.6",
"@volar/source-map": "1.10.6",
Expand Down
@@ -1,4 +1,3 @@
import { posix as path } from 'path';
import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import { notEmpty } from '../utils/common';
Expand Down Expand Up @@ -187,7 +186,9 @@ export function register(context: ServiceContext) {
const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(notEmpty);
const vueItem: vscode.CallHierarchyItem = {
...tsItem,
name: tsItem.name === path.basename(context.env.uriToFileName(map.virtualFileDocument.uri)) ? path.basename(context.env.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name,
name: tsItem.name === map.virtualFileDocument.uri.substring(map.virtualFileDocument.uri.lastIndexOf('/') + 1)
? map.sourceFileDocument.uri.substring(map.sourceFileDocument.uri.lastIndexOf('/') + 1)
: tsItem.name,
uri: map.sourceFileDocument.uri,
// TS Bug: `range: range` not works
range: {
Expand Down
4 changes: 2 additions & 2 deletions packages/monaco/src/editor.ts
Expand Up @@ -58,7 +58,7 @@ export namespace editor {
return;
}

let timer: NodeJS.Timeout | undefined;
let timer: number | undefined;
const changeSubscription = model.onDidChangeContent(() => {
clearTimeout(timer);
timer = setTimeout(() => doValidation(model), 250);
Expand Down Expand Up @@ -122,7 +122,7 @@ export namespace editor {
const disposables: IDisposable[] = [];
const listener = new Map<_editor.IModel, IDisposable>();

let timeout: NodeJS.Timeout | undefined;
let timeout: number | undefined;

disposables.push(
editor.onDidCreateModel((model) => hostingAutoInsertion(model)),
Expand Down
4 changes: 3 additions & 1 deletion packages/typescript/package.json
Expand Up @@ -13,9 +13,11 @@
"directory": "packages/typescript"
},
"dependencies": {
"@volar/language-core": "1.10.6"
"@volar/language-core": "1.10.6",
"path-browserify": "^1.0.1"
},
"devDependencies": {
"@types/path-browserify": "^1.0.1",
"@volar/language-service": "1.10.6"
}
}
2 changes: 1 addition & 1 deletion packages/typescript/src/languageServiceHost.ts
@@ -1,6 +1,6 @@
import type { FileKind, VirtualFile, LanguageContext } from '@volar/language-core';
import type * as ts from 'typescript/lib/tsserverlibrary';
import { posix as path } from 'path';
import * as path from 'path-browserify';
import { matchFiles } from './typescript/utilities';

const fileVersions = new Map<string, { lastVersion: number; snapshotVersions: WeakMap<ts.IScriptSnapshot, number>; }>();
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript/src/sys.ts
@@ -1,6 +1,6 @@
import type { FileChangeType, FileType, ServiceEnvironment, Disposable, FileStat } from '@volar/language-service';
import type * as ts from 'typescript/lib/tsserverlibrary';
import { posix as path } from 'path';
import * as path from 'path-browserify';
import { matchFiles } from './typescript/utilities';

interface File {
Expand Down Expand Up @@ -109,6 +109,7 @@ export function createSys(
if (sys.directoryExists(rootPath)) {
// https://github.com/vuejs/language-tools/issues/2480
try {
// @ts-expect-error
process.chdir(rootPath);
} catch { }
}
Expand Down
1 change: 1 addition & 0 deletions packages/typescript/src/typescript/corePublic.ts
Expand Up @@ -116,6 +116,7 @@ namespace NativeCollections {
declare const self: any;

const globals = typeof globalThis !== "undefined" ? globalThis :
// @ts-expect-error node global
typeof global !== "undefined" ? global :
typeof self !== "undefined" ? self :
undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/vscode/package.json
Expand Up @@ -18,6 +18,7 @@
"vscode-nls": "^5.2.0"
},
"devDependencies": {
"@types/node": "latest",
"@types/vscode": "^1.82.0",
"vscode-languageclient": "^9.0.1"
},
Expand Down
27 changes: 24 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.