-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
esm
package locally when testing to use ESM syntax from CJS code
These changes are primarily aiming for having an acceptable developer experience when working on changes locally and want to run the test suite. By using `esm` as a required package to be executed *before* the individual test files are executed, `esm` allows CommonJS/`require()` based code to use code written with ES Modules syntax. In practise that means our existing CommonJS based test suite that is `require()`ing the source code witten in ES Modules, is seamless and totally transparent. It just works without any build or transpiling pipeline like `babel` involved. Caveat: the `esm` package only support Node.js 6.x and above. That is more than okey, as we've got continous integration to verify how our changes works on different versions of Node.js, browsers & deno. Refs https://www.npmjs.com/package/esm
- Loading branch information
Showing
4 changed files
with
47 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
cjs: { | ||
// Ensure ESM `export default` ends up as the root, e.g. `module.exports` when | ||
// being `require()`d from CJS code. This is not spec compliant, but that does | ||
// not matter because only use this `esm` package trickery locally while testing | ||
dedefault: true | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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