Package Exports
- @kwruntime/core
- @kwruntime/core/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kwruntime/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
kwruntime
kwruntime is a custom nodejs runtime inspired by Deno / Babel. Is the best of both worlds, the simplicity of importing urls and typescript, with all nodejs ecosystem. kwruntime is fast and doesn't have depedencies. Can work as a module for nodejs, or as a runtime.
- Supports typescript out the box
- Full ES2020 Syntax
- Dynamic import supported
- Import from urls with ESM syntax
- Import from NPM in one line with ESM syntax
- Import from github and gitlab with ESM syntax
- Full nodejs ecosystem
kwruntime is the replacement of @kawix/core
Installation
There are many options for installing kwruntime. You can install in any nodejs supported platform: Linux, Windows, Mac, Android, etc.
In Android you can install using Termux (recommended Termux from F-Droid)
- Linux (supported:
x64, armv7, arm64)
curl https://cdn.jsdelivr.net/gh/kwruntime/core@986e359/install/linux.sh | bash- Windows
Installer 32/64 bits: https://github.com/kwruntime/core/releases/tag/win32-installer. The installer automatically download the last version.
- Android (with Termux)
curl https://cdn.jsdelivr.net/gh/kwruntime/core@a60e7b8/install/android.sh | bash- Linux, Mac, Android with
nodejs(please version 12 or higher)
Prerequisites: Install nodejs from https://nodejs.org/es/download/ or using distro package manager.
In Android Termux you can install using: pkg install nodejs-lts or pkg install nodejs
curl https://cdn.jsdelivr.net/gh/kwruntime/core@986e359/install/node.sh | bash- Install from git in any node supported platform (Linux, Mac, Windows, Android, etc)
> git clone https://github.com/kwruntime/core kwruntime
> cd kwruntime
> node index --self-install- Install from NPM registry
npm install -g @kwruntime/core
kwrun --self-install
# or
yarn global add @kwruntime/core
kwrun --self-install
# or
pnpm add @kwruntime --global
kwrun --self-install- Execute without install
npx @kwruntime/core github://kwruntime/std@808cb57/util/hello.tsGet started
- Import from github/gitlab
# Syntax: github://USER/Repo@Tag_or_Commit/path/to/script.ts
> kwrun "github://kwruntime/std@808cb57/util/hello.ts"
[kwruntime] Compiling: https://raw.githubusercontent.com/kwruntime/std/808cb57/util/hello.ts
Welcome to @kwruntime/core 🥝😉You can also import from gitlab.com using gitlab://
- Import any npm module in one line (internally uses yarn, but maybe will use pnpm in the future)
import Express from 'npm://express@4.17.1'
main()
async function main(){
const app = Express()
app.get('/', function (req, res) {
res.send('Hello World')
})
app.listen(3000)
console.info("HTTP Server running on 127.0.0.1:3000")
}- Import from URLs (like deno), for example import npm modules in one line using esm.sh
import * as Luxon from "https://esm.sh/luxon@2.3.0"
const date = Luxon.DateTime.now().toFormat("yyyy-MM-dd")
console.info(date)you will get a output like this:
> kwrun luxon_test.ts
[kwruntime] Compiling: /home/ubuntu/scripts/luxon_test.ts
[kwruntime] Compiling: https://esm.sh/luxon
[kwruntime] Compiling: https://cdn.esm.sh/v43/luxon@2.0.1/es2020/luxon.js
2022-01-04NOTE: When you import URLs the content is cached on disk. For this reason is preferrable when you import, specify an URL containing version, tag, or commit.
Using from Node.js
const {kwruntime} = require("@kwruntime/core")
kwruntime.import("github://kwruntime/std@808cb57/util/hello.ts")const {kwruntime} = require("@kwruntime/core")
async function main(){
const Luxon = await kwruntime.import("https://esm.sh/luxon@2.3.0")
const date = Luxon.DateTime.now().toFormat("yyyy-MM-dd")
console.info(date)
}
Plugin for VSCode
You can get intelissense in your editor using: https://github.com/kwruntime/vscode-plugin
Contribute
Contributors are welcome.