-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the migrate page and the cheatsheet for deno future (#687)
Co-authored-by: Marvin Hagemeister <[email protected]> Co-authored-by: Josh Collinsworth <[email protected]>
- Loading branch information
1 parent
83889e5
commit 50100d6
Showing
13 changed files
with
480 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
runtime/manual/node/faqs.md → runtime/manual/advanced/faqs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: "Importing modules from HTTP URLs" | ||
oldUrl: | ||
- runtime/manual/node/cdns.md | ||
--- | ||
|
||
Deno supports importing modules from HTTP URLs. This is useful for importing | ||
modules from a CDN or from a server that serves JavaScript modules. Note that | ||
npm packages can be directly imported via the | ||
[`npm:` specifier](../../manual/node/npm_specifiers). | ||
|
||
```typescript | ||
import { render } from "https://esm.sh/preact"; | ||
``` | ||
|
||
You can also import modules from a URL by adding it to your `deno.json` import | ||
map: | ||
|
||
```json | ||
{ | ||
"imports": { | ||
"preact": "https://esm.sh/preact" | ||
} | ||
} | ||
``` | ||
|
||
Supporting URL imports enables us to support the following JavaScript CDNs, as | ||
they provide URL access to JavaScript modules: | ||
|
||
- [esm.sh](https://esm.sh/) (recommended) | ||
- [jspm.io](https://jspm.io/) | ||
|
||
URL imports should be used with caution, as they can introduce security risks. | ||
When importing modules from a URL, you are trusting the server to serve the | ||
correct code. If the server is compromised, it could serve malicious code to | ||
your application. For this reason, it is recommended to use URL imports only | ||
from trusted sources. They can also cause versioning issues if you import | ||
different versions in different files. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: "Node → Deno cheatsheet" | ||
oldUrl: | ||
- /runtime/manual/references/cheatsheet/ | ||
--- | ||
|
||
| Node.js | Deno | | ||
| -------------------------------------- | ----------------------------- | | ||
| `node file.js` | `deno run file.js` | | ||
| `ts-node file.ts` | `deno run file.ts` | | ||
| `nodemon` | `deno run --watch` | | ||
| `node -e` | `deno eval` | | ||
| `npm i` / `npm install` | `deno install` | | ||
| `npm install -g` | `deno install -g` | | ||
| `npm run` | `deno task` | | ||
| `eslint` | `deno lint` | | ||
| `prettier` | `deno fmt` | | ||
| `package.json` | `deno.json` or `package.json` | | ||
| `tsc` | `deno check` ¹ | | ||
| `typedoc` | `deno doc` | | ||
| `jest` / `ava` / `mocha` / `tap` / etc | `deno test` | | ||
| `nexe` / `pkg` | `deno compile` | | ||
| `npm explain` | `deno info` | | ||
| `nvm` / `n` / `fnm` | `deno upgrade` | | ||
| `tsserver` | `deno lsp` | | ||
| `nyc` / `c8` / `istanbul` | `deno coverage` | | ||
| benchmarks | `deno bench` | | ||
|
||
¹ Type checking happens automatically, TypeScript compiler is built into the | ||
`deno` binary. | ||
|
||
## Built-in Node.js globals | ||
|
||
Deno provides a similar set of built-in globals as Node.js, but with some | ||
differences. Here are some common ones: | ||
|
||
| Node.js | Deno | | ||
| ---------------------------- | ------------------------------- | | ||
| `process.cwd()` | `Deno.cwd()` | | ||
| `process.env.MY_ENV` | `Deno.env.get("MY_ENV")` | | ||
| `process.env.MY_ENV = "foo"` | `Deno.env.set("MY_ENV", "foo")` | | ||
| `process.platform` | `Deno.build.os` | | ||
| `process.arch` | `Deno.build.arch` | | ||
| `process.execPath()` | `Deno.execPath()` | | ||
| `process.exist(code)` | `Deno.exit(code)` | | ||
|
||
It is also possible to import Node.js modules into your project using the | ||
`node:` specifier. For example: | ||
|
||
```js | ||
import process from "node:process"; | ||
``` | ||
|
||
### APIs | ||
|
||
| Node.js | Deno | | ||
| ---------------------------------------- | ----------------------------- | | ||
| `fsPromises.readFile(filePath, "utf-8")` | `Deno.readTextFile(filePath)` | |
Oops, something went wrong.