Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint/build ~ CJS+ESM packaging + deno support
- ref: [Node Modules at War](https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1) @@ <https://archive.is/zl0qg> - ref: [yargs ~ 'Road to ESM/Deno'](yargs/yargs#1706) ## discussion As suggested in "Node Modules at War", an ESM wrapper is used to provide basic ESM support. However, `deno` is unable to use that ESM module, failing to load the transitive CJS module with `'../index.js' does not provide an export named 'default'`. So, `deno` is instead referred to a full ESM transpile. As `deno` is it's own animal, there is no issue with CJS and ESM referring to differing modules, either for installation or creating subtle code issues.
- Loading branch information
Showing
4 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// # spell-checker:ignore Deno | ||
import _ from '../index.js'; | ||
// note: not usable by `deno`; | ||
// ...`deno` is unable to (the CJS module) '../index.js' via import => `'../index.js' does not provide an export named 'default'` | ||
|
||
// export const OSPathsWithAdaption = _['_esm!'].OSPathsWithAdaption; | ||
// const default_ = _['_esm!'].default; | ||
// export default default_; | ||
const default_ = _; | ||
export default default_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type": "module"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters