@astrojs/language-server 0.8.4 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/astro.d.ts +5 -13
- package/dist/plugins/typescript/languageService.js +19 -17
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @astrojs/language-server
|
|
2
2
|
|
|
3
|
+
## 0.8.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 526d5c7: Bring back loading the user js/tsconfig.json, notably, this allow us to support aliases
|
|
8
|
+
|
|
9
|
+
## 0.8.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 897ab35: Provide vite client types to Astro files
|
|
14
|
+
|
|
15
|
+
## 0.8.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 97559b6: Removes errors with import.meta.hot
|
|
20
|
+
- 4c93d24: Prevent reading tsconfig in .astro files
|
|
21
|
+
|
|
22
|
+
## 0.8.5
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- f1f3091: Fix commenting, namespaced elements, and Fragment typings
|
|
27
|
+
|
|
3
28
|
## 0.8.4
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/astro.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
|
|
3
|
-
declare global {
|
|
4
|
-
interface ImportMeta {
|
|
5
|
-
hot: {
|
|
6
|
-
accept: Function;
|
|
7
|
-
dispose: Function;
|
|
8
|
-
};
|
|
9
|
-
env: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
type AstroRenderedHTML = string;
|
|
14
4
|
|
|
15
5
|
type AstroElement = any;
|
|
@@ -51,6 +41,8 @@ interface Astro {
|
|
|
51
41
|
slots: Record<string, true | undefined>;
|
|
52
42
|
}
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
declare
|
|
56
|
-
|
|
44
|
+
declare var Astro: Astro;
|
|
45
|
+
declare var Fragment: string;
|
|
46
|
+
|
|
47
|
+
void Astro;
|
|
48
|
+
void Fragment;
|
|
@@ -52,24 +52,31 @@ async function getLanguageServiceForPath(path, workspaceUris, docContext) {
|
|
|
52
52
|
}
|
|
53
53
|
exports.getLanguageServiceForPath = getLanguageServiceForPath;
|
|
54
54
|
async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
55
|
+
var _a, _b, _c;
|
|
55
56
|
const parseConfigHost = {
|
|
56
57
|
...ts.sys,
|
|
57
58
|
readDirectory: (path, extensions, exclude, include, depth) => {
|
|
58
59
|
return ts.sys.readDirectory(path, [...extensions, '.vue', '.svelte', '.astro', '.js', '.jsx'], exclude, include, depth);
|
|
59
60
|
},
|
|
60
61
|
};
|
|
61
|
-
let configJson = (tsconfigPath && ts.readConfigFile(tsconfigPath, ts.sys.readFile).config) ||
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
let configJson = (tsconfigPath && ts.readConfigFile(tsconfigPath, ts.sys.readFile).config) || {};
|
|
63
|
+
// If our user has types in their config but it doesn't include the types for ImportMeta, let's add them for them
|
|
64
|
+
if (((_a = configJson.compilerOptions) === null || _a === void 0 ? void 0 : _a.types) &&
|
|
65
|
+
!((_b = configJson.compilerOptions) === null || _b === void 0 ? void 0 : _b.types.includes("vite/client"))) {
|
|
66
|
+
configJson.compilerOptions.types.push("vite/client");
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
configJson.compilerOptions = Object.assign(getDefaultCompilerOptions(), configJson.compilerOptions);
|
|
69
|
+
// If the user supplied exclude, let's use theirs
|
|
70
|
+
(_c = configJson.exclude) !== null && _c !== void 0 ? _c : (configJson.exclude = getDefaultExclude());
|
|
71
|
+
// Delete include so that .astro files don't get mistakenly excluded by the user
|
|
68
72
|
delete configJson.include;
|
|
73
|
+
// Everything here will always, unconditionally, be in the resulting config, not the opposite, tricky
|
|
69
74
|
const existingCompilerOptions = {
|
|
75
|
+
// Setting strict to true for .astro files leads to a lot of unrelated errors (see language-tools#91) so we force it off for .astro files
|
|
76
|
+
strict: false,
|
|
70
77
|
jsx: ts.JsxEmit.Preserve,
|
|
71
78
|
module: ts.ModuleKind.ESNext,
|
|
72
|
-
target: ts.ScriptTarget.ESNext
|
|
79
|
+
target: ts.ScriptTarget.ESNext,
|
|
73
80
|
};
|
|
74
81
|
const project = ts.parseJsonConfigFileContent(configJson, parseConfigHost, workspaceRoot, existingCompilerOptions, (0, path_1.basename)(tsconfigPath), undefined, [
|
|
75
82
|
{ extension: '.vue', isMixedContent: true, scriptKind: ts.ScriptKind.Deferred },
|
|
@@ -149,18 +156,13 @@ async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
|
149
156
|
return doc;
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*/
|
|
155
|
-
function getDefaultJsConfig() {
|
|
156
|
-
let compilerOptions = {
|
|
159
|
+
function getDefaultCompilerOptions() {
|
|
160
|
+
return {
|
|
157
161
|
maxNodeModuleJsDepth: 2,
|
|
158
162
|
allowSyntheticDefaultImports: true,
|
|
159
|
-
allowJs: true
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
compilerOptions,
|
|
163
|
-
include: ['src'],
|
|
163
|
+
allowJs: true,
|
|
164
|
+
// By providing vite/client here, our users get proper typing on import.meta in .astro files
|
|
165
|
+
types: ["vite/client"],
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
168
|
function getDefaultExclude() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"author": "Skypack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"source-map": "^0.7.3",
|
|
25
25
|
"ts-morph": "^12.0.0",
|
|
26
|
-
"typescript": "^4.5.
|
|
26
|
+
"typescript": "^4.5.4",
|
|
27
27
|
"vscode-css-languageservice": "^5.1.1",
|
|
28
28
|
"vscode-emmet-helper": "2.1.2",
|
|
29
29
|
"vscode-html-languageservice": "^3.0.3",
|