Skip to content

Commit

Permalink
Exclude 'babel-plugin-compact-reexports' during Stage 1 build
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespierce committed Mar 1, 2021
1 parent ed5e9bc commit c1e3489
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/compat/src/detect-compact-reexports.ts
Original file line number Diff line number Diff line change
@@ -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);
}
7 changes: 7 additions & 0 deletions packages/compat/src/v1-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c1e3489

Please sign in to comment.