Skip to content

Commit

Permalink
feat: make it way faster
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Jul 28, 2024
1 parent 61418c2 commit bd7fb43
Show file tree
Hide file tree
Showing 13 changed files with 734 additions and 266 deletions.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
# impvol

> Import scripts and modules from virtual filesystems!
> Import scripts and modules from virtual filesystems with [memfs](https://npm.im/memfs)!
## Usage

```ts
import {memfs} from 'memfs';
import {impvol} from 'impvol';

const {vol} = memfs({
'/foo.mjs': 'export const foo = 42;',
'/bar.cjs': 'exports.bar = 42;',
});

// ivol is a new Volume
const ivol = impvol(vol);

await ivol.promises.writeFile('/baz.mjs', 'export const baz = 42;');

const foo = await import('/foo.mjs'); // {foo: 42}
const bar = await import('/bar.cjs'); // {bar: 42}
const baz = await import('/baz.mjs'); // {baz: 42}
```

This should be a _drop-in replacement_ for a `memfs` `Volume`, but it isn't quite there.

> [!CAUTION]
>
> - This lib monkeypatches `memfs` internals. _I'm_ not really comfortable with that, and you shouldn't be either.
> - Does not yet support JSON.
> - WASM support is unknown.
> - Interaction with other loaders is unknown.
## Requirements

- Node.js v20.0.0+
- `memfs` v4.0.0+

## Installation

```sh
npm install impvol memfs -D
```

## License

©️ 2024 Christopher "boneskull" Hiller. Licensed Apache-2.0
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export default tseslint.config(

'n/no-unpublished-import': 'off',

// seems to be incompatible with tshy
'n/no-extraneous-import': 'off',

// I like my template expressions, tyvm
'@typescript-eslint/restrict-template-expressions': 'off',

Expand Down Expand Up @@ -127,4 +130,10 @@ export default tseslint.config(
'n/no-missing-import': ['error', {allowModules: ['impvol']}],
},
},
{
files: ['test/**/*.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
},
},
);
Loading

0 comments on commit bd7fb43

Please sign in to comment.