You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an attempt at a multiple ESM edition autoloader to test if the foundations are possible. It seems they are not, as it returns a promise, as dynamic imports return promises, so the exports will be promises, which is inconsistent API with the CJS Autoloader.
For editions v4, it can be accomplished via a index.mjs file like so:
'use strict'
// auto-generated by boundation, do not update manually
/** @type {typeof import("./compiled-types/index.d.ts") } */
import { requirePackage } from 'editions'
import filedirname from 'filedirname'
const [__filename, __dirname] = filedirname(import.meta.url)
const pkg = await requirePackage(__dirname, (path) => import(path))
export default pkg.default || pkg
However, this still suffers from the promise return, and causes incompatibilities with anything but the default export:
// doesn't work via the autoloader
// import { nullish } from './index.mjs'
// nullish(null, 'nullish worked')
// autoloader requires
import pkg from './index.mjs'
pkg.nullish(null, 'nullish worked')
// direct consumption requires
import { nullish } from './edition-esnext-esm/index.js'
nullish(null, 'nullish worked')
As such, there will need to be a way to write static exports for everything, or boundation must only generate one esm edition, and not use an esm autoloader.
Here is an attempt at a multiple ESM edition autoloader to test if the foundations are possible. It seems they are not, as it returns a promise, as dynamic imports return promises, so the exports will be promises, which is inconsistent API with the CJS Autoloader.
As such, only a single ESM edition for Node seems to be able to be supported by packages.
The text was updated successfully, but these errors were encountered: