From 752db39dbc046053a28edf823bad3a7888754801 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 8 Sep 2020 13:12:26 -0400 Subject: [PATCH 1/4] Support "esm" as an alias of "es" format I constantly get tripped up by this. It compiles without errors, but writes an ES Module to the configured CJS output file. --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 7e1a8ee2..06ed4b90 100644 --- a/src/index.js +++ b/src/index.js @@ -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)); From a2bb3229d2e47102114e07c236370b21816b91c5 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 8 Sep 2020 13:14:40 -0400 Subject: [PATCH 2/4] Create hip-papayas-pretend.md --- .changeset/hip-papayas-pretend.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hip-papayas-pretend.md diff --git a/.changeset/hip-papayas-pretend.md b/.changeset/hip-papayas-pretend.md new file mode 100644 index 00000000..120a8ac4 --- /dev/null +++ b/.changeset/hip-papayas-pretend.md @@ -0,0 +1,5 @@ +--- +"microbundle": patch +--- + +Support "esm" (`-f esm`) as an alias of "es" format. From b2c4b030cc60451602e7ff43b7a4e559a375536d Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 8 Sep 2020 13:15:27 -0400 Subject: [PATCH 3/4] prettier --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 06ed4b90..f81f9f23 100644 --- a/src/index.js +++ b/src/index.js @@ -84,7 +84,7 @@ export default async function microbundle(inputOptions) { 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))); + 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)); From 217672719f0c5c2e5d34fd3802a60dd99aacbfb0 Mon Sep 17 00:00:00 2001 From: Leah Date: Mon, 28 Sep 2020 01:12:06 +0000 Subject: [PATCH 4/4] update snapshots --- test/__snapshots__/index.test.js.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index d78a502b..f7c747f6 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -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`;