@@ -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 } ) ,
@@ -57,64 +57,71 @@ export default configs;
5757
5858function esmConfig ( ) {
5959 return sharedESMConfig ( {
60- input : {
61- ...renameEntrypoints ( exposedDependencies ( ) , ( name ) => join ( 'packages' , name , 'index' ) ) ,
62- ...renameEntrypoints ( packages ( ) , ( name ) => join ( 'packages' , name ) ) ,
63- } ,
64- debugMacrosMode : '@embroider/macros' ,
60+ input : esmInputs ( ) ,
61+ debugMacrosMode : true ,
62+ includePackageMeta : true ,
6563 } ) ;
6664}
6765
68- function esmTemplateCompiler ( ) {
66+ function esmProdConfig ( ) {
6967 return sharedESMConfig ( {
70- input : {
71- // the actual authored "./packages/ember-template-compiler/index.ts" is
72- // part of what powers the historical dist/ember-template-compiler.js AMD
73- // bundle. It has historical cruft that has never been present in our ESM
74- // builds.
75- //
76- // On the ESM build, the main entrypoint of ember-template-compiler is the
77- // "minimal.ts" version, which has a lot less in it.
78-
79- 'packages/ember-template-compiler/index' : 'ember-template-compiler/minimal.ts' ,
80- } ,
81- // the template compiler is always in debug mode (and doesn't use
82- // embroider/macros, so it's directly invokable on node)
83- debugMacrosMode : true ,
68+ input : esmInputs ( ) ,
69+ debugMacrosMode : false ,
8470 } ) ;
8571}
8672
87- function sharedESMConfig ( { input, debugMacrosMode } ) {
73+ function esmInputs ( ) {
74+ return {
75+ ...renameEntrypoints ( exposedDependencies ( ) , ( name ) => join ( 'packages' , name , 'index' ) ) ,
76+ ...renameEntrypoints ( packages ( ) , ( name ) => join ( 'packages' , name ) ) ,
77+ // the actual authored "./packages/ember-template-compiler/index.ts" is
78+ // part of what powers the historical dist/ember-template-compiler.js AMD
79+ // bundle. It has historical cruft that has never been present in our ESM
80+ // builds.
81+ //
82+ // On the ESM build, the main entrypoint of ember-template-compiler is the
83+ // "minimal.ts" version, which has a lot less in it.
84+ 'packages/ember-template-compiler/index' : 'ember-template-compiler/minimal.ts' ,
85+ } ;
86+ }
87+
88+ function sharedESMConfig ( { input, debugMacrosMode, includePackageMeta = false } ) {
89+ let outputDir = debugMacrosMode === false ? 'dist-prod' : 'dist' ;
8890 let babelConfig = { ...sharedBabelConfig } ;
8991 babelConfig . plugins = [
9092 ...babelConfig . plugins ,
9193 buildDebugMacroPlugin ( debugMacrosMode ) ,
9294 canaryFeatures ( ) ,
9395 ] ;
9496
97+ let plugins = [
98+ babel ( {
99+ babelHelpers : 'bundled' ,
100+ extensions : [ '.js' , '.ts' ] ,
101+ configFile : false ,
102+ ...babelConfig ,
103+ } ) ,
104+ resolveTS ( ) ,
105+ version ( ) ,
106+ resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
107+ pruneEmptyBundles ( ) ,
108+ ] ;
109+
110+ if ( includePackageMeta ) {
111+ plugins . push ( packageMeta ( ) ) ;
112+ }
113+
95114 return {
96115 onLog : handleRollupWarnings ,
97116 input,
98117 output : {
99118 format : 'es' ,
100- dir : 'dist' ,
119+ dir : outputDir ,
101120 hoistTransitiveImports : false ,
102121 generatedCode : 'es2015' ,
103122 chunkFileNames : 'packages/shared-chunks/[name]-[hash].js' ,
104123 } ,
105- plugins : [
106- babel ( {
107- babelHelpers : 'bundled' ,
108- extensions : [ '.js' , '.ts' ] ,
109- configFile : false ,
110- ...babelConfig ,
111- } ) ,
112- resolveTS ( ) ,
113- version ( ) ,
114- resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
115- pruneEmptyBundles ( ) ,
116- packageMeta ( ) ,
117- ] ,
124+ plugins,
118125 } ;
119126}
120127
@@ -193,7 +200,7 @@ function renameEntrypoints(entrypoints, fn) {
193200function legacyBundleConfig ( input , output , { isDeveloping, isExternal } ) {
194201 let babelConfig = { ...sharedBabelConfig } ;
195202
196- babelConfig . plugins = [ ...babelConfig . plugins , buildDebugMacroPlugin ( isDeveloping ) ] ;
203+ babelConfig . plugins = [ ...babelConfig . plugins ] ;
197204
198205 return {
199206 input,
@@ -690,11 +697,15 @@ function pruneEmptyBundles() {
690697function packageMeta ( ) {
691698 return {
692699 name : 'package-meta' ,
693- generateBundle ( ) {
700+ generateBundle ( _outputOptions , bundle ) {
694701 let renamedModules = Object . fromEntries (
695- glob
696- . sync ( 'packages/**/*.js' , { cwd : 'dist' , nodir : true } )
697- . filter ( ( name ) => ! name . startsWith ( 'packages/shared-chunks/' ) )
702+ Object . keys ( bundle )
703+ . filter (
704+ ( name ) =>
705+ name . startsWith ( 'packages/' ) &&
706+ ! name . startsWith ( 'packages/shared-chunks/' ) &&
707+ name . endsWith ( '.js' )
708+ )
698709 . sort ( )
699710 . map ( ( name ) => {
700711 return [
0 commit comments