Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A tiny JavaScript runtime

License

NotificationsYou must be signed in to change notification settings

saghul/txiki.js

Repository files navigation

txiki.js — The tiny JavaScript runtime

Overview

txikia (basque): small, tiny.

txiki.js is a small and powerful JavaScript runtime. It targets state-of-the-art ECMAScriptand aims to beWinterCG compliant.

It's built on the shoulders of giants: it usesQuickJS-ng as its JavaScript engine andlibuv as the platform layer.

See it in action here:

Building a tiny JavaScript runtime with QuickJS

Getting started

First head over tobuilding and build the runtime.

$ ./build/tjseval"console.log('hello world')"hello world$

If you want to run a script you can usetjs run:

$ ./build/tjs run examples/hello_world.jshello world$

Explore all the options:

$ ./build/tjs --help

For TS support see@txikijs/types.

Features

Support for theES2023 specification (almost complete).

WinterCG

txiki.js aims to beWinterCG compliant, you can track the progresshere.

Web Platform APIs

(1): All of them are async.

(2): No subtle support.

(3): No tables, globals or memory support.

Runtime features

  • Standalone executables
  • TCP and UDP sockets
  • Unix sockets / named pipes
  • Signal handling
  • File operations
  • Child processes
  • WASI
  • ...

See thefull API documentation.

Other extras:

  • Import directly from HTTP(S) URLs
  • Import JSON files
  • Builtin test runner

Standard library

The following modules compose the standard library:

Supported platforms

  • GNU/Linux
  • macOS
  • Windows (beta)
  • Other Unixes (please test!)

Building

CMake is necessary.

NOTE: The txiki.js build depends on a number of git submodules (libffi,libuv andwasm3).If you didn't already clone this repository recursively, make sure you initialize thesesubmodules withgit submodule update --init before proceeding to the build.

GNU/Linux

Install dependencies (libcurl,build-essential,cmake,makeinfo,autoreconf,libtool,libltdl-dev):

# On Debian / Ubuntusudo apt install libcurl4-openssl-dev build-essential cmake autoconf texinfo libtool libltdl-dev

macOS

Install dependencies (cmake,autoconf):

brew install cmake autoconf automake libtool texinfo

Unix systems

# Get the codegit clone --recursive https://github.com/saghul/txiki.js --shallow-submodules&&cd txiki.js# Compile it!make# Run the REPL./build/tjs

Windows (beta)

Windows support it's currently considered beta. Tests do pass, but building it is not as easy as it should be.

Building has only been tested in 64bit Windows.

Prerequisites

First make sure you haveMSYS2 installed. Themingw64 andclang64 environments are currently tested.

Then install the required dependencies:

pacman -S git make pactoyspacboy -S curl-winssl:p toolchain:p cmake:p ninja:p

Build

These commands must be run in a MinGW64 or clang64 shell.

make

This will build the executable just like on Unix. Note that at this point there are a number of dynamically linked libraries, so if you want to use the executable on a different system you'll need to copy those too. Check the list withldd build/tjs.exe.

Running the tests

Make sure these commands are run from Windows Terminal (mintty, what MSYS2 provides is not supported).

maketest

Customizing the build

If you are making a custom build and are modifying any of the JS files that arepart of the runtime, you'll need to regenerate the C code for them, so your changesbecome part of the build.

# First install the JS dependenciesnpm install# Now bundle the code and compile it into C source filesmake js

tjs compile - creating standalone executables

Creating standalone executables is possible withtjs compile. The resulting executablewill bundle the given code and the txiki.js runtime. No compiler is needed.

NOTE: The resulting executable will have the same runtime dependencies as thetjsexecutable.

Assuming abundle.js file with some JS code, the following command will createa standalone executable with it:

tjs compile bundle.js

The new executable will be calledbundle on Unix platforms andbundle.exe on Windows.The output name can be customized by passing a second option:

tjs compile bundle.js myexe

Thetjs compile command doesn't do any code bundling. If you need to bundle yourapp into a single JS file for use withtjs compile,esbuild can be a good option.Here is how to bundle an app into a singlebundle.js file:

npx esbuild my-app/index.js \    --bundle \    --outfile=bundle.js \    --external:tjs:* \    --minify \    --target=es2023 \    --platform=neutral \    --format=esm \    --main-fields=main,module

Versioning

txiki.js usescalendar versioning with the form YY.MM.MICRO.



Built with ❤️ by saghul and these awesomecontributors.


[8]ページ先頭

©2009-2025 Movatter.jp