Attributes
Popular
Repository
Current version released
3 years ago
Versions
- 0.40.0Latest
- 0.39.0
- 0.38.1
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.1
- 0.33.0
- 0.32.1
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.1
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.3
- 0.25.2
- 0.25.1
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.2
- 0.21.1
- 0.21.0
- 0.20.1
- 0.20.0
- 0.19.0
- 0.18.1
- 0.18.0
- 0.17.0
- 0.16.1
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.1
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
dnt - Deno to Node Transform
Prototype for a Deno to Node/canonical TypeScript transform.
CLI Example
# install
deno install --allow-read --allow-write --allow-net -n dnt https://deno.land/x/dnt/cli.ts
# clone a Deno-first repo
git clone https://github.com/dsherret/code-block-writer.git
cd code-block-writer
# run tool and output to ./code-block-writer/npm/dist (uses tsc CLI flags)
dnt mod.ts --target ES6 --outDir ./npm/dist --declaration
# go to output directory, run tsc, and publish
cd npm
npm publish
Wasm API Example
To emit the Deno-first sources to code that can be consumed in Node.js, use the
emit
function:
// docs: https://doc.deno.land/https/deno.land/x/dnt/mod.ts
import { emit } from "https://deno.land/x/dnt/mod.ts";
await emit({
compilerOptions: {
outDir: "./dist",
},
entryPoint: "./mod.ts",
shimPackageName: "deno-shim-package-name",
typeCheck: false,
});
For only the Deno to canonical TypeScript transform which can be useful for bundlers, use the following:
// docs: https://doc.deno.land/https/deno.land/x/dnt/transform.ts
import { transform } from "https://deno.land/x/dnt/transform.ts";
const outputFiles = await transform({
entryPoint: "./mod.ts",
shimPackageName: "deno-shim-package-name",
keepExtensions: false, // transforms to not have extensions
});
Rust API Example
When using TypeScript, the Rust API only transforms from Deno to canonical TypeScript. You will need to use the TypeScript compiler to do the rest.
use std::path::PathBuf;
use deno_node_transform::ModuleSpecifier;
use deno_node_transform::transform;
use deno_node_transform::TransformOptions;
let output_files = transform(TransformOptions {
entry_point: ModuleSpecifier::from_file_path(PathBuf::from("./mod.ts")).unwrap(),
keep_extensions: false,
loader: None, // use the default loader
}).await?;
for output_file in output_files {
// use these properties on output_file
output_file.file_path;
output_file.file_text;
}