@0x706b/ts-transform-fix-esm

This transformer is experimental; use it at your own risk.

Usage no npm install needed!

<script type="module">
  import 0x706bTsTransformFixEsm from 'https://cdn.skypack.dev/@0x706b/ts-transform-fix-esm';
</script>

README

ts-transform-fix-esm

Disclaimer

This transformer is experimental; use it at your own risk.

Description

Adds file extension and/or index to module specifiers and correctly requires commonjs modules in an ESM environment.

For example:

import { thing } from "commonjs/file";
import { anotherThing } from "esm/folder"

becomes

import { anotherThing } from "esm/folder/index.js";
import { createRequire as __createRequire } from "module";
const __require = __createRequire(import.meta.url);
const { thing } = require(commonjs/file);