Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
quickjs-emscripten-core
Advanced tools
This package is part of quickjs-emscripten, a Javascript interface for QuickJS compiled to WebAssembly via Emscripten.
This package (quickjs-emscripten-core
) contains only Javascript code - no WebAssembly. To use this package, you'll need to install one or more variants of the QuickJS WebAssembly build, see available variants below.
// 1. Import a QuickJS module constructor function from quickjs-emscripten-core
import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core"
// 2. Import a variant suitable for your use case. For example, if you only care to
// target with the fastest execution speed, import the release build variant
import releaseVariant from "@jitl/quickjs-singlefile-cjs-release-sync"
// 3. Create the "QuickJS" module that presents the quickjs-emscripten API.
// Export and use in other files, or consume directly.
const QuickJS = await newQuickJSWASMModuleFromVariant(releaseVariant)
A variant describes how to load a QuickJS WebAssembly build and how to call the low-level C API functions used by the higher-level abstractions in quickjs-emscripten-core
. A variant is an object with the following properties:
const variant = {
// This should be `async` if the variant is built with ASYNCIFY
// so that the WebAssembly module execution can be suspended.
//
// Otherwise, this should be `sync`.
type: "sync",
// This should be a function that resolves to a QuickJSFFI class.
importFFI: () => import("something/ffi.ts").then((mod) => mod.QuickJSFFI),
// This should be a function that resolves to a Emscripten-shaped WASM module factory.
importModuleLoader: () => import("something/emscripten-module.ts"),
}
You can provide your own variant to control exactly how the large WebAssembly object is loaded. quickjs-emscripten-core
will call your variant's importXYZ methods during newQuickJSWASMModuleFromVariant
or newQuickJSAsyncWASMModuleFromVariant
.
You can use subpath imports in package.json to select the appropriate variant for a runtime. This is how the main quickjs-emscripten
package picks between browser, Node ESM and Node CommonJS variants.
// in your package.json
{
"imports": {
"#my-quickjs-variant": {
"types": "@jitl/quickjs-wasmfile-release-sync",
// In the browser, use the singlefile variant that doesn't need an external file
"browser": "@jitl/quickjs-singlefile-browser-release-sync",
// Otherwise, use the wasmfile variant, compatible with all environments
"default": "@jitl/quickjs-wasmfile-release-sync"
}
}
}
// In your code
import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core"
import variant from "#my-quickjs-variant"
const QuickJS = await newQuickJSWASMModuleFromVariant(variant)
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. |
exports | require import browser workerd | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | require | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | require | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | require | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | require | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a NodeJS ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | import | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a NodeJS ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | import | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a NodeJS ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | import | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a NodeJS ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | import | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a browser ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | browser | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a browser ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | browser | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a browser ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | browser | Has these package.json export conditions |
Docs | Variant with the WASM data embedded into a browser ESModule.
Variable | Setting | Description |
---|---|---|
releaseMode | release | Optimized for performance; use when building/deploying your application. |
syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs. |
emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. |
exports | browser | Has these package.json export conditions |
v0.27.0
wasmMemory: WebAssembly.Memory
option for newVariant
, and mod.getWasmMemory()
method for QuickJS[Async]WASMModule
.using
statement.Symbol.for('Symbol.dispose')
if Symbol.dispose
isn't defined globally.FAQs
Unknown package
The npm package quickjs-emscripten-core receives a total of 21,209 weekly downloads. As such, quickjs-emscripten-core popularity was classified as popular.
We found that quickjs-emscripten-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.