@furryr/typescript-runtime 1.0.0 → 1.0.2
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
|
|
|
@@ -96,8 +109,8 @@ Classic JSX example:
|
|
|
96
109
|
{
|
|
97
110
|
"compilerOptions": {
|
|
98
111
|
"jsx": "react",
|
|
99
|
-
"jsxFactory": "
|
|
100
|
-
"jsxFragmentFactory": "
|
|
112
|
+
"jsxFactory": "window.jsx",
|
|
113
|
+
"jsxFragmentFactory": "window.Fragment"
|
|
101
114
|
}
|
|
102
115
|
}
|
|
103
116
|
```
|
|
@@ -110,7 +123,8 @@ Then use `type="text/typescript-tsx"` or a `.tsx` file:
|
|
|
110
123
|
</script>
|
|
111
124
|
```
|
|
112
125
|
|
|
113
|
-
`typescript-runtime` does not provide a JSX runtime. You must provide `
|
|
126
|
+
`typescript-runtime` does not provide a JSX runtime. You must provide `window.jsx`, React, or another runtime yourself.
|
|
127
|
+
For automatic JSX (`"jsx": "react-jsx"`), import `jsx`/`jsxs` from your runtime in your own source; `typescript-runtime` does not inject a JSX runtime import.
|
|
114
128
|
|
|
115
129
|
## Source Maps
|
|
116
130
|
|