14.0.4 • Published 2 months ago

@textlint/module-interop v14.0.4

Weekly downloads
16,271
License
MIT
Repository
github
Last release
2 months ago

@textlint/module-interop

ECMAScript module interop library.

import .default from ES module or CommonJS module.

example.mjs

const value = 42;

export default value;
import {moduleInterop} from "@textlint/module-interop";

// Doesn't matter if `require` uses `module.exports` or ES Module `export`
const value = moduleInterop(require("./example"));
console.log(value);  // 42

Notes: This library is for common use. This library is not depended on textlint.

Why it is needed?

Some rule modules use export default.

If you creating rule preset for textlint, you should wrap the required result.

const rule = require("textlint-rule-es-export-default-example");
console.log(rule); // { default: ruleImplementation } 

This library resolve this issue by moduleInterop function.

const {moduleInterop} = require("@textlint/module-interop");
const rule = moduleInterop(require("textlint-rule-es-export-default-example"));
console.log(rule); // ruleImplementation

Install

Install with npm:

npm install @textlint/module-interop

Usage

const {moduleInterop} = require("@textlint/module-interop");
const rule = moduleInterop(require("textlint-rule-example")); // rule implementation

Related

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

14.0.4

2 months ago

14.0.3

2 months ago

14.0.2

3 months ago

14.0.1

3 months ago

14.0.0

3 months ago

13.4.2-next.0

3 months ago

13.4.1

5 months ago

13.3.3

10 months ago

13.4.0

6 months ago

13.3.2

1 year ago

13.3.1

1 year ago

13.1.3

1 year ago

13.1.4

1 year ago

13.0.5

1 year ago

13.2.0

1 year ago

13.1.1

1 year ago

13.3.0

1 year ago

13.1.2

1 year ago

13.1.0

1 year ago

13.0.4

1 year ago

13.0.2

1 year ago

13.0.3

1 year ago

13.0.0

1 year ago

13.0.1

1 year ago

12.6.1

1 year ago

12.5.2

1 year ago

12.3.0

1 year ago

12.5.0

1 year ago

12.6.0

1 year ago

12.2.3

1 year ago

12.2.2

2 years ago

12.2.1

2 years ago

12.2.0

2 years ago

12.1.1

2 years ago

12.1.0

2 years ago

12.0.2

3 years ago

12.0.0-beta.3

3 years ago

12.0.0-beta.0

3 years ago

12.0.0-beta.1

3 years ago

12.0.0

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.5

3 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago