Skip to content

Commit

Permalink
Support "esm" as an alias of "es" format (#722)
Browse files Browse the repository at this point in the history
Co-authored-by: Leah <[email protected]>
  • Loading branch information
developit and ForsakenHarmony authored Sep 28, 2020
1 parent 0fec414 commit 0527862
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-papayas-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"microbundle": patch
---

Support "esm" (`-f esm`) as an alias of "es" format.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default async function microbundle(inputOptions) {
options.multipleEntries = options.entries.length > 1;

let formats = (options.format || options.formats).split(',');
// de-dupe formats and convert "esm" to "es":
formats = Array.from(new Set(formats.map(f => (f === 'esm' ? 'es' : f))));
// always compile cjs first if it's there:
formats.sort((a, b) => (a === 'cjs' ? -1 : a > b ? 1 : 0));

Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1615,14 +1615,14 @@ Directory tree:
define-expression
dist
define-expression.js
define-expression.esm.js
index.js
package.json
Build \\"defineExpression\\" to dist:
56 B: define-expression.js.gz
40 B: define-expression.js.br"
56 B: define-expression.esm.js.gz
40 B: define-expression.esm.js.br"
`;
exports[`fixtures build define-expression with microbundle 2`] = `1`;
Expand Down

0 comments on commit 0527862

Please sign in to comment.