From 16802fbe26fb6650c7e94596e5d5becdc3063232 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 27 Feb 2026 14:36:10 -0500 Subject: [PATCH 1/3] Add prod build --- .gitignore | 1 + package.json | 7 +++- rollup.config.mjs | 91 ++++++++++++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index 4a4c99b4f3e..9bf32df156f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ assets/bpm_libs.js assets/bpm_styles.css coverage dist +dist-prod /docs lib/*/tests/all.js lib/*/tests/qunit* diff --git a/package.json b/package.json index aff44aaa561..0c712601b78 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,11 @@ "ember-addon" ], "exports": { - "./*": "./dist/packages/*", + "./*": { + "development": "./dist/packages/*", + "production": "./dist-prod/packages/*", + "default": "./dist/packages/*" + }, "./types": { "types": "./types/stable/index.d.ts" }, @@ -24,6 +28,7 @@ "blueprints", "dist/packages", "dist/dependencies", + "dist-prod/packages", "dist/ember-template-compiler.js", "dist/ember-template-compiler.js.map", "dist/ember.debug.js", diff --git a/rollup.config.mjs b/rollup.config.mjs index bbb33dbdfed..bf2789916c0 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -27,7 +27,7 @@ const testDependencies = [ let configs = [ esmConfig(), - esmTemplateCompiler(), + esmProdConfig(), legacyBundleConfig('./broccoli/amd-compat-entrypoints/ember.debug.js', 'ember.debug.js', { isDeveloping: true, }), @@ -55,34 +55,36 @@ export default configs; function esmConfig() { return sharedESMConfig({ - input: { - ...renameEntrypoints(exposedDependencies(), (name) => join('packages', name, 'index')), - ...renameEntrypoints(packages(), (name) => join('packages', name)), - }, + input: esmInputs(), debugMacrosMode: '@embroider/macros', + includePackageMeta: true, }); } -function esmTemplateCompiler() { +function esmProdConfig() { return sharedESMConfig({ - input: { - // the actual authored "./packages/ember-template-compiler/index.ts" is - // part of what powers the historical dist/ember-template-compiler.js AMD - // bundle. It has historical cruft that has never been present in our ESM - // builds. - // - // On the ESM build, the main entrypoint of ember-template-compiler is the - // "minimal.ts" version, which has a lot less in it. - - 'packages/ember-template-compiler/index': 'ember-template-compiler/minimal.ts', - }, - // the template compiler is always in debug mode (and doesn't use - // embroider/macros, so it's directly invokable on node) - debugMacrosMode: true, + input: esmInputs(), + debugMacrosMode: false, }); } -function sharedESMConfig({ input, debugMacrosMode }) { +function esmInputs() { + return { + ...renameEntrypoints(exposedDependencies(), (name) => join('packages', name, 'index')), + ...renameEntrypoints(packages(), (name) => join('packages', name)), + // the actual authored "./packages/ember-template-compiler/index.ts" is + // part of what powers the historical dist/ember-template-compiler.js AMD + // bundle. It has historical cruft that has never been present in our ESM + // builds. + // + // On the ESM build, the main entrypoint of ember-template-compiler is the + // "minimal.ts" version, which has a lot less in it. + 'packages/ember-template-compiler/index': 'ember-template-compiler/minimal.ts', + }; +} + +function sharedESMConfig({ input, debugMacrosMode, includePackageMeta = false }) { + let outputDir = debugMacrosMode === false ? 'dist-prod' : 'dist'; let babelConfig = { ...sharedBabelConfig }; babelConfig.plugins = [ ...babelConfig.plugins, @@ -90,29 +92,34 @@ function sharedESMConfig({ input, debugMacrosMode }) { canaryFeatures(), ]; + let plugins = [ + babel({ + babelHelpers: 'bundled', + extensions: ['.js', '.ts'], + configFile: false, + ...babelConfig, + }), + resolveTS(), + version(), + resolvePackages({ ...exposedDependencies(), ...hiddenDependencies() }), + pruneEmptyBundles(), + ]; + + if (includePackageMeta) { + plugins.push(packageMeta()); + } + return { onLog: handleRollupWarnings, input, output: { format: 'es', - dir: 'dist', + dir: outputDir, hoistTransitiveImports: false, generatedCode: 'es2015', chunkFileNames: 'packages/shared-chunks/[name]-[hash].js', }, - plugins: [ - babel({ - babelHelpers: 'bundled', - extensions: ['.js', '.ts'], - configFile: false, - ...babelConfig, - }), - resolveTS(), - version(), - resolvePackages({ ...exposedDependencies(), ...hiddenDependencies() }), - pruneEmptyBundles(), - packageMeta(), - ], + plugins, }; } @@ -148,7 +155,7 @@ function renameEntrypoints(entrypoints, fn) { function legacyBundleConfig(input, output, { isDeveloping, isExternal }) { let babelConfig = { ...sharedBabelConfig }; - babelConfig.plugins = [...babelConfig.plugins, buildDebugMacroPlugin(isDeveloping)]; + babelConfig.plugins = [...babelConfig.plugins]; return { input, @@ -644,11 +651,15 @@ function pruneEmptyBundles() { function packageMeta() { return { name: 'package-meta', - generateBundle() { + generateBundle(_outputOptions, bundle) { let renamedModules = Object.fromEntries( - glob - .sync('packages/**/*.js', { cwd: 'dist', nodir: true }) - .filter((name) => !name.startsWith('packages/shared-chunks/')) + Object.keys(bundle) + .filter( + (name) => + name.startsWith('packages/') && + !name.startsWith('packages/shared-chunks/') && + name.endsWith('.js') + ) .sort() .map((name) => { return [ From 9d7e59e02666c7772eff6e7e8a4e4eb31e8f07f5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 27 Feb 2026 14:58:15 -0500 Subject: [PATCH 2/3] Update rollup to ditch the @embroider/macros --- rollup.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index bf2789916c0..b2e21136394 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -56,7 +56,7 @@ export default configs; function esmConfig() { return sharedESMConfig({ input: esmInputs(), - debugMacrosMode: '@embroider/macros', + debugMacrosMode: true, includePackageMeta: true, }); } From 1b7a19ae501f5a9b83e6dceb6ece29f513496ffc Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:37:51 -0500 Subject: [PATCH 3/3] Make prod default --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c712601b78..d2bb64295f7 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "./*": { "development": "./dist/packages/*", "production": "./dist-prod/packages/*", - "default": "./dist/packages/*" + "default": "./dist-prod/packages/*" }, "./types": { "types": "./types/stable/index.d.ts"