@astrojs/compiler 1.1.2 → 1.2.0

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
@@ -1,5 +1,11 @@
1
1
  # @astrojs/compiler
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b2cfd00: Add teardown API to remove WASM instance after using the compiler
8
+
3
9
  ## 1.1.2
4
10
 
5
11
  ### Patch Changes
package/astro.wasm CHANGED
Binary file
@@ -1,4 +1,5 @@
1
1
  import type * as types from '../shared/types';
2
2
  export declare const transform: typeof types.transform;
3
3
  export declare const parse: typeof types.parse;
4
+ export declare const teardown: typeof types.teardown;
4
5
  export declare const initialize: typeof types.initialize;
package/browser/index.js CHANGED
@@ -7,6 +7,11 @@ export const parse = (input, options) => {
7
7
  };
8
8
  let initializePromise;
9
9
  let longLivedService;
10
+ export const teardown = () => {
11
+ initializePromise = undefined;
12
+ longLivedService = undefined;
13
+ globalThis['@astrojs/compiler'] = undefined;
14
+ };
10
15
  export const initialize = async (options) => {
11
16
  let wasmURL = options.wasmURL;
12
17
  if (!wasmURL)
package/node/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export declare const transform: typeof types.transform;
4
4
  export declare const parse: typeof types.parse;
5
5
  export declare const convertToTSX: typeof types.convertToTSX;
6
6
  export declare const compile: (template: string) => Promise<string>;
7
+ export declare const teardown: typeof types.teardown;
package/node/index.js CHANGED
@@ -15,6 +15,10 @@ export const compile = async (template) => {
15
15
  return mod;
16
16
  };
17
17
  let longLivedService;
18
+ export const teardown = () => {
19
+ longLivedService = undefined;
20
+ globalThis['@astrojs/compiler'] = undefined;
21
+ };
18
22
  let getService = () => {
19
23
  if (!longLivedService) {
20
24
  longLivedService = startRunningService().catch((err) => {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "module",
6
6
  "bugs": "https://github.com/withastro/compiler/issues",
7
7
  "homepage": "https://astro.build",
8
- "version": "1.1.2",
8
+ "version": "1.2.0",
9
9
  "main": "./node/index.js",
10
10
  "types": "./node",
11
11
  "repository": {
package/shared/types.d.ts CHANGED
@@ -94,6 +94,17 @@ export declare function transform(input: string, options?: TransformOptions): Pr
94
94
  export declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
95
95
  export declare function convertToTSX(input: string, options?: ConvertToTSXOptions): Promise<TSXResult>;
96
96
  export declare function initialize(options: InitializeOptions): Promise<void>;
97
+ /**
98
+ * When calling the core compiler APIs, e.g. `transform`, `parse`, etc, they
99
+ * would automatically instantiate a WASM instance to process the input. When
100
+ * done, you can call this to manually teardown the WASM instance.
101
+ *
102
+ * If the APIs are called again, they will automatically instantiate a new WASM
103
+ * instance. In browsers, you have to call `initialize()` again before using the APIs.
104
+ *
105
+ * Note: Calling teardown is optional and exists mostly as an optimization only.
106
+ */
107
+ export declare function teardown(): void;
97
108
  export interface InitializeOptions {
98
109
  wasmURL?: string;
99
110
  }