wc-compiler 0.15.1 → 0.17.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/src/ts-loader.js DELETED
@@ -1,32 +0,0 @@
1
- import fs from 'fs/promises';
2
- import { transform } from 'sucrase';
3
-
4
- const tsRegex = /\.(ts)$/;
5
-
6
- export function resolve(specifier, context, defaultResolve) {
7
- const { parentURL } = context;
8
-
9
- if (tsRegex.test(specifier)) {
10
- return {
11
- url: new URL(specifier, parentURL).href,
12
- shortCircuit: true
13
- };
14
- }
15
-
16
- return defaultResolve(specifier, context, defaultResolve);
17
- }
18
-
19
- export async function load(url, context, defaultLoad) {
20
- if (tsRegex.test(url)) {
21
- const contents = await fs.readFile(new URL(url), 'utf-8');
22
- const result = transform(contents, { transforms: ['typescript'] });
23
-
24
- return {
25
- format: 'module',
26
- shortCircuit: true,
27
- source: result.code
28
- };
29
- }
30
-
31
- return defaultLoad(url, context, defaultLoad);
32
- }