Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nyxb/dynot
π¦β‘οΈ Boost your Node.js runtime with TypeScript and ESM support!
https://github.com/nyxb/dynot
esm nodejs runtime support typescript
Last synced: 12 days ago
JSON representation
π¦β‘οΈ Boost your Node.js runtime with TypeScript and ESM support!
- Host: GitHub
- URL: https://github.com/nyxb/dynot
- Owner: nyxb
- License: mit
- Created: 2023-05-10T00:42:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-12T14:28:51.000Z (over 1 year ago)
- Last Synced: 2025-01-16T16:25:38.105Z (17 days ago)
- Topics: esm, nodejs, runtime, support, typescript
- Language: TypeScript
- Homepage: https://nyxb.xyz
- Size: 1.17 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![cover][cover-src]][cover-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![License][license-src]][license-href]> π¦β‘οΈ Boost your Node.js runtime with TypeScript and ESM support!
## β¨ Features
- π Smooth TypeScript and ESM syntax integration
- π Seamless ESM and CommonJS interoperability
- β‘ Synchronous API as a `require` alternative
- πͺ Super lightweight with zero dependencies
- π§ Clever syntax detection to avoid unnecessary transformations
- πΎ CommonJS cache integration
- ποΈ Filesystem transpile hard cache
- ποΈ V8 compile cache
- π Custom resolve alias## π οΈ Usage
### π¦ Scripted
```ts
const dynotti = require('dynot')(__filename)dynot('./path/to/file.ts')
```You can also pass options as a second argument:
```ts
const dynot = require('dynot')(__filename, { debug: true })
```### π₯οΈ CLI
```bash
dynot index.ts
# or npx dynot index.ts
```### π Register require hook
```bash
node -r dynot/register index.ts
```Alternatively, you can register `dynot` as a require hook programmatically:
```ts
const dynot = require('dynot')()const unregister = dynot.register()
```## βοΈ Options
### `debug` π
- Type: Boolean
- Default: `false`
- Environment Variable: `DYNOT_DEBUG`Enable debug mode to see which files are transpiled
### `cache` π½
- Type: Boolean | String
- Default: `true`
- Environment Variable: `DYNOT_CACHE`Toggle transpile cache
If set to `true`, it will use `node_modules/.cache/dynot` (if exists) or `{TMP_DIR}/node-dynot`
### `esmResolve` π
- Type: Boolean | String
- Default: `false`
- Environment Variable: `DYNOT_ESM_RESOLVE`Activate esm resolution algorithm to support `import` condition.
### `transform` π
- Type: Function
- Default: Babel (lazy loaded)Specify a transform function. Check [src/babel](./src/babel.ts) for more details.
### `sourceMaps` πΊοΈ
- Type: Boolean
- Default `false`
- Environment Variable: `DYNOT_SOURCE_MAPS`Add inline source map to transformed source for improved debugging.
### `interopDefault` π§©
- Type: Boolean
- Default: `false`Return the `.default` export of a module at the top-level.
### `alias` π·οΈ
- Type: Object
- Default: -
- Environment Variable: `DYNOT_ALIAS`Define a custom alias map to resolve ids.
### `nativeModules` π
- Type: Array
- Default: ['typescript`]
- Environment Variable: `DYNOT_NATIVE_MODULES`Specify a list of modules (within `node_modules`) to always use native require for them.
### `transformModules` π οΈ
- Type: Array
- Default: []
- Environment Variable: `DYNOT_TRANSFORM_MODULES`List modules (within `node_modules`) to transform them regardless of syntax.
## π± Development
π Clone this repository
π§ Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
π¦ Install dependencies using [nyxi](https://github.com/nyxblabs/nyxi) π§ Always right package manager
π Run `nyxr dev`
π Run `nyxr dynot ./test/path/to/file.ts`## π License
[MIT](./LICENSE) - Made with π
[npm-version-src]: https://img.shields.io/npm/v/dynot?style=flat&colorA=18181B&colorB=14F195
[npm-version-href]: https://npmjs.com/package/dynot
[npm-downloads-src]: https://img.shields.io/npm/dm/dynot?style=flat&colorA=18181B&colorB=14F195
[npm-downloads-href]: https://npmjs.com/package/dynot
[bundle-src]: https://img.shields.io/bundlephobia/minzip/dynot?style=flat&colorA=18181B&colorB=14F195
[bundle-href]: https://bundlephobia.com/result?p=dynot
[license-src]: https://img.shields.io/github/license/nyxblabs/dynot.svg?style=flat&colorA=18181B&colorB=14F195
[license-href]: https://github.com/nyxblabs/dynot/blob/main/LICENSE[cover-src]: https://raw.githubusercontent.com/nyxblabs/dynot/main/.github/assets/cover-github-dynot.png
[cover-href]: https://π»nyxb.ws