Bradley Farias
Bradley Farias
Example requested by https://twitter.com/dan_abramov/status/806506649544491008 This plugin maps `import()` to `require.ensure()` `import` returns the [ModuleNamespaceObject](https://tc39.github.io/ecma262/#sec-module-namespace-objects) of an ESM. `require.ensure` returns the value of `module.exports` directly. CJS interop with ESM **cannot** create...
ah, conversely in the current code: ```js (await import('fs')).default.readFile; ``` Does not work, since it doesn't shadow nor wrap `default`
@Kovensky I've had talks w/ typescript in the past about this, they are aware. This behavior also affects `import` declarations.
@ljharb can we at least properly set the `default`?
@ljharb no, you need something like: ```js (new Promise((resolve) => { require.ensure([], (require) => { var ns = require(SOURCE); if (ns && ns.__esModule) { resolve(ns); } else { var wrapper...
@ljharb existing shim in babel below: ```js function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for...
@Kovensky sounds good. eventually would be interested in [test262](https://github.com/tc39/test262) being brought into all this to see % compliance for babel: ```sh TEST_FILES="$(find test262/test -name \*.js)" mkdir compiled-test262 for FILE in...
@Kovensky ```ts // test.ts import {version} from 'express'; import express from 'express'; import * as expressNS from 'express'; import expressAssign = require('express'); console.log(version); express(); console.log(expressNS.version); console.log(expressAssign.version); export default function defaultExport()...
bins are symlinked, the module system still eventually resolves it to an absolute path. From there you can find the package.json. A bin to support both CJS and ES entry...
Even loaders somewhat want something like this outside loaders. I like the use case and it is possible to do this with policies today to error outside a directory but...