@sinclair/esbuild-wasm-resolve
TypeScript icon, indicating that this package has built-in type declarations

0.8.1 • Public • Published

esbuild-wasm-resolve

File Resolution for Esbuild running in the Browser

          import { App } from './index.ts'            

┌──────────────┐                      ┌──────────────┐
│              │ ─── '/index.ts' ───> │              │
│ esbuild-wasm │                      │   resolver   │
│              │ <───── [code] ────── │              │
└──────────────┘                      └──────────────┘


npm version

Overview

esbuild-wasm-resolve is a file resolver for esbuild-wasm. Due to Web Browsers not having direct access to a file system, esbuild-wasm-resolve intercepts file read requests made by esbuild during compilation allowing applications to resolve files externally. With this mechanism, esbuild can resolve files from IndexedDB, LocalStorage, Http or any other readable device accessible to the browser.

esbuild-wasm-resolve is primarily made with editors in mind. It is offered as is to anyone who may find it of use.

License MIT

Install

$ npm install @sinclair/esbuild-wasm-resolve

Usage

The following shows general usage.

import { Compiler } from '@sinclair/esbuild-wasm-resolve'

const compiler = new Compiler({
    
    resolve: path => fetch('http://localhost:5000' + path).then(res => res.text())

}, { wasmURL: 'esbuild.wasm' })

const code = await compiler.compile('/index.ts', { format: 'esm' })
//
//                                   ^ http://localhost:5000/index.ts

console.log(code)

Refer to the example here for additional usage.

Package Sidebar

Install

npm i @sinclair/esbuild-wasm-resolve

Weekly Downloads

1

Version

0.8.1

License

MIT

Unpacked Size

32.1 kB

Total Files

18

Last publish

Collaborators

  • sinclair