Skip to content

Commit 32ea9f1

Browse files
authored
fix: temporarily disable astro parsing again (#3652)
1 parent 1896e38 commit 32ea9f1

File tree

6 files changed

+105
-71
lines changed

6 files changed

+105
-71
lines changed

.changeset/ten-mangos-judge.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"graphql-language-service-server": patch
3+
"graphql-language-service-cli": patch
4+
"vscode-graphql": patch
5+
---
6+
7+
Temporarily disable astro support again because of bundling issues

packages/graphql-language-service-server/src/__tests__/findGraphQLTags.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ export function Example(arg: string) {}`;
559559
const contents = findGraphQLTags(text, '.svelte');
560560
expect(contents.length).toEqual(1);
561561
});
562-
it('handles full astro example', () => {
562+
// eslint-disable-next-line jest/no-disabled-tests
563+
it.skip('handles full astro example', () => {
563564
const text = `
564565
---
565566
const gql = String.raw;

packages/graphql-language-service-server/src/constants.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ export const DEFAULT_SUPPORTED_EXTENSIONS = [
5454
'.tsx',
5555
'.vue',
5656
'.svelte',
57-
'.astro',
57+
// '.astro',
5858
'.cts',
5959
'.mts',
6060
] as const;
61+
6162
export type SupportedExtensions = typeof DEFAULT_SUPPORTED_EXTENSIONS;
6263
export type SupportedExtensionsEnum =
6364
(typeof DEFAULT_SUPPORTED_EXTENSIONS)[number];

packages/graphql-language-service-server/src/findGraphQLTags.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Position, Range } from 'graphql-language-service';
1818
import { TAG_MAP } from './constants';
1919
import { ecmaParser, tsParser } from './parsers/babel';
2020
import { vueParser } from './parsers/vue';
21-
import { astroParser } from './parsers/astro';
21+
// import { astroParser } from './parsers/astro';
2222
import type { Logger, NoopLogger } from './Logger';
2323
import { RangeMapper } from './parsers/types';
2424
import { svelteParser } from './parsers/svelte';
@@ -43,7 +43,7 @@ const parserMap = {
4343
'.mts': tsParser,
4444
'.svelte': svelteParser,
4545
'.vue': vueParser,
46-
'.astro': astroParser,
46+
// '.astro': astroParser,
4747
};
4848

4949
export function findGraphQLTags(
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
import { Position, Range } from 'graphql-language-service';
2-
import { RangeMapper, SourceParser } from './types';
3-
import { babelParser } from './babel';
4-
import { parse } from 'astrojs-compiler-sync';
1+
// import { Position, Range } from 'graphql-language-service';
2+
// import { RangeMapper, SourceParser } from './types';
3+
// import { babelParser } from './babel';
4+
// import { parse } from 'astrojs-compiler-sync';
55

6-
// import { teardown } from '@astrojs/compiler/dist/node';
6+
// // import { teardown } from '@astrojs/compiler/dist/node';
77

8-
type ParseAstroResult =
9-
| { type: 'error'; errors: string[] }
10-
| {
11-
type: 'ok';
12-
scriptOffset: number;
13-
scriptAst: any[];
14-
};
8+
// type ParseAstroResult =
9+
// | { type: 'error'; errors: string[] }
10+
// | {
11+
// type: 'ok';
12+
// scriptOffset: number;
13+
// scriptAst: any[];
14+
// };
1515

16-
function parseAstro(source: string): ParseAstroResult {
17-
// eslint-disable-next-line unicorn/no-useless-undefined
18-
const { ast, diagnostics } = parse(source, undefined);
16+
// function parseAstro(source: string): ParseAstroResult {
17+
// // eslint-disable-next-line unicorn/no-useless-undefined
18+
// const { ast, diagnostics } = parse(source, undefined);
1919

20-
if (diagnostics.some(d => d.severity === /* Error */ 1)) {
21-
return {
22-
type: 'error',
23-
errors: diagnostics.map(d => JSON.stringify(d)),
24-
};
25-
}
20+
// if (diagnostics.some(d => d.severity === /* Error */ 1)) {
21+
// return {
22+
// type: 'error',
23+
// errors: diagnostics.map(d => JSON.stringify(d)),
24+
// };
25+
// }
2626

27-
for (const node of ast.children) {
28-
if (node.type === 'frontmatter') {
29-
try {
30-
return {
31-
type: 'ok',
32-
scriptOffset: (node.position?.start.line ?? 1) - 1,
33-
scriptAst: [babelParser(node.value, ['typescript'])],
34-
};
35-
} catch (error) {
36-
return {
37-
type: 'error',
38-
errors: [String(error)],
39-
};
40-
}
41-
}
42-
}
27+
// for (const node of ast.children) {
28+
// if (node.type === 'frontmatter') {
29+
// try {
30+
// return {
31+
// type: 'ok',
32+
// scriptOffset: (node.position?.start.line ?? 1) - 1,
33+
// scriptAst: [babelParser(node.value, ['typescript'])],
34+
// };
35+
// } catch (error) {
36+
// return {
37+
// type: 'error',
38+
// errors: [String(error)],
39+
// };
40+
// }
41+
// }
42+
// }
4343

44-
return { type: 'error', errors: ['Could not find frontmatter block'] };
45-
}
44+
// return { type: 'error', errors: ['Could not find frontmatter block'] };
45+
// }
4646

47-
export const astroParser: SourceParser = (text, uri, logger) => {
48-
const parseAstroResult = parseAstro(text);
49-
if (parseAstroResult.type === 'error') {
50-
logger.info(
51-
`Could not parse the astro file at ${uri} to extract the graphql tags:`,
52-
);
53-
for (const error of parseAstroResult.errors) {
54-
logger.info(String(error));
55-
}
56-
return null;
57-
}
47+
// export const astroParser: SourceParser = (text, uri, logger) => {
48+
// const parseAstroResult = parseAstro(text);
49+
// if (parseAstroResult.type === 'error') {
50+
// logger.info(
51+
// `Could not parse the astro file at ${uri} to extract the graphql tags:`,
52+
// );
53+
// for (const error of parseAstroResult.errors) {
54+
// logger.info(String(error));
55+
// }
56+
// return null;
57+
// }
5858

59-
const rangeMapper: RangeMapper = range => {
60-
return new Range(
61-
new Position(
62-
range.start.line + parseAstroResult.scriptOffset,
63-
range.start.character,
64-
),
65-
new Position(
66-
range.end.line + parseAstroResult.scriptOffset,
67-
range.end.character,
68-
),
69-
);
70-
};
71-
return { asts: parseAstroResult.scriptAst, rangeMapper };
72-
};
59+
// const rangeMapper: RangeMapper = range => {
60+
// return new Range(
61+
// new Position(
62+
// range.start.line + parseAstroResult.scriptOffset,
63+
// range.start.character,
64+
// ),
65+
// new Position(
66+
// range.end.line + parseAstroResult.scriptOffset,
67+
// range.end.character,
68+
// ),
69+
// );
70+
// };
71+
// return { asts: parseAstroResult.scriptAst, rangeMapper };
72+
// };

yarn.lock

+28-3
Original file line numberDiff line numberDiff line change
@@ -16297,7 +16297,7 @@ string-length@^4.0.1:
1629716297
char-regex "^1.0.2"
1629816298
strip-ansi "^6.0.0"
1629916299

16300-
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
16300+
"string-width-cjs@npm:string-width@^4.2.0":
1630116301
version "4.2.3"
1630216302
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1630316303
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -16332,6 +16332,15 @@ string-width@^3.0.0, string-width@^3.1.0:
1633216332
is-fullwidth-code-point "^2.0.0"
1633316333
strip-ansi "^5.1.0"
1633416334

16335+
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
16336+
version "4.2.3"
16337+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
16338+
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
16339+
dependencies:
16340+
emoji-regex "^8.0.0"
16341+
is-fullwidth-code-point "^3.0.0"
16342+
strip-ansi "^6.0.1"
16343+
1633516344
string-width@^5.0.1, string-width@^5.1.2:
1633616345
version "5.1.2"
1633716346
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
@@ -16435,7 +16444,7 @@ stringify-object@^3.3.0:
1643516444
is-obj "^1.0.1"
1643616445
is-regexp "^1.0.0"
1643716446

16438-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
16447+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
1643916448
version "6.0.1"
1644016449
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1644116450
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -16463,6 +16472,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
1646316472
dependencies:
1646416473
ansi-regex "^4.1.0"
1646516474

16475+
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
16476+
version "6.0.1"
16477+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
16478+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
16479+
dependencies:
16480+
ansi-regex "^5.0.1"
16481+
1646616482
strip-ansi@^7.0.1:
1646716483
version "7.1.0"
1646816484
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -18457,7 +18473,7 @@ [email protected]:
1845718473
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
1845818474
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==
1845918475

18460-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
18476+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
1846118477
version "7.0.0"
1846218478
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1846318479
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -18492,6 +18508,15 @@ wrap-ansi@^6.2.0:
1849218508
string-width "^4.1.0"
1849318509
strip-ansi "^6.0.0"
1849418510

18511+
wrap-ansi@^7.0.0:
18512+
version "7.0.0"
18513+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
18514+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
18515+
dependencies:
18516+
ansi-styles "^4.0.0"
18517+
string-width "^4.1.0"
18518+
strip-ansi "^6.0.0"
18519+
1849518520
wrap-ansi@^8.1.0:
1849618521
version "8.1.0"
1849718522
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)