Skip to content

Commit 2350dfa

Browse files
authored
(fix) (chore) bump rollup, fix estree-types (#630)
- bump rollup versions for svelte2tsx - that way, estree-types no longer differ between packages. Fix resulting type errors.
1 parent 1c2bd73 commit 2350dfa

File tree

8 files changed

+190
-196
lines changed

8 files changed

+190
-196
lines changed

packages/language-server/src/plugins/svelte/features/getCodeActions/getQuickfixes.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ import { mapObjWithRangeToOriginal, offsetAt, positionAt } from '../../../../lib
1515
import { pathToUrl } from '../../../../utils';
1616
import { SvelteDocument } from '../../SvelteDocument';
1717
import ts from 'typescript';
18-
// There are multiple estree-walker versions in the monorepo.
19-
// The newer versions don't have start/end in their public interface,
20-
// but the AST returned by svelte/compiler does.
21-
// To get the Node type right in both dev and prod environment,
22-
// declaring the Node type like this is necessary. Once
23-
// all depend on the same estree(-walker) version, this should be revisited.
18+
// estree does not have start/end in their public Node interface,
19+
// but the AST returned by svelte/compiler does. Type as any as a workaround.
2420
type Node = any;
2521

2622
/**

packages/language-server/src/plugins/svelte/features/getSelectionRanges.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { Position, SelectionRange } from 'vscode-languageserver';
33
import { isInTag, mapSelectionRangeToParent, offsetAt, toRange } from '../../../lib/documents';
44
import { SvelteDocument } from '../SvelteDocument';
55

6+
// estree does not have start/end in their public Node interface,
7+
// but the AST returned by svelte/compiler does. Type as any as a workaround.
8+
type Node = any;
9+
610
type OffsetRange = {
711
start: number;
812
end: number;
@@ -29,7 +33,7 @@ export async function getSelectionRange(svelteDoc: SvelteDocument, position: Pos
2933
let result: SelectionRange | undefined;
3034

3135
walk(html, {
32-
enter(node, parent) {
36+
enter(node: Node, parent: Node) {
3337
if (!parent) {
3438
// keep looking
3539
return;

packages/svelte2tsx/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"magic-string": "^0.25.7",
2525
"mocha": "^6.2.2",
2626
"periscopic": "^2.0.2",
27-
"rollup": "^1.12.0",
28-
"rollup-plugin-commonjs": "^10.0.0",
29-
"rollup-plugin-delete": "^1.1.0",
30-
"rollup-plugin-json": "^4.0.0",
31-
"rollup-plugin-node-resolve": "^5.2.0",
32-
"rollup-plugin-typescript": "^1.0.1",
27+
"rollup": "^2.28.0",
28+
"@rollup/plugin-commonjs": "^15.0.0",
29+
"rollup-plugin-delete": "^2.0.0",
30+
"@rollup/plugin-json": "^4.0.0",
31+
"@rollup/plugin-node-resolve": "^9.0.0",
32+
"@rollup/plugin-typescript": "^6.0.0",
3333
"source-map": "^0.6.1",
3434
"source-map-support": "^0.5.16",
3535
"svelte": "3.28.0",

packages/svelte2tsx/rollup.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import typescript from 'rollup-plugin-typescript';
2-
import commonjs from 'rollup-plugin-commonjs';
3-
import resolve from 'rollup-plugin-node-resolve';
4-
import json from 'rollup-plugin-json';
1+
import typescript from '@rollup/plugin-typescript';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import json from '@rollup/plugin-json';
55
import builtins from 'builtin-modules';
66

77
export default [
@@ -22,7 +22,7 @@ export default [
2222
resolve({ browser: false, preferBuiltins: true }),
2323
commonjs(),
2424
json(),
25-
typescript()
25+
typescript({ include: ['src/**/*'] })
2626
],
2727
watch: {
2828
clearScreen: false

packages/svelte2tsx/rollup.config.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import typescript from 'rollup-plugin-typescript';
2-
import commonjs from 'rollup-plugin-commonjs';
3-
import resolve from 'rollup-plugin-node-resolve';
4-
import json from 'rollup-plugin-json';
1+
import typescript from '@rollup/plugin-typescript';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import json from '@rollup/plugin-json';
55
import del from 'rollup-plugin-delete';
66
import builtins from 'builtin-modules';
77

@@ -18,7 +18,7 @@ export default [
1818
resolve({ browser: false, preferBuiltins: true }),
1919
commonjs(),
2020
json(),
21-
typescript()
21+
typescript({ include: ['src/**/*'] })
2222
],
2323
external: [...builtins, 'typescript', 'svelte', 'svelte/compiler', 'magic-string']
2424
},
@@ -34,7 +34,7 @@ export default [
3434
resolve({ browser: false, preferBuiltins: true }),
3535
commonjs(),
3636
json(),
37-
typescript()
37+
typescript({ include: ['src/**/*'] })
3838
],
3939
external: [...builtins, 'typescript', 'svelte', 'svelte/compiler', 'magic-string']
4040
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { BaseNode } from 'estree';
2+
3+
// estree does not have start/end in their public Node interface,
4+
// but the AST returned by svelte/compiler does.
5+
// We add the those properties here and add Node as an interface
6+
// to both estree and estree-walker.
7+
8+
declare module 'estree-walker' {
9+
export interface Node extends BaseNode {
10+
start: number;
11+
end: number;
12+
[propName: string]: any;
13+
}
14+
}
15+
16+
declare module 'estree' {
17+
export interface BaseNode {
18+
start: number;
19+
end: number;
20+
[propName: string]: any;
21+
}
22+
}

packages/svelte2tsx/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"paths": {
2323
"@/*": ["src/*"]
2424
},
25-
"include": [],
25+
// "include" is set in rollup.config(.test).js
2626
"exclude": ["node_modules"]
2727
}

0 commit comments

Comments
 (0)