@@ -27,7 +27,7 @@ const testDependencies = [
2727
2828let configs = [
2929 esmConfig ( ) ,
30- esmTemplateCompiler ( ) ,
30+ esmProdConfig ( ) ,
3131 legacyBundleConfig ( './broccoli/amd-compat-entrypoints/ember.debug.js' , 'ember.debug.js' , {
3232 isDeveloping : true ,
3333 } ) ,
@@ -55,61 +55,69 @@ export default configs;
5555
5656function esmConfig ( ) {
5757 return sharedESMConfig ( {
58- input : {
59- ...renameEntrypoints ( exposedDependencies ( ) , ( name ) => join ( 'packages' , name , 'index' ) ) ,
60- ...renameEntrypoints ( packages ( ) , ( name ) => join ( 'packages' , name ) ) ,
61- } ,
58+ input : esmInputs ( ) ,
6259 debugMacrosMode : '@embroider/macros' ,
60+ includePackageMeta : true ,
6361 } ) ;
6462}
6563
66- function esmTemplateCompiler ( ) {
64+ function esmProdConfig ( ) {
6765 return sharedESMConfig ( {
68- input : {
69- // the actual authored "./packages/ember-template-compiler/index.ts" is
70- // part of what powers the historical dist/ember-template-compiler.js AMD
71- // bundle. It has historical cruft that has never been present in our ESM
72- // builds.
73- //
74- // On the ESM build, the main entrypoint of ember-template-compiler is the
75- // "minimal.ts" version, which has a lot less in it.
76-
77- 'packages/ember-template-compiler/index' : 'ember-template-compiler/minimal.ts' ,
78- } ,
79- // the template compiler is always in debug mode (and doesn't use
80- // embroider/macros, so it's directly invokable on node)
81- debugMacrosMode : true ,
66+ input : esmInputs ( ) ,
67+ debugMacrosMode : 'production' ,
8268 } ) ;
8369}
8470
85- function sharedESMConfig ( { input, debugMacrosMode } ) {
71+ function esmInputs ( ) {
72+ return {
73+ ...renameEntrypoints ( exposedDependencies ( ) , ( name ) => join ( 'packages' , name , 'index' ) ) ,
74+ ...renameEntrypoints ( packages ( ) , ( name ) => join ( 'packages' , name ) ) ,
75+ // the actual authored "./packages/ember-template-compiler/index.ts" is
76+ // part of what powers the historical dist/ember-template-compiler.js AMD
77+ // bundle. It has historical cruft that has never been present in our ESM
78+ // builds.
79+ //
80+ // On the ESM build, the main entrypoint of ember-template-compiler is the
81+ // "minimal.ts" version, which has a lot less in it.
82+
83+ 'packages/ember-template-compiler/index' : 'ember-template-compiler/minimal.ts' ,
84+ } ;
85+ }
86+
87+ function sharedESMConfig ( { input, debugMacrosMode, includePackageMeta = false } ) {
88+ let outputDir = debugMacrosMode === 'production' ? 'dist-prod' : 'dist' ;
8689 let babelConfig = { ...sharedBabelConfig } ;
8790 babelConfig . plugins = [ ...babelConfig . plugins , canaryFeatures ( ) ] ;
8891
92+ let plugins = [
93+ importMetaRemoval ( debugMacrosMode ) ,
94+ babel ( {
95+ babelHelpers : 'bundled' ,
96+ extensions : [ '.js' , '.ts' ] ,
97+ configFile : false ,
98+ ...babelConfig ,
99+ } ) ,
100+ resolveTS ( ) ,
101+ version ( ) ,
102+ resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
103+ pruneEmptyBundles ( ) ,
104+ ] ;
105+
106+ if ( includePackageMeta ) {
107+ plugins . push ( packageMeta ( ) ) ;
108+ }
109+
89110 return {
90111 onLog : handleRollupWarnings ,
91112 input,
92113 output : {
93114 format : 'es' ,
94- dir : 'dist' ,
115+ dir : outputDir ,
95116 hoistTransitiveImports : false ,
96117 generatedCode : 'es2015' ,
97118 chunkFileNames : 'packages/shared-chunks/[name]-[hash].js' ,
98119 } ,
99- plugins : [
100- importMetaRemoval ( debugMacrosMode ) ,
101- babel ( {
102- babelHelpers : 'bundled' ,
103- extensions : [ '.js' , '.ts' ] ,
104- configFile : false ,
105- ...babelConfig ,
106- } ) ,
107- resolveTS ( ) ,
108- version ( ) ,
109- resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
110- pruneEmptyBundles ( ) ,
111- packageMeta ( ) ,
112- ] ,
120+ plugins,
113121 } ;
114122}
115123
@@ -642,11 +650,15 @@ function pruneEmptyBundles() {
642650function packageMeta ( ) {
643651 return {
644652 name : 'package-meta' ,
645- generateBundle ( ) {
653+ generateBundle ( _outputOptions , bundle ) {
646654 let renamedModules = Object . fromEntries (
647- glob
648- . sync ( 'packages/**/*.js' , { cwd : 'dist' , nodir : true } )
649- . filter ( ( name ) => ! name . startsWith ( 'packages/shared-chunks/' ) )
655+ Object . keys ( bundle )
656+ . filter (
657+ ( name ) =>
658+ name . startsWith ( 'packages/' ) &&
659+ ! name . startsWith ( 'packages/shared-chunks/' ) &&
660+ name . endsWith ( '.js' )
661+ )
650662 . sort ( )
651663 . map ( ( name ) => {
652664 return [
0 commit comments