0.6.3 • Published 2 months ago

ts-dual-module v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

ts-dual-module

Easily build ts projects as dual packaged modules (cjs+esm)

The tool is designed to work on ESM packages (type: "module") and will build both ESM and commonjs versions of your code using typescript. The package.json exports is automatically updated to match your build.

A dual module project is usually storing the source files in a directoy like ./src`` and the generated files in a directory like./dist`. The minimal layout of a projet is:

./dist
./src
package.json
tsconfig.json

The first time the build is done (or if you run npx tsmod init) you will be asked for the oputput directory name where the generated files will be stored.

You must create a ./tsconfig.json file in the project root, which will be used by the tool to as the base tsc configuration. If you don't have one just run npx tsmod init and it will create one for you.

If you need to customize the tsconfig.json file differently for esm or cjs you can create a specific files for each build: tsconfig.esm.json and tsconfig.cjs.esm hich will take precendence over tsconfig.json.

To start a build run: npx tsmod build. You can pass any additional tsc options you need.

Sub-paths exports

Also, sub-paths exports are supported (this is not working by default with commonjs builds because typescript is only handling subpath exports if moduleResolution >= Node16).

The tool is fxing this by mapping types using a typesVersions entry in the package.json

See:

To add an export path run: npx tsmod export mypath path/to/out/file.js

0.6.3

2 months ago

0.6.2

3 months ago

0.6.1

3 months ago

0.6.0

3 months ago

0.5.0

3 months ago

0.4.3

3 months ago

0.4.2

3 months ago

0.4.1

3 months ago

0.4.0

3 months ago

0.3.0

3 months ago