diff --git a/rollup.config.mjs b/rollup.config.mjs index ceee7e37ab1..dce983cda52 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -100,6 +100,20 @@ function sharedESMConfig({ input, debugMacrosMode, includePackageMeta = false }) return { onLog: handleRollupWarnings, input, + treeshake: { + moduleSideEffects(id) { + if (id.includes('packages/@glimmer/debug')) return false; + if (id.includes('packages/@glimmer/env')) return false; + if (id.includes('packages/@glimmer/local-debug-flags')) return false; + if (!debugMacrosMode && id.includes('packages/@ember/debug')) return false; + + /** + * our own side-effects are not for us to decide when to remove + * (aside from those incurred from the develop/prod split) + */ + return true; + }, + }, output: { format: 'es', dir: outputDir, diff --git a/tests/node-vitest/tree-shakability.test.js b/tests/node-vitest/tree-shakability.test.js index 46a49098b5e..d6220a4bc3d 100644 --- a/tests/node-vitest/tree-shakability.test.js +++ b/tests/node-vitest/tree-shakability.test.js @@ -233,6 +233,8 @@ it('[prod] has expected tree-shakable entrypoints', async () => { [ "ember-source/@ember/-internals/browser-environment/index.js", "ember-source/@ember/-internals/error-handling/index.js", + "ember-source/@ember/-internals/meta/index.js", + "ember-source/@ember/-internals/meta/lib/meta.js", "ember-source/@ember/-internals/owner/index.js", "ember-source/@ember/-internals/string/index.js", "ember-source/@ember/-internals/utility-types/index.js", @@ -254,16 +256,27 @@ it('[prod] has expected tree-shakable entrypoints', async () => { "ember-source/@ember/reactive/index.js", "ember-source/@ember/routing/lib/cache.js", "ember-source/@ember/routing/lib/controller_for.js", + "ember-source/@ember/routing/lib/dsl.js", "ember-source/@ember/routing/lib/location-utils.js", "ember-source/@ember/routing/lib/query_params.js", "ember-source/@ember/template-compilation/index.js", + "ember-source/@ember/template-compiler/-internal-primitives.js", "ember-source/@ember/template-compiler/-internal-utils.js", + "ember-source/@ember/template-compiler/lib/-internal/primitives.js", "ember-source/@ember/template-compiler/lib/dasherize-component-name.js", "ember-source/@ember/template-compiler/lib/plugins/allowed-globals.js", + "ember-source/@ember/template-compiler/lib/plugins/assert-against-attrs.js", + "ember-source/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js", + "ember-source/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js", + "ember-source/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js", "ember-source/@ember/template-compiler/lib/plugins/auto-import-builtins.js", + "ember-source/@ember/template-compiler/lib/plugins/index.js", "ember-source/@ember/template-compiler/lib/plugins/transform-action-syntax.js", "ember-source/@ember/template-compiler/lib/plugins/transform-each-in-into-each.js", + "ember-source/@ember/template-compiler/lib/plugins/transform-each-track-array.js", + "ember-source/@ember/template-compiler/lib/plugins/transform-in-element.js", "ember-source/@ember/template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js", + "ember-source/@ember/template-compiler/lib/plugins/transform-resolutions.js", "ember-source/@ember/template-compiler/lib/plugins/transform-wrap-mount-and-outlet.js", "ember-source/@ember/template-compiler/lib/plugins/utils.js", "ember-source/@ember/template-compiler/lib/system/calculate-location-display.js", @@ -298,8 +311,6 @@ it('[prod] has expected tree-shakable entrypoints', async () => { "ember-source/@ember/-internals/deprecations/index.js", "ember-source/@ember/-internals/environment/index.js", "ember-source/@ember/-internals/glimmer/index.js", - "ember-source/@ember/-internals/meta/index.js", - "ember-source/@ember/-internals/meta/lib/meta.js", "ember-source/@ember/-internals/metal/index.js", "ember-source/@ember/-internals/routing/index.js", "ember-source/@ember/-internals/runtime/index.js", @@ -362,7 +373,6 @@ it('[prod] has expected tree-shakable entrypoints', async () => { "ember-source/@ember/routing/hash-location.js", "ember-source/@ember/routing/history-location.js", "ember-source/@ember/routing/index.js", - "ember-source/@ember/routing/lib/dsl.js", "ember-source/@ember/routing/lib/generate_controller.js", "ember-source/@ember/routing/lib/router_state.js", "ember-source/@ember/routing/lib/routing-service.js", @@ -373,18 +383,8 @@ it('[prod] has expected tree-shakable entrypoints', async () => { "ember-source/@ember/routing/router.js", "ember-source/@ember/runloop/index.js", "ember-source/@ember/service/index.js", - "ember-source/@ember/template-compiler/-internal-primitives.js", "ember-source/@ember/template-compiler/index.js", - "ember-source/@ember/template-compiler/lib/-internal/primitives.js", "ember-source/@ember/template-compiler/lib/compile-options.js", - "ember-source/@ember/template-compiler/lib/plugins/assert-against-attrs.js", - "ember-source/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js", - "ember-source/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js", - "ember-source/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js", - "ember-source/@ember/template-compiler/lib/plugins/index.js", - "ember-source/@ember/template-compiler/lib/plugins/transform-each-track-array.js", - "ember-source/@ember/template-compiler/lib/plugins/transform-in-element.js", - "ember-source/@ember/template-compiler/lib/plugins/transform-resolutions.js", "ember-source/@ember/template-compiler/lib/public-api.js", "ember-source/@ember/template-compiler/lib/runtime.js", "ember-source/@ember/template-compiler/lib/template.js",