@astrojs/compiler 0.14.2 → 0.15.1
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 +28 -2
- package/README.md +3 -1
- package/astro.wasm +0 -0
- package/node/index.d.ts +1 -0
- package/node/index.js +14 -1
- package/package.json +1 -1
- package/shared/types.d.ts +7 -0
- package/types.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @astrojs/compiler
|
|
2
2
|
|
|
3
|
+
## 0.15.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 26cbcdb: Prevent side-effectual CSS imports from becoming module metadata
|
|
8
|
+
|
|
9
|
+
## 0.15.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 702e848: Trailing space at the end of Astro files is now stripped from Component output.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 3a1a24b: Fix long-standing bug where a `class` attribute inside of a spread prop will cause duplicate `class` attributes
|
|
18
|
+
- 62faceb: Fixes an issue where curly braces in `<math>` elements would get parsed as expressions instead of raw text.
|
|
19
|
+
|
|
20
|
+
## 0.14.3
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 6177620: Fix edge case with expressions inside of tables
|
|
25
|
+
- 79b1ed6: Provides a better error message when we can't match client:only usage to an import statement
|
|
26
|
+
- a4e1957: Fix Astro scoping when `class:list` is used
|
|
27
|
+
- fda859a: Fix json escape
|
|
28
|
+
|
|
3
29
|
## 0.14.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -7,10 +33,10 @@
|
|
|
7
33
|
- 6f30e2e: Fix edge case with nested expression inside `<>`
|
|
8
34
|
- 15e3ff8: Fix panic when using a `<slot />` in `head`
|
|
9
35
|
- c048567: Fix edge case with `select` elements and expression children
|
|
10
|
-
- 13d2fc2: Fix #340, fixing behavior of content after an expression inside of
|
|
36
|
+
- 13d2fc2: Fix #340, fixing behavior of content after an expression inside of `<select>`
|
|
11
37
|
- 9e37a72: Fix issue when multiple client-only components are used
|
|
12
38
|
- 67993d5: Add support for block comment only expressions, block comment only shorthand attributes and block comments in shorthand attributes
|
|
13
|
-
- 59fbea2: Fix #343, edge case with
|
|
39
|
+
- 59fbea2: Fix #343, edge case with `<tr>` inside component
|
|
14
40
|
- 049dadf: Fix usage of expressions inside `caption` and `colgroup` elements
|
|
15
41
|
|
|
16
42
|
## 0.14.1
|
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ _Note: Public APIs are likely to change before 1.0! Use at your own discretion._
|
|
|
19
19
|
The Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.
|
|
20
20
|
|
|
21
21
|
**Some notes**...
|
|
22
|
+
|
|
22
23
|
- TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.
|
|
23
24
|
- `.astro` files rely on a server implementation exposed as `astro/internal` in the Node ecosystem. Other runtimes currently need to bring their own rendering implementation and reference it via `internalURL`. This is a pain point we're looking into fixing.
|
|
24
25
|
|
|
@@ -38,6 +39,7 @@ const result = await transform(source, {
|
|
|
38
39
|
The Astro compiler can emit an AST using the `parse` method.
|
|
39
40
|
|
|
40
41
|
**Some notes**...
|
|
42
|
+
|
|
41
43
|
- Position data is currently incomplete and in some cases incorrect. We're working on it!
|
|
42
44
|
- A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.
|
|
43
45
|
- The `@astrojs/compiler/utils` entrypoint exposes a `walk` function that can be used to traverse the AST. It also exposes the `is` helper which can be used as guards to derive the proper types for each `node`.
|
|
@@ -55,7 +57,7 @@ walk(result.ast, (node) => {
|
|
|
55
57
|
if (is.tag(node)) {
|
|
56
58
|
console.log(node.name);
|
|
57
59
|
}
|
|
58
|
-
})
|
|
60
|
+
});
|
|
59
61
|
```
|
|
60
62
|
|
|
61
63
|
## Contributing
|
package/astro.wasm
CHANGED
|
Binary file
|
package/node/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export type { PreprocessorResult, ParseOptions, TransformOptions, HoistedScript,
|
|
|
2
2
|
import type * as types from '../shared/types';
|
|
3
3
|
export declare const transform: typeof types.transform;
|
|
4
4
|
export declare const parse: typeof types.parse;
|
|
5
|
+
export declare const convertToTSX: typeof types.convertToTSX;
|
|
5
6
|
export declare const compile: (template: string) => Promise<string>;
|
package/node/index.js
CHANGED
|
@@ -7,6 +7,9 @@ export const transform = async (input, options) => {
|
|
|
7
7
|
export const parse = async (input, options) => {
|
|
8
8
|
return getService().then((service) => service.parse(input, options));
|
|
9
9
|
};
|
|
10
|
+
export const convertToTSX = async (input, options) => {
|
|
11
|
+
return getService().then((service) => service.convertToTSX(input, options));
|
|
12
|
+
};
|
|
10
13
|
export const compile = async (template) => {
|
|
11
14
|
const { default: mod } = await import(`data:text/javascript;charset=utf-8;base64,${Buffer.from(template).toString('base64')}`);
|
|
12
15
|
return mod;
|
|
@@ -38,7 +41,17 @@ const startRunningService = async () => {
|
|
|
38
41
|
go.run(wasm.instance);
|
|
39
42
|
const _service = globalThis['@astrojs/compiler'];
|
|
40
43
|
return {
|
|
41
|
-
transform: (input, options) => new Promise((resolve) =>
|
|
44
|
+
transform: (input, options) => new Promise((resolve) => {
|
|
45
|
+
try {
|
|
46
|
+
resolve(_service.transform(input, options || {}));
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
// Recreate the service next time on panic
|
|
50
|
+
longLivedService = void 0;
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
42
54
|
parse: (input, options) => new Promise((resolve) => resolve(_service.parse(input, options || {}))).then((result) => ({ ...result, ast: JSON.parse(result.ast) })),
|
|
55
|
+
convertToTSX: (input, options) => new Promise((resolve) => resolve(_service.convertToTSX(input, options || {}))),
|
|
43
56
|
};
|
|
44
57
|
};
|
package/package.json
CHANGED
package/shared/types.d.ts
CHANGED
|
@@ -36,11 +36,18 @@ export interface TransformResult {
|
|
|
36
36
|
code: string;
|
|
37
37
|
map: string;
|
|
38
38
|
}
|
|
39
|
+
export interface TSXResult {
|
|
40
|
+
code: string;
|
|
41
|
+
map: string;
|
|
42
|
+
}
|
|
39
43
|
export interface ParseResult {
|
|
40
44
|
ast: RootNode;
|
|
41
45
|
}
|
|
42
46
|
export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
|
|
43
47
|
export declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
|
|
48
|
+
export declare function convertToTSX(input: string, options?: {
|
|
49
|
+
sourcefile?: string;
|
|
50
|
+
}): Promise<TSXResult>;
|
|
44
51
|
export declare function initialize(options: InitializeOptions): Promise<void>;
|
|
45
52
|
export interface InitializeOptions {
|
|
46
53
|
wasmURL?: string;
|
package/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './shared/ast'
|
|
1
|
+
export * from './shared/ast';
|