@furryr/typescript-runtime 1.0.0 → 1.0.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/README.md
CHANGED
|
@@ -8,10 +8,11 @@ Run small TypeScript and TSX scripts directly in the browser.
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
-
Load `typescript-runtime` before your TypeScript scripts
|
|
11
|
+
Load `typescript-runtime` before your TypeScript scripts (add `raw` so the library
|
|
12
|
+
isn't re-processed — see [raw attribute](#scripts-marked-with-raw) below):
|
|
12
13
|
|
|
13
14
|
```html
|
|
14
|
-
<script src="./dist/typescript-runtime.global.js"></script>
|
|
15
|
+
<script src="./dist/typescript-runtime.global.js" raw></script>
|
|
15
16
|
|
|
16
17
|
<script type="text/typescript">
|
|
17
18
|
const message: string = 'Hello from TypeScript';
|
|
@@ -22,7 +23,7 @@ Load `typescript-runtime` before your TypeScript scripts:
|
|
|
22
23
|
External files work too:
|
|
23
24
|
|
|
24
25
|
```html
|
|
25
|
-
<script src="./dist/typescript-runtime.global.js"></script>
|
|
26
|
+
<script src="./dist/typescript-runtime.global.js" raw></script>
|
|
26
27
|
<script type="text/typescript" src="./app.ts"></script>
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -35,6 +36,18 @@ Supported script markers:
|
|
|
35
36
|
- `type="text/typescript-tsx"`
|
|
36
37
|
- `type="application/typescript-tsx"`
|
|
37
38
|
- `src` ending in `.ts`, `.mts`, `.cts`, `.tsx`, `.mtsx`, or `.ctsx`
|
|
39
|
+
- `src` ending in `.js`, `.mjs`, `.cjs`, `.jsx`, `.mjsx`, or `.cjsx` (import resolution)
|
|
40
|
+
|
|
41
|
+
### Scripts marked with `raw`
|
|
42
|
+
|
|
43
|
+
Any `<script>` with a `raw` attribute is skipped by the runtime. Add `raw` to the
|
|
44
|
+
library's own script to prevent it from being re-processed:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<script src="./dist/typescript-runtime.global.js" raw></script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This is also useful for any third-party scripts you want to exclude from processing.
|
|
38
51
|
|
|
39
52
|
External scripts are loaded with `fetch`, so normal browser CORS rules apply.
|
|
40
53
|
|