@astrojs/language-server 2.1.2 → 2.1.4

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.
@@ -44,6 +44,15 @@ function getLanguageModule(astroInstall, ts) {
44
44
  resolveHost(host) {
45
45
  return {
46
46
  ...host,
47
+ resolveModuleName(moduleName, impliedNodeFormat) {
48
+ if (impliedNodeFormat === ts.ModuleKind.ESNext &&
49
+ (moduleName.endsWith('.astro') ||
50
+ moduleName.endsWith('.vue') ||
51
+ moduleName.endsWith('.svelte'))) {
52
+ return `${moduleName}.js`;
53
+ }
54
+ return host.resolveModuleName?.(moduleName, impliedNodeFormat) ?? moduleName;
55
+ },
47
56
  getScriptFileNames() {
48
57
  const fileNames = host.getScriptFileNames();
49
58
  return [
@@ -2,7 +2,10 @@ import type * as svelte from '@astrojs/svelte/dist/editor.cjs';
2
2
  import type * as vue from '@astrojs/vue/dist/editor.cjs';
3
3
  import type * as prettier from 'prettier';
4
4
  export declare function setIsTrusted(_isTrusted: boolean): void;
5
- export declare function getPackagePath(packageName: string, fromPath: string[]): string | undefined;
5
+ /**
6
+ * Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
7
+ */
8
+ export declare function getPackagePath(packageName: string, fromPath: string[], root?: boolean): string | undefined;
6
9
  export declare function importSvelteIntegration(fromPath: string): typeof svelte | undefined;
7
10
  export declare function importVueIntegration(fromPath: string): typeof vue | undefined;
8
11
  export declare function importPrettier(fromPath: string): typeof prettier | undefined;
@@ -7,13 +7,18 @@ function setIsTrusted(_isTrusted) {
7
7
  isTrusted = _isTrusted;
8
8
  }
9
9
  exports.setIsTrusted = setIsTrusted;
10
- function getPackagePath(packageName, fromPath) {
10
+ /**
11
+ * Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
12
+ */
13
+ function getPackagePath(packageName, fromPath, root = true) {
11
14
  const paths = [];
12
15
  if (isTrusted) {
13
16
  paths.unshift(...fromPath);
14
17
  }
15
18
  try {
16
- return (0, node_path_1.dirname)(require.resolve(packageName + '/package.json', { paths }));
19
+ return root
20
+ ? (0, node_path_1.dirname)(require.resolve(packageName + '/package.json', { paths }))
21
+ : require.resolve(packageName, { paths });
17
22
  }
18
23
  catch (e) {
19
24
  return undefined;
@@ -51,7 +56,7 @@ function importPrettier(fromPath) {
51
56
  }
52
57
  exports.importPrettier = importPrettier;
53
58
  function getPrettierPluginPath(fromPath) {
54
- const prettierPluginPath = getPackagePath('prettier-plugin-astro', [fromPath, __dirname]);
59
+ const prettierPluginPath = getPackagePath('prettier-plugin-astro', [fromPath, __dirname], false);
55
60
  if (!prettierPluginPath) {
56
61
  return undefined;
57
62
  }
@@ -68,8 +68,7 @@ const plugin = (initOptions, modules) => ({
68
68
  languages: ['astro'],
69
69
  ignoreIdeOptions: true,
70
70
  resolveConfigOptions: {
71
- // Prettier's cache is a bit cumbersome, because you need to reload the config yourself on change
72
- // TODO: Upstream a fix for this
71
+ // This seems to be broken since Prettier 3, and it'll always use its cumbersome cache. Hopefully it works one day.
73
72
  useCache: false,
74
73
  },
75
74
  additionalOptions: async (resolvedConfig) => {
@@ -77,7 +76,8 @@ const plugin = (initOptions, modules) => ({
77
76
  if (!prettier || !prettierPluginPath) {
78
77
  return [];
79
78
  }
80
- const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro');
79
+ const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro') ||
80
+ resolvedConfig.plugins?.includes('prettier-plugin-astro'); // getSupportInfo doesn't seems to work very well in Prettier 3 for plugins
81
81
  return hasPluginLoadedAlready ? [] : [prettierPluginPath];
82
82
  }
83
83
  const plugins = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,20 +22,20 @@
22
22
  "dependencies": {
23
23
  "@astrojs/compiler": "1.5.7",
24
24
  "@jridgewell/sourcemap-codec": "^1.4.15",
25
- "@volar/kit": "~1.9.0",
26
- "@volar/language-core": "~1.9.0",
27
- "@volar/language-server": "~1.9.0",
28
- "@volar/language-service": "~1.9.0",
29
- "@volar/source-map": "~1.9.0",
30
- "@volar/typescript": "~1.9.0",
25
+ "@volar/kit": "~1.10.0",
26
+ "@volar/language-core": "~1.10.0",
27
+ "@volar/language-server": "~1.10.0",
28
+ "@volar/language-service": "~1.10.0",
29
+ "@volar/source-map": "~1.10.0",
30
+ "@volar/typescript": "~1.10.0",
31
31
  "fast-glob": "^3.2.12",
32
32
  "muggle-string": "^0.3.1",
33
- "volar-service-css": "0.0.10",
34
- "volar-service-emmet": "0.0.10",
35
- "volar-service-html": "0.0.10",
36
- "volar-service-prettier": "0.0.10",
37
- "volar-service-typescript": "0.0.10",
38
- "volar-service-typescript-twoslash-queries": "0.0.10",
33
+ "volar-service-css": "0.0.11",
34
+ "volar-service-emmet": "0.0.11",
35
+ "volar-service-html": "0.0.11",
36
+ "volar-service-prettier": "0.0.11",
37
+ "volar-service-typescript": "0.0.11",
38
+ "volar-service-typescript-twoslash-queries": "0.0.11",
39
39
  "vscode-html-languageservice": "^5.0.6",
40
40
  "vscode-uri": "^3.0.7"
41
41
  },