An open API service indexing awesome lists of open source software.

https://github.com/hugoalh/deno-nodejs-transformer

A Deno module for transform Deno package to NodeJS package. This is a modified edition of the JSR package `dnt`.
https://github.com/hugoalh/deno-nodejs-transformer

build builder deno nodejs package transform transformer

Last synced: about 2 months ago
JSON representation

A Deno module for transform Deno package to NodeJS package. This is a modified edition of the JSR package `dnt`.

Awesome Lists containing this project

README

          

# Deno NodeJS Transformer

[**⚖️** MIT](./LICENSE.md)

🔗
[GitHub](https://github.com/hugoalh/deno-nodejs-transformer)
[JSR](https://jsr.io/@hugoalh/deno-nodejs-transformer)

Transform Deno code to NodeJS code.

Currently, this is a modified edition of the [Deno DNT](https://github.com/denoland/dnt) which:

- Always force with ECMAScript module
- Improve file structure
- Unify configuration

## ▶️ Begin - Deno

- **[Deno](https://deno.land/)** >= v2.5.2

### 🛡️ Runtime Permissions

- Environment Variable (`env`)
- *Resources*
- File System - Read (`read`)
- *Resources*
- File System - Write (`write`)
- *Resources*
- Network (`net`)
- *Resources*

### #️⃣ Sources

- GitHub Raw
```
https://raw.githubusercontent.com/hugoalh/deno-nodejs-transformer/{Tag}/mod.ts
```
- JSR
```
jsr:@hugoalh/deno-nodejs-transformer[@{Tag}]
```

> [!NOTE]
> - It is recommended to include tag for immutability.
> - These are not part of the public APIs hence should not be used:
> - Benchmark/Test file (e.g.: `example.bench.ts`, `example.test.ts`).
> - Entrypoint name or path include any underscore prefix (e.g.: `_example.ts`, `foo/_example.ts`).
> - Identifier/Namespace/Symbol include any underscore prefix (e.g.: `_example`, `Foo._example`).

### ⤵️ Entrypoints

| **Name** | **Path** | **Description** |
|:--|:--|:--|
| `.` | `./mod.ts` | Default. |

### 🧩 APIs

- ```ts
function transform(options: TransformOptions): Promise;
```
- ```ts
interface TransformOptions {
copyEntries?: readonly (string | RegExp | TransformCopyEntriesOptions)[];
entrypointsExecutable?: Record;
entrypointsScript?: Record;
fixDenoDNTModifications?: boolean;
generateDeclaration?: boolean;
generateDeclarationMap?: boolean;
importsMap?: string;
lib?: LibName[];
mappings?: SpecifierMappings;
metadata: Metadata;
outputDirectory?: string;
outputDirectoryPreEmpty?: boolean;
shims?: TransformShimOptions;
target?: ScriptTarget;
useTSLibHelper?: boolean;
workspace?: string;
}
```

> [!NOTE]
> - For the full or prettier documentation, can visit via:
> - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc/)
> - [JSR](https://jsr.io/@hugoalh/deno-nodejs-transformer)

### ✍️ Examples

- ```ts
await transform({
copyEntries: [
/^LICENSE(?:[-\._][^\/\\]+)?\.md$/i,
/^README(?:[-\._][^\/\\]+)?\.md$/i
],
entrypointsScript: {
".": "./mod.ts"
},
metadata: {
name: "@hugoalh/deno-nodejs-transformer-test",
version: "0.8.0",
description: "Demo of Deno NodeJS Transformer.",
keywords: [
"test"
],
homepage: "https://github.com/hugoalh/deno-nodejs-transformer#readme",
bugs: {
url: "https://github.com/hugoalh/deno-nodejs-transformer/issues"
},
license: "MIT",
author: "hugoalh",
repository: {
type: "git",
url: "git+https://github.com/hugoalh/deno-nodejs-transformer.git"
},
private: false,
publishConfig: {
access: "public"
}
},
outputDirectory: "dist/npm",
outputDirectoryPreEmpty: true
});
```