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`.
- Host: GitHub
- URL: https://github.com/hugoalh/deno-nodejs-transformer
- Owner: hugoalh
- License: other
- Created: 2024-09-21T08:47:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T04:23:05.000Z (over 1 year ago)
- Last Synced: 2024-10-24T21:52:06.239Z (over 1 year ago)
- Topics: build, builder, deno, nodejs, package, transform, transformer
- Language: TypeScript
- Homepage:
- Size: 77.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
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
});
```