1 | The `dist-raw` directory contains JS sources that are distributed verbatim, not compiled nor typechecked via TS.
|
2 |
|
3 | To implement ESM support, we unfortunately must duplicate some of node's built-in functionality that is not
|
4 | exposed via an API. We have copy-pasted the necessary code from https://github.com/nodejs/node/tree/master/lib
|
5 | then modified it to suite our needs.
|
6 |
|
7 | Formatting may be intentionally bad to keep the diff as small as possible, to make it easier to merge
|
8 | upstream changes and understand our modifications. For example, when we need to wrap node's source code
|
9 | in a factory function, we will not indent the function body, to avoid whitespace changes in the diff.
|
10 |
|
11 | One obvious problem with this approach: the code has been pulled from one version of node, whereas users of ts-node
|
12 | run multiple versions of node.
|
13 | Users running node 12 may see that ts-node behaves like node 14, for example.
|
14 |
|
15 | ## `raw` directory
|
16 |
|
17 | Within the `raw` directory, we keep unmodified copies of the node source files. This allows us to use diffing tools to
|
18 | compare files in `raw` to those in `dist-raw`, which will highlight all of the changes we have made. Hopefully, these
|
19 | changes are as minimal as possible.
|
20 |
|
21 | ## Naming convention
|
22 |
|
23 | Not used consistently, but the idea is:
|
24 |
|
25 | `node-<directory>(...-<directory>)-<filename>.js`
|
26 |
|
27 | `node-internal-errors.js` -> `github.com/nodejs/node/blob/TAG/lib/internal/errors.js`
|
28 |
|
29 | So, take the path within node's `lib/` directory, and replace slashes with hyphens.
|
30 |
|
31 | In the `raw` directory, files are suffixed with the version number or revision from which
|
32 | they were downloaded.
|
33 |
|
34 | If they have a `stripped` suffix, this means they have large chunks of code deleted, but no other modifications.
|
35 | This is useful when diffing. Sometimes our `dist-raw` files only have a small part of a much larger node source file.
|
36 | It is easier to diff `raw/*-stripped.js` against `dist-raw/*.js`.
|