cross-import
v3.1.7
Published
Import .ts, .mjs, .cjs files across environments as JavaScript modules
Downloads
4,875
Maintainers
Readme
Solved Problems
As far as is generally known:
- Cannot import ESM modules in CJS
- Cannot use ESM dynamic import in CJS
- Cannot use CJS dynamic require in ESM
- Cannot import .ts config in .js .cjs .mjs
- Cannot mix .js .cjs .mjs packages
Getting Started
npm install cross-import
Usage
import crossImport from 'cross-import'
crossImport(modulePath: string): any
Import .ts
in .js
foo.ts
export * from './bar'
export const foo = 'foo'
bar.ts
export const bar = 'bar'
index.js
crossImport('./foo.ts')
// {"bar": "bar", "foo": "foo"}