2018-05-18 12:25:59 -04:00
|
|
|
# deno
|
|
|
|
|
2018-05-29 14:02:43 -04:00
|
|
|
[![Build Status](https://travis-ci.com/ry/deno.svg?branch=master)](https://travis-ci.com/ry/deno)
|
2018-05-18 12:25:59 -04:00
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
## A secure TypeScript runtime built on V8
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-05-30 11:11:15 -04:00
|
|
|
* Supports TypeScript 2.8 out of the box. Uses V8 6.8.275.3. That is, it's
|
|
|
|
very modern JavaScript.
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
* No `package.json`. No npm. Not explicitly compatible with Node.
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-05-29 01:35:06 -04:00
|
|
|
* Imports reference source code URLs only.
|
2018-05-28 23:52:22 -04:00
|
|
|
```
|
|
|
|
import { test } from "https://unpkg.com/deno_testing@0.0.5/testing.ts"
|
|
|
|
import { log } from "./util.ts"
|
|
|
|
```
|
2018-05-30 11:11:15 -04:00
|
|
|
Remote code is fetched and cached on first execution, and never updated until
|
2018-06-08 04:38:47 -04:00
|
|
|
the code is run with the `--reload` flag. (So, this will still work on an
|
2018-05-30 11:11:15 -04:00
|
|
|
airplane. See `~/.deno/src` for details on the cache.)
|
2018-05-28 23:52:22 -04:00
|
|
|
|
|
|
|
* File system and network access can be controlled in order to run sandboxed
|
2018-05-30 11:11:15 -04:00
|
|
|
code. Defaults to read-only file system access and no network access.
|
|
|
|
Access between V8 (unprivileged) and Golang (privileged) is only done via
|
2018-05-31 14:31:37 -04:00
|
|
|
serialized messages defined in this
|
2018-06-08 04:38:47 -04:00
|
|
|
[protobuf](https://github.com/ry/deno/blob/master/msg.proto). This makes it
|
2018-05-31 14:31:37 -04:00
|
|
|
easy to audit.
|
2018-05-30 11:11:15 -04:00
|
|
|
To enable write access explicitly use `--allow-write` and `--allow-net` for
|
|
|
|
network access.
|
2018-05-28 23:52:22 -04:00
|
|
|
|
|
|
|
* Single executable:
|
|
|
|
```
|
|
|
|
> ls -lh deno
|
|
|
|
-rwxrwxr-x 1 ryan ryan 55M May 28 23:46 deno
|
|
|
|
> ldd deno
|
|
|
|
linux-vdso.so.1 => (0x00007ffc6797a000)
|
|
|
|
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f104fa47000)
|
|
|
|
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f104f6c5000)
|
|
|
|
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f104f3bc000)
|
|
|
|
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f104f1a6000)
|
|
|
|
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f104eddc000)
|
|
|
|
/lib64/ld-linux-x86-64.so.2 (0x00007f104fc64000)
|
|
|
|
```
|
|
|
|
|
2018-05-29 05:24:56 -04:00
|
|
|
* Always dies on uncaught errors.
|
2018-05-29 03:20:04 -04:00
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
* Supports top-level `await`.
|
2018-05-29 03:20:04 -04:00
|
|
|
|
|
|
|
* Aims to be browser compatible.
|
|
|
|
|
2018-05-29 04:28:32 -04:00
|
|
|
* Can be used as a library to easily build your own JavaScript runtime.
|
|
|
|
https://github.com/ry/deno/blob/master/cmd/main.go
|
|
|
|
|
2018-05-29 03:20:04 -04:00
|
|
|
|
|
|
|
## Status
|
|
|
|
|
|
|
|
Segfaulty.
|
|
|
|
|
2018-05-31 14:31:37 -04:00
|
|
|
No docs yet. For some of the public API see: [deno.d.ts](https://github.com/ry/deno/blob/master/deno.d.ts).
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-05-31 14:31:37 -04:00
|
|
|
And examples are around here: [testdata/004_set_timeout.ts](https://github.com/ry/deno/blob/master/testdata/004_set_timeout.ts).
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-05-31 14:31:37 -04:00
|
|
|
Roadmap is [here](https://github.com/ry/deno/blob/master/TODO.txt).
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
Also see this presentation: http://tinyclouds.org/jsconf2018.pdf
|
2018-06-04 03:10:54 -04:00
|
|
|
|
|
|
|
|
2018-05-28 23:52:22 -04:00
|
|
|
## Compile instructions
|
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
I will release binaries at some point, but for now you have to build it
|
2018-05-28 23:52:22 -04:00
|
|
|
yourself.
|
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
You will need [Go](https://golang.org) with `$GOPATH` defined and
|
|
|
|
`$GOPATH/bin` in your `$PATH`.
|
|
|
|
|
|
|
|
You will also need [yarn](https://yarnpkg.com/lang/en/docs/install/) installed.
|
2018-05-31 00:07:02 -04:00
|
|
|
|
2018-05-28 23:52:22 -04:00
|
|
|
You need Protobuf 3. On Linux this might work:
|
2018-05-31 14:31:37 -04:00
|
|
|
|
|
|
|
``` bash
|
|
|
|
cd ~
|
|
|
|
wget https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip
|
|
|
|
unzip protoc-3.1.0-linux-x86_64.zip
|
|
|
|
export PATH=$HOME/bin:$PATH
|
2018-05-31 00:07:02 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
On macOS, using [HomeBrew](https://brew.sh/):
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-05-31 14:31:37 -04:00
|
|
|
``` bash
|
|
|
|
brew install protobuf
|
2018-05-28 23:52:22 -04:00
|
|
|
```
|
2018-05-31 14:31:37 -04:00
|
|
|
|
|
|
|
Then you need [protoc-gen-go](https://github.com/golang/protobuf/tree/master/protoc-gen-go) and [go-bindata](https://github.com/jteeuwen/go-bindata):
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
go get -u github.com/golang/protobuf/protoc-gen-go
|
|
|
|
go get -u github.com/jteeuwen/go-bindata/...
|
2018-05-28 23:52:22 -04:00
|
|
|
```
|
|
|
|
|
2018-06-04 03:41:51 -04:00
|
|
|
You need to get and build [v8worker2](https://github.com/ry/v8worker2). __The package will not build with `go
|
|
|
|
get` and will log out an error ⚠__
|
|
|
|
```bash
|
|
|
|
# pkg-config --cflags v8.pc
|
|
|
|
Failed to open 'v8.pc': No such file or directory
|
|
|
|
No package 'v8.pc' found
|
|
|
|
pkg-config: exit status 1
|
|
|
|
```
|
|
|
|
|
|
|
|
__which can be ignored__. It takes about 30 minutes to build:
|
2018-05-31 14:31:37 -04:00
|
|
|
|
|
|
|
``` bash
|
|
|
|
go get -u github.com/ry/v8worker2
|
|
|
|
cd $GOPATH/src/github.com/ry/v8worker2
|
|
|
|
./build.py --use_ccache
|
2018-05-28 23:52:22 -04:00
|
|
|
```
|
2018-06-08 04:38:47 -04:00
|
|
|
Maybe also run `git submodule update --init` in the `v8worker2/` dir.
|
2018-05-28 23:52:22 -04:00
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
Finally, you can get `deno` and its other Go deps.
|
2018-05-31 14:31:37 -04:00
|
|
|
|
|
|
|
``` bash
|
2018-05-30 11:11:15 -04:00
|
|
|
go get -u github.com/ry/deno/...
|
|
|
|
```
|
2018-05-28 23:52:22 -04:00
|
|
|
|
|
|
|
Now you can build deno and run it:
|
2018-05-31 14:31:37 -04:00
|
|
|
|
|
|
|
``` bash
|
|
|
|
cd $GOPATH/src/github.com/ry/deno
|
|
|
|
|
|
|
|
make # Wait for redacted
|
|
|
|
|
|
|
|
./deno testdata/001_hello.js # Output: Hello World
|
2018-05-28 23:52:22 -04:00
|
|
|
```
|
|
|
|
|
2018-06-08 04:38:47 -04:00
|
|
|
## `make` commands
|
2018-05-18 12:25:59 -04:00
|
|
|
|
2018-05-31 14:31:37 -04:00
|
|
|
``` bash
|
|
|
|
make deno # Builds the deno executable.
|
2018-05-19 05:53:29 -04:00
|
|
|
|
|
|
|
make test # Runs the tests.
|
|
|
|
|
|
|
|
make fmt # Formats the code.
|
|
|
|
|
|
|
|
make clean # Cleans the build.
|
|
|
|
```
|
2018-05-28 23:52:22 -04:00
|
|
|
|