From a69e85d8d5c3ae4b627927752c105cd5ae6dad6c Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Mon, 22 Feb 2021 20:09:55 +0200 Subject: [PATCH] fix(commonjs): `isRestorableCompiledEsm` should also trigger code transform (#816) --- packages/commonjs/src/transform-commonjs.js | 3 ++- .../form/compiled-esm-define-exports-empty/input.js | 1 + .../form/compiled-esm-define-exports-empty/output.js | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/input.js create mode 100644 packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/output.js diff --git a/packages/commonjs/src/transform-commonjs.js b/packages/commonjs/src/transform-commonjs.js index d019cff90..0f6b54060 100644 --- a/packages/commonjs/src/transform-commonjs.js +++ b/packages/commonjs/src/transform-commonjs.js @@ -437,7 +437,8 @@ export default function transformCommonjs( uses.exports || uses.require || uses.commonjsHelpers || - hasRemovedRequire + hasRemovedRequire || + isRestorableCompiledEsm ) && (ignoreGlobal || !uses.global) ) { diff --git a/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/input.js b/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/input.js new file mode 100644 index 000000000..a6a850fe2 --- /dev/null +++ b/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/input.js @@ -0,0 +1 @@ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/output.js b/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/output.js new file mode 100644 index 000000000..43b03ffa5 --- /dev/null +++ b/packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/output.js @@ -0,0 +1,6 @@ +var input = /*#__PURE__*/Object.defineProperty({ + +}, '__esModule', {value: true}); + +export default input; +export { input as __moduleExports };