@astrojs/language-server 0.8.7 → 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
CHANGED
|
@@ -52,17 +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
|
-
|
|
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");
|
|
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
|
|
72
|
+
delete configJson.include;
|
|
73
|
+
// Everything here will always, unconditionally, be in the resulting config, not the opposite, tricky
|
|
62
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,
|
|
63
77
|
jsx: ts.JsxEmit.Preserve,
|
|
64
78
|
module: ts.ModuleKind.ESNext,
|
|
65
|
-
target: ts.ScriptTarget.ESNext
|
|
79
|
+
target: ts.ScriptTarget.ESNext,
|
|
66
80
|
};
|
|
67
81
|
const project = ts.parseJsonConfigFileContent(configJson, parseConfigHost, workspaceRoot, existingCompilerOptions, (0, path_1.basename)(tsconfigPath), undefined, [
|
|
68
82
|
{ extension: '.vue', isMixedContent: true, scriptKind: ts.ScriptKind.Deferred },
|
|
@@ -142,17 +156,13 @@ async function createLanguageService(tsconfigPath, workspaceRoot, docContext) {
|
|
|
142
156
|
return doc;
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
159
|
+
function getDefaultCompilerOptions() {
|
|
160
|
+
return {
|
|
147
161
|
maxNodeModuleJsDepth: 2,
|
|
148
162
|
allowSyntheticDefaultImports: true,
|
|
149
163
|
allowJs: true,
|
|
150
164
|
// By providing vite/client here, our users get proper typing on import.meta in .astro files
|
|
151
|
-
types: [
|
|
152
|
-
};
|
|
153
|
-
return {
|
|
154
|
-
compilerOptions,
|
|
155
|
-
exclude: getDefaultExclude(),
|
|
165
|
+
types: ["vite/client"],
|
|
156
166
|
};
|
|
157
167
|
}
|
|
158
168
|
function getDefaultExclude() {
|