Remove barrel file imports from internal code#21295
Remove barrel file imports from internal code#21295NullVoxPopuli-ai-agent wants to merge 1 commit intoemberjs:mainfrom
Conversation
Replace all internal barrel imports (from `@ember/-internals/glimmer`,
`@ember/-internals/environment`, etc.) with direct imports from the
specific source files that define what is needed. Also replace all
`export *` patterns in `@ember` packages with explicit named exports.
- Update ~40 source files to import from specific lib paths instead of
barrel `index.ts` files
- Replace `export *` with named exports in `@ember/-internals/environment`,
`@ember/engine/parent`, `@ember/template-compiler/*`, `ember-template-compiler`,
and `ember-testing`
- Replace `import * as environment` with named `{ hasDOM }` import in
`@ember/application/instance`
- Add deep import path entries to `@ember/-internals/package.json` exports map
- Add `@glimmer/opcode-compiler` dependency to `ember-template-compiler`
Test files are intentionally left unchanged as they may use barrel imports.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📊 Package size report 0.2%↑
Show files (49 files)
🤖 This report was automatically generated by pkg-size-action |
| toEnvironment(): BootEnvironment { | ||
| // Do we really want to assign all of this!? | ||
| return { | ||
| ...environment, |
There was a problem hiding this comment.
was this totally redundant?
There was a problem hiding this comment.
Yes — ...environment was spreading { hasDOM, window, location, history, userAgent, isChrome, isFirefox } from @ember/-internals/browser-environment, but the BootEnvironment type only uses hasDOM, isInteractive, _renderMode, and options. The explicit hasDOM: this.isBrowser was already overriding it. The other properties (window, location, etc.) were not in the type and not used by any consumer.
| @@ -1,6 +1,6 @@ | |||
| export { | |||
| Helper as default, | |||
| default as default, | |||
There was a problem hiding this comment.
can just be default, ya
There was a problem hiding this comment.
Fixed — export { default } in the latest push on #21286.
| export { setComponentTemplate, getComponentTemplate } from '@glimmer/manager'; | ||
|
|
||
| export { Component as default, Input, Textarea } from '@ember/-internals/glimmer'; | ||
| export { default as default } from '@ember/-internals/glimmer/lib/component'; |
There was a problem hiding this comment.
can just be export { default }, yea?
There was a problem hiding this comment.
Fixed — export { default } in the latest push on #21286.
|
as expected, there are a few more shared-chunks now (good)
|
Summary
@ember/-internals/glimmer,@ember/-internals/environment, etc.) with direct imports from specific source files to improve tree-shakingexport *patterns in@emberpackages with explicit namedexport { ... }statementsimport * as environmentwith named imports in@ember/application/instance@ember/-internals/package.jsonexports map for the new import paths@glimmer/opcode-compileras an explicit dependency ofember-template-compilerThis enables bundlers to tree-shake more effectively since importing from a barrel
index.tspulls in all transitive dependencies. Test files are intentionally left unchanged.Barrel
index.tsfiles themselves are preserved as the public API entry points -- only their consumers are updated.Test plan
pnpm run type-check:internals) -- only pre-existing type-test errors remainpnpm run lint:eslint)pnpm run lint:format)pnpm run build:js)🤖 Generated with Claude Code