You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Node.js tool for building a TypeScript dual package.
21
21
First, install this package to create the `duel` executable inside your `node_modules/.bin` directory.
22
22
23
23
```console
24
-
user@comp ~ $ npm i @knighted/duel
24
+
user@comp ~ $ npm i @knighted/duel --save-dev
25
25
```
26
26
27
27
Then, given a `package.json` that defines `"type": "module"` and a `tsconfig.json` file that looks something like the following:
@@ -86,7 +86,7 @@ The available options are limited, because you should define most of them inside
86
86
87
87
*`--project, -p` The path to the project's configuration file. Defaults to `tsconfig.json`.
88
88
*`--pkg-dir, -k` The directory to start looking for a package.json file. Defaults to the cwd.
89
-
*`--dirs, -d` Outputs both builds to directories inside of `outDir`. Defalts to `false`.
89
+
*`--dirs, -d` Outputs both builds to directories inside of `outDir`. Defaults to `false`.
90
90
*`--parallel, -l` Run the builds in parallel. Defaults to `false`.
91
91
92
92
You can run `duel --help` to get the same info. Below is the output of that:
@@ -106,7 +106,7 @@ Options:
106
106
107
107
These are definitely edge cases, and would only really come up if your project mixes file extensions. For example, if you have `.ts` files combined with `.mts`, and/or `.cts`. For most projects, things should just work as expected.
108
108
109
-
* This is going to work best if your CJS-first project uses file extensions in their _relative_ specifiers. This is completely acceptable in CJS projects, and [required in ESM projects](https://nodejs.org/api/esm.html#import-specifiers). This package makes no attempt to rewrite bare specifiers, or remap any relative specifiers to a directory index.
109
+
* This is going to work best if your CJS-first project uses file extensions in _relative_ specifiers. This is completely acceptable in CJS projects, and [required in ESM projects](https://nodejs.org/api/esm.html#import-specifiers). This package makes no attempt to rewrite bare specifiers, or remap any relative specifiers to a directory index.
110
110
111
111
* Unfortunately, TypeScript doesn't really build [dual packages](https://nodejs.org/api/packages.html#dual-commonjses-module-packages) very well in regards to preserving module system by file extension. For instance, there doesn't appear to be a way to convert an arbitrary `.ts` file into another module system, _while also preserving the module system of `.mts` and `.cts` files_, without requiring **multiple** package.json files. In my opinion, the `tsc` compiler is fundamentally broken in this regard, and at best is enforcing usage patterns it shouldn't. This is only mentioned for transparency, `duel` will correct for this and produce files with the module system you would expect based on the file's extension, so that it works with [how Node.js determines module systems](https://nodejs.org/api/packages.html#determining-module-system).
0 commit comments