From c1e3489c6e400998fa6228162437ba21a05b3761 Mon Sep 17 00:00:00 2001 From: Charles Pierce Date: Thu, 11 Feb 2021 17:17:00 -0800 Subject: [PATCH] Exclude 'babel-plugin-compact-reexports' during Stage 1 build --- packages/compat/src/detect-compact-reexports.ts | 13 +++++++++++++ packages/compat/src/v1-addon.ts | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 packages/compat/src/detect-compact-reexports.ts diff --git a/packages/compat/src/detect-compact-reexports.ts b/packages/compat/src/detect-compact-reexports.ts new file mode 100644 index 000000000..318d00b03 --- /dev/null +++ b/packages/compat/src/detect-compact-reexports.ts @@ -0,0 +1,13 @@ +import { PluginItem } from '@babel/core'; + +export function isCompactReexports(item: PluginItem): boolean { + let pluginPath: string; + if (typeof item === 'string') { + pluginPath = item; + } else if (Array.isArray(item) && item.length > 0 && typeof item[0] === 'string') { + pluginPath = item[0]; + } else { + return false; + } + return /(^|\/)babel-plugin-compact-reexports\//.test(pluginPath); +} diff --git a/packages/compat/src/v1-addon.ts b/packages/compat/src/v1-addon.ts index 37b8b7b21..4e400c377 100644 --- a/packages/compat/src/v1-addon.ts +++ b/packages/compat/src/v1-addon.ts @@ -23,6 +23,7 @@ import modulesCompat from './modules-compat'; import writeFile from 'broccoli-file-creator'; import SynthesizeTemplateOnlyComponents from './synthesize-template-only-components'; import { isEmberAutoImportDynamic } from './detect-ember-auto-import'; +import { isCompactReexports } from './detect-compact-reexports'; import { ResolvedDep } from '@embroider/core/src/resolver'; const stockTreeNames = Object.freeze([ @@ -1006,6 +1007,12 @@ function babelPluginAllowedInStage1(plugin: PluginItem) { return false; } + if (isCompactReexports(plugin)) { + // We don't want to replace re-exports at this stage, since that will turn + // an `export` statement into a `define`, which is handled in Stage 3 + return false; + } + return true; }