From aef6c2b9b5d4a62f20678b0aec16d839d994ea0a Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 16 Dec 2021 16:04:51 -0800 Subject: [PATCH] fix: Use statically analyzable CJS exports This enables named imports in node ESM scripts because they do some magic to detect which module is exported. --- packages/history/node-main.js | 10 ++++++---- scripts/rollup/history.config.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/history/node-main.js b/packages/history/node-main.js index 228b26e63..d2440db40 100644 --- a/packages/history/node-main.js +++ b/packages/history/node-main.js @@ -1,5 +1,7 @@ /* eslint-env node */ -module.exports = - process.env.NODE_ENV === 'production' - ? require('./umd/history.production.min.js') - : require('./umd/history.development.js'); + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./umd/history.production.min.js'); +} else { + module.exports = require('./umd/history.development.js'); +} diff --git a/scripts/rollup/history.config.js b/scripts/rollup/history.config.js index 9b323e27f..22ae8efa1 100644 --- a/scripts/rollup/history.config.js +++ b/scripts/rollup/history.config.js @@ -198,7 +198,7 @@ const node = [ file: `${OUTPUT_DIR}/main.js`, format: 'cjs' }, - plugins: [compiler()].concat(PRETTY ? prettier({ parser: 'babel' }) : []) + plugins: PRETTY ? prettier({ parser: 'babel' }) : [] } ];