@astrojs/ts-plugin 1.0.8 → 1.0.9

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @astrojs/ts-plugin@1.0.8 build /home/runner/work/language-tools/language-tools/packages/ts-plugin
2
+ > @astrojs/ts-plugin@1.0.9 build /home/runner/work/language-tools/language-tools/packages/ts-plugin
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @astrojs/ts-plugin
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - b6a98e0: Better handle when the Astro compiler fails to parse a file
8
+
3
9
  ## 1.0.8
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/ts-plugin",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A TypeScript Plugin providing Astro intellisense",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
package/src/astro2tsx.ts CHANGED
@@ -2,6 +2,25 @@ import { convertToTSX } from '@astrojs/compiler/sync';
2
2
  import type { TSXResult } from '@astrojs/compiler/types';
3
3
 
4
4
  export function astro2tsx(content: string, fileName: string): TSXResult {
5
- const tsx = convertToTSX(content, { filename: fileName });
6
- return tsx;
5
+ try {
6
+ const tsx = convertToTSX(content, { filename: fileName });
7
+ return tsx;
8
+ } catch (e) {
9
+ console.error(
10
+ `There was an error transforming ${fileName} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`
11
+ );
12
+
13
+ return {
14
+ code: '',
15
+ map: {
16
+ file: fileName,
17
+ sources: [],
18
+ sourcesContent: [],
19
+ names: [],
20
+ mappings: '',
21
+ version: 0,
22
+ },
23
+ diagnostics: [],
24
+ };
25
+ }
7
26
  }