@gongt/fix-esm
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

fix-esm

fix ERR_REQUIRE_ESM with realtime esbuild transform.

require('@gongt/fix-esm') will register legacy commonjs loader. (and no way to unregister)

When ERR_REQUIRE_ESM happen, it will spawn esbuild to compile target file. loaded module will inside require cache. compiled result will save at filename.jsc to speed up next run.

Do nothing when import '@gongt/fix-esm';, so if you have project compile to esm, it import 'cjs-module', then cjs-module do require('esm-module'), this package will not handle.

It's best to use this package in a final-end-user project, not in a library, many people have thier own fix-esm method, may cause conflict.

/@gongt/fix-esm/

    Package Sidebar

    Install

    npm i @gongt/fix-esm

    Weekly Downloads

    3

    Version

    1.0.3

    License

    WTFPL

    Unpacked Size

    7.25 kB

    Total Files

    8

    Last publish

    Collaborators

    • gongt