Skip to content

Commit

Permalink
breaking: vs code / language-server major (#2475)
Browse files Browse the repository at this point in the history
- use Svelte 4 as built-in version now
- add exports map
- bump vs code ls/client version to 9
- require Node 18 / VS Code 1.82 minimum
- drive-by fix of __sveltets_2_ensureComponent (the previous version didn't work after all)
  • Loading branch information
dummdidumm authored Aug 27, 2024
1 parent 89a1532 commit 53856cc
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 144 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
"prettier": "~3.2.5",
"prettier": "~3.3.3",
"ts-node": "^10.0.0"
},
"packageManager": "[email protected]"
Expand Down
25 changes: 14 additions & 11 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "svelte-language-server",
"version": "0.16.0",
"version": "0.17.0",
"description": "A language server for Svelte",
"main": "dist/src/index.js",
"typings": "dist/src/index",
"exports": {
"./package.json": "./package.json",
".": "./dist/src/index.js"
},
"scripts": {
"test": "cross-env TS_NODE_TRANSPILE_ONLY=true mocha --require ts-node/register \"test/**/*.ts\" --exclude \"test/**/*.d.ts\"",
"build": "tsc",
Expand Down Expand Up @@ -31,38 +35,37 @@
},
"homepage": "https://github.com/sveltejs/language-tools#readme",
"engines": {
"node": ">= 12.0.0"
"node": ">= 18.0.0"
},
"devDependencies": {
"@types/estree": "^0.0.42",
"@types/lodash": "^4.14.116",
"@types/mocha": "^9.1.0",
"@types/node": "^16.0.0",
"@types/prettier": "^2.2.3",
"@types/node": "^18.0.0",
"@types/sinon": "^7.5.2",
"cross-env": "^7.0.2",
"mocha": "^9.2.0",
"sinon": "^11.0.0",
"ts-node": "^10.0.0"
},
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.17",
"@jridgewell/trace-mapping": "^0.3.25",
"@vscode/emmet-helper": "2.8.4",
"chokidar": "^3.4.1",
"estree-walker": "^2.0.1",
"fdir": "^6.2.0",
"lodash": "^4.17.21",
"prettier": "~3.2.5",
"prettier-plugin-svelte": "^3.2.2",
"svelte": "^3.57.0",
"prettier": "~3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "^4.2.19",
"svelte2tsx": "workspace:~",
"typescript": "^5.5.2",
"typescript-auto-import-cache": "^0.3.3",
"vscode-css-languageservice": "~6.3.0",
"vscode-html-languageservice": "~5.3.0",
"vscode-languageserver": "8.0.2",
"vscode-languageserver-protocol": "3.17.2",
"vscode-languageserver-types": "3.17.2",
"vscode-languageserver": "9.0.1",
"vscode-languageserver-protocol": "3.17.5",
"vscode-languageserver-types": "3.17.5",
"vscode-uri": "~3.0.0"
}
}
8 changes: 0 additions & 8 deletions packages/language-server/src/importPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ export function importSvelte(fromPath: string): typeof svelte {
Logger.debug('Using Svelte v' + pkg.version.full, 'from', main);
if (pkg.version.major === 4) {
return dynamicRequire(main + '.cjs');
} else if (pkg.version.major === 5) {
// TODO remove once Svelte 5 is released
// (we switched from compiler.cjs to compiler/index.js at some point)
try {
return dynamicRequire(main);
} catch (e) {
return dynamicRequire(main + '.cjs');
}
} else {
return dynamicRequire(main);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class CallHierarchyProviderImpl implements CallHierarchyProvider {
.provideCallHierarchyOutgoingCalls(filePath, offset)
.concat(
isComponentModulePosition
? this.getOutgoingCallsForComponent(program, filePath) ?? []
? (this.getOutgoingCallsForComponent(program, filePath) ?? [])
: []
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ export class CodeActionsProviderImpl implements CodeActionsProvider {

const position = inModuleScript
? originalRange.start
: this.fixPropsCodeActionRange(originalRange.start, document) ?? originalRange.start;
: (this.fixPropsCodeActionRange(originalRange.start, document) ?? originalRange.start);

// fix the length of trailing indent
const linesOfNewText = edit.newText.split('\n');
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"node": ">= 18.0.0"
},
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.17",
"@jridgewell/trace-mapping": "^0.3.25",
"chokidar": "^3.4.1",
"fdir": "^6.2.0",
"picocolors": "^1.0.0",
Expand All @@ -52,7 +52,7 @@
"rollup": "3.7.5",
"rollup-plugin-cleanup": "^3.2.0",
"rollup-plugin-copy": "^3.4.0",
"svelte": "^3.57.0",
"svelte": "^4.2.19",
"svelte-language-server": "workspace:*",
"typescript": "^5.5.2",
"vscode-languageserver": "8.0.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"Formatters"
],
"engines": {
"vscode": "^1.67.0"
"vscode": "^1.82.0"
},
"activationEvents": [
"onLanguage:svelte",
Expand Down Expand Up @@ -718,7 +718,7 @@
},
"devDependencies": {
"@types/lodash": "^4.14.116",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/vscode": "^1.67",
"js-yaml": "^3.14.0",
"tslib": "^2.4.0",
Expand All @@ -729,7 +729,7 @@
"lodash": "^4.17.21",
"svelte-language-server": "workspace:*",
"typescript-svelte-plugin": "workspace:*",
"vscode-languageclient": "^8.0.0",
"vscode-languageserver-protocol": "3.17.2"
"vscode-languageclient": "^9.0.1",
"vscode-languageserver-protocol": "3.17.5"
}
}
2 changes: 1 addition & 1 deletion packages/svelte-vscode/src/html/autoClose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function activateTagClosing(
updateEnabledState();
window.onDidChangeActiveTextEditor(updateEnabledState, null, disposables);

let timeout: NodeJS.Timer | undefined = void 0;
let timeout: NodeJS.Timeout | undefined = void 0;

function updateEnabledState() {
isEnabled = false;
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte2tsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"module": "index.mjs",
"types": "index.d.ts",
"devDependencies": {
"@jridgewell/sourcemap-codec": "^1.4.14",
"@jridgewell/trace-mapping": "^0.3.17",
"@jridgewell/sourcemap-codec": "^1.5.0",
"@jridgewell/trace-mapping": "^0.3.25",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^10.0.0",
"@types/estree": "^0.0.42",
"@types/mocha": "^9.1.0",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/unist": "^2.0.3",
"@types/vfile": "^3.0.2",
"builtin-modules": "^3.3.0",
Expand All @@ -37,7 +37,7 @@
"rollup": "3.7.5",
"rollup-plugin-delete": "^2.0.0",
"source-map-support": "^0.5.16",
"svelte": "~3.57.0",
"svelte": "~4.2.19",
"tiny-glob": "^0.2.6",
"tslib": "^2.4.0",
"typescript": "^5.5.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte2tsx/src/htmlxtojsx_v2/utils/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function rangeWithTrailingPropertyAccess(
* Get the end of the node, excluding the type annotation
*/
export function getEnd(node: any) {
return isTypescriptNode(node) ? node.expression.end : node.typeAnnotation?.start ?? node.end;
return isTypescriptNode(node) ? node.expression.end : (node.typeAnnotation?.start ?? node.end);
}

export function isTypescriptNode(node: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte2tsx/svelte-shims-v4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ declare type ATypedSvelteComponent = {
declare type ConstructorOfATypedSvelteComponent = new (args: {target: any, props?: any}) => ATypedSvelteComponent
declare function __sveltets_2_ensureComponent<
// @ts-ignore svelte.Component doesn't exist in Svelte 4
T extends ConstructorOfATypedSvelteComponent | (0 extends (1 & import('svelte').Component) ? never : import('svelte').Component<any, any, any>) | null | undefined
T extends ConstructorOfATypedSvelteComponent | (typeof import('svelte') extends { mount: any } ? import('svelte').Component<any, any, any> : never) | null | undefined
// @ts-ignore svelte.Component doesn't exist in Svelte 4
>(type: T): NonNullable<T extends ConstructorOfATypedSvelteComponent ? T : 0 extends (1 & import('svelte').Component) ? T : T extends import('svelte').Component<infer Props> ? typeof import('svelte').SvelteComponent<Props, Props['$$events'], Props['$$slots']> : T>;
>(type: T): NonNullable<T extends ConstructorOfATypedSvelteComponent ? T : typeof import('svelte') extends { mount: any } ? T extends import('svelte').Component<infer Props> ? typeof import('svelte').SvelteComponent<Props, Props['$$events'], Props['$$slots']> : T : T>;
declare function __sveltets_2_ensureArray<T extends ArrayLike<unknown> | Iterable<unknown>>(array: T): T extends ArrayLike<infer U> ? U[] : T extends Iterable<infer U> ? Iterable<U> : any[];

type __sveltets_2_PropsWithChildren<Props, Slots> = Props &
Expand Down
6 changes: 3 additions & 3 deletions packages/typescript-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"author": "The Svelte Community",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"typescript": "^5.5.2",
"svelte": "^3.57.0"
"svelte": "^4.2.19"
},
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.14",
"@jridgewell/sourcemap-codec": "^1.5.0",
"svelte2tsx": "workspace:~"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function decorateCallHierarchy(
return provideCallHierarchyOutgoingCalls(fileName, offset)
.concat(
program && sourceFile && isComponentModulePosition(fileName, position)
? getOutgoingCallsForComponent(program, sourceFile) ?? []
? (getOutgoingCallsForComponent(program, sourceFile) ?? [])
: []
)
.map((item): ts.CallHierarchyOutgoingCall | null => {
Expand Down
Loading

0 comments on commit 53856cc

Please sign in to comment.