1 | @swc/register
|
2 | ========
|
3 | One of the ways you can use swc is through the require hook. The require hook
|
4 | will bind itself to node's require and automatically compile files on the fly.
|
5 |
|
6 | ### Install
|
7 | ```bash
|
8 | npm i -D @swc/core @swc/register
|
9 | ```
|
10 |
|
11 | or
|
12 |
|
13 | ```bash
|
14 | yarn add --dev @swc/core @swc/register
|
15 | ```
|
16 |
|
17 | ### Usage
|
18 | ```bash
|
19 | require("@swc/register");
|
20 | ```
|
21 |
|
22 | All subsequent files required by node will be transformed by swc. You can also
|
23 | call @swc/register directly from command line.
|
24 |
|
25 | ```bash
|
26 | swc-node <filename>
|
27 | node -r '@swc/register' <filename>
|
28 | ```
|
29 |
|
30 |
|
31 |
|
32 | --------
|
33 | *@swc/register* is primarily distributed under the terms of both the [MIT
|
34 | license] and the [Apache License (Version 2.0)]. See [COPYRIGHT] for details.
|
35 |
|
36 | [MIT license]: LICENSE-MIT
|
37 | [Apache License (Version 2.0)]: LICENSE-APACHE
|
38 | [COPYRIGHT]: COPYRIGHT
|