UNPKG

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