@file-services/commonjs
TypeScript icon, indicating that this package has built-in type declarations

9.2.1 • Public • Published

@file-services/commonjs

npm version package size

Isomorphic, fs-agnostic implementation of Node's CommonJS module system.

Getting started

Install library in project:

npm i @file-services/commonjs

Then, use the programmatic API:

import { createCjsModuleSystem } from "@file-services/commonjs";
import { createMemoryFs } from "@file-services/memory";

const fs = createMemoryFs({
  "some-folder": {
    "index.js": `module.exports = 'exported value'`,
  },
});

const moduleSystem = createCjsModuleSystem({ fs });

const evaluated = moduleSystem.requireModule("/some-folder/index.js");
// evaluated === 'exported value'

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @file-services/commonjs

Weekly Downloads

558

Version

9.2.1

License

MIT

Unpacked Size

51.1 kB

Total Files

22

Last publish

Collaborators

  • avi.vahl
  • pistolpete_
  • tomermes
  • cijoe