@@ -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,64 +55,71 @@ 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 : false ,
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+ 'packages/ember-template-compiler/index' : 'ember-template-compiler/minimal.ts' ,
83+ } ;
84+ }
85+
86+ function sharedESMConfig ( { input, debugMacrosMode, includePackageMeta = false } ) {
87+ let outputDir = debugMacrosMode === false ? 'dist-prod' : 'dist' ;
8688 let babelConfig = { ...sharedBabelConfig } ;
8789 babelConfig . plugins = [
8890 ...babelConfig . plugins ,
8991 buildDebugMacroPlugin ( debugMacrosMode ) ,
9092 canaryFeatures ( ) ,
9193 ] ;
9294
95+ let plugins = [
96+ babel ( {
97+ babelHelpers : 'bundled' ,
98+ extensions : [ '.js' , '.ts' ] ,
99+ configFile : false ,
100+ ...babelConfig ,
101+ } ) ,
102+ resolveTS ( ) ,
103+ version ( ) ,
104+ resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
105+ pruneEmptyBundles ( ) ,
106+ ] ;
107+
108+ if ( includePackageMeta ) {
109+ plugins . push ( packageMeta ( ) ) ;
110+ }
111+
93112 return {
94113 onLog : handleRollupWarnings ,
95114 input,
96115 output : {
97116 format : 'es' ,
98- dir : 'dist' ,
117+ dir : outputDir ,
99118 hoistTransitiveImports : false ,
100119 generatedCode : 'es2015' ,
101120 chunkFileNames : 'packages/shared-chunks/[name]-[hash].js' ,
102121 } ,
103- plugins : [
104- babel ( {
105- babelHelpers : 'bundled' ,
106- extensions : [ '.js' , '.ts' ] ,
107- configFile : false ,
108- ...babelConfig ,
109- } ) ,
110- resolveTS ( ) ,
111- version ( ) ,
112- resolvePackages ( { ...exposedDependencies ( ) , ...hiddenDependencies ( ) } ) ,
113- pruneEmptyBundles ( ) ,
114- packageMeta ( ) ,
115- ] ,
122+ plugins,
116123 } ;
117124}
118125
@@ -148,7 +155,7 @@ function renameEntrypoints(entrypoints, fn) {
148155function legacyBundleConfig ( input , output , { isDeveloping, isExternal } ) {
149156 let babelConfig = { ...sharedBabelConfig } ;
150157
151- babelConfig . plugins = [ ...babelConfig . plugins , buildDebugMacroPlugin ( isDeveloping ) ] ;
158+ babelConfig . plugins = [ ...babelConfig . plugins ] ;
152159
153160 return {
154161 input,
@@ -644,11 +651,15 @@ function pruneEmptyBundles() {
644651function packageMeta ( ) {
645652 return {
646653 name : 'package-meta' ,
647- generateBundle ( ) {
654+ generateBundle ( _outputOptions , bundle ) {
648655 let renamedModules = Object . fromEntries (
649- glob
650- . sync ( 'packages/**/*.js' , { cwd : 'dist' , nodir : true } )
651- . filter ( ( name ) => ! name . startsWith ( 'packages/shared-chunks/' ) )
656+ Object . keys ( bundle )
657+ . filter (
658+ ( name ) =>
659+ name . startsWith ( 'packages/' ) &&
660+ ! name . startsWith ( 'packages/shared-chunks/' ) &&
661+ name . endsWith ( '.js' )
662+ )
652663 . sort ( )
653664 . map ( ( name ) => {
654665 return [
0 commit comments