Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sinclairzx81/esbuild-wasm-resolve
File Resolution for Esbuild running in the Browser
https://github.com/sinclairzx81/esbuild-wasm-resolve
esbuild filesytem resolve wasm
Last synced: 3 months ago
JSON representation
File Resolution for Esbuild running in the Browser
- Host: GitHub
- URL: https://github.com/sinclairzx81/esbuild-wasm-resolve
- Owner: sinclairzx81
- License: other
- Created: 2022-07-31T10:22:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-31T10:43:22.000Z (over 2 years ago)
- Last Synced: 2024-10-13T19:33:44.355Z (3 months ago)
- Topics: esbuild, filesytem, resolve, wasm
- Language: TypeScript
- Homepage:
- Size: 2.57 MB
- Stars: 21
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
esbuild-wasm-resolve
File Resolution for Esbuild running in the Browser
import { App } from './index.ts'┌──────────────┐ ┌──────────────┐
│ │ ─── '/index.ts' ───> │ │
│ esbuild-wasm │ │ resolver │
│ │ <───── [code] ────── │ │
└──────────────┘ └──────────────┘
[![npm version](https://badge.fury.io/js/%40sinclair%2Fesbuild-wasm-resolve.svg)](https://badge.fury.io/js/%40sinclair%2Fesbuild-wasm-resolve)
## 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
```bash
$ npm install @sinclair/esbuild-wasm-resolve
```## Usage
The following shows general usage.
```typescript
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.tsconsole.log(code)
```Refer to the example [here](https://github.com/sinclairzx81/esbuild-wasm-resolve/tree/main/example) for additional usage.