Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate/eliminate barrel files #13618

Open
swissspidy opened this issue Apr 16, 2024 · 1 comment
Open

Investigate/eliminate barrel files #13618

swissspidy opened this issue Apr 16, 2024 · 1 comment
Labels
P3 Nice to have Type: Code Quality Things that need a refactor, rewrite or just some good old developer ❤️ Type: Infrastructure Changes impacting testing infrastructure or build tooling Type: Performance Performance related issues and enhancements.

Comments

@swissspidy
Copy link
Collaborator

Task Description

Barrel files can slow down your build/tests, can cause circular dependencies, and makes tree shaking more difficult.

Admittedly, we have a lot of those in the code base.

I was wondering whether we could use something like eslint-plugin-no-barrel-files to detect barrel files in in the project to see where they currently have a negative impact.

They might not have an impact on our actual bundle size due to better tree shaking, but the difference can be more significant in places like Jest unit tests.

Right now said ESLint rule reports 1502 problems.

@swissspidy swissspidy added Type: Infrastructure Changes impacting testing infrastructure or build tooling Type: Performance Performance related issues and enhancements. P3 Nice to have Type: Code Quality Things that need a refactor, rewrite or just some good old developer ❤️ labels Apr 16, 2024
@swissspidy
Copy link
Collaborator Author

$ npx oxlint --import-plugin -D no-barrel-file

  × oxc(no-barrel-file): Barrel file detected, 137 modules are loaded.
    ╭─[packages/animation/src/types/index.ts:17:15]
 16 │ 
 17 │ export * from './animation';
    ·               ──────┬──────
    ·                     ╰── 68 modules
 18 │ export * from './storyAnimationState';
 19 │ export * from './effects';
 20 │ export * from './element';
    ·               ─────┬─────
    ·                    ╰── 1 modules
 21 │ export * from './keyframes';
 22 │ export * from './propTypes';
    ·               ──────┬──────
    ·                     ╰── 68 modules
    ╰────
  help: Loading 137 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 2628 modules are loaded.
    ╭─[packages/design-system/src/components/index.ts:16:15]
 15 │  */
 16 │ export * from './banner';
    ·               ─────┬────
    ·                    ╰── 37 modules
 17 │ export * from './button';
    ·               ─────┬────
    ·                    ╰── 28 modules
 18 │ export * from './checkbox';
    ·               ──────┬─────
    ·                     ╰── 27 modules
 19 │ export * from './chip';
    ·               ────┬───
    ·                   ╰── 25 modules
 20 │ export * from './circularProgress';
    ·               ──────────┬─────────
    ·                         ╰── 4 modules
 21 │ export * from './contextMenu';
    ·               ───────┬───────
    ·                      ╰── 93 modules
 22 │ export * from './datalist';
    ·               ──────┬─────
    ·                     ╰── 225 modules
 23 │ export * from './dialog';
    ·               ─────┬────
    ·                    ╰── 38 modules
 24 │ export * from './disclosure';
    ·               ───────┬──────
    ·                      ╰── 24 modules
 25 │ export * from './dropDown';
    ·               ──────┬─────
    ·                     ╰── 225 modules
 26 │ export * from './hex';
    ·               ───┬───
    ·                  ╰── 66 modules
 27 │ export * from './infiniteScroller';
    ·               ──────────┬─────────
    ·                         ╰── 52 modules
 28 │ export * from './input';
    ·               ────┬────
    ·                   ╰── 63 modules
 29 │ export * from './input/numericInput';
    ·               ───────────┬──────────
    ·                          ╰── 62 modules
 30 │ export * from './keyboard';
    ·               ──────┬─────
    ·                     ╰── 9 modules
 31 │ export * from './keyboard/gridview';
    ·               ──────────┬──────────
    ·                         ╰── 12 modules
 32 │ export * from './loadingBar';
    ·               ───────┬──────
    ·                      ╰── 26 modules
 33 │ export * from './loadingSpinner';
    ·               ─────────┬────────
    ·                        ╰── 42 modules
 34 │ export * from './mediaInput';
    ·               ───────┬──────
    ·                      ╰── 225 modules
 35 │ export * from './menu';
    ·               ────┬───
    ·                   ╰── 67 modules
 36 │ export * from './modal';
    ·               ────┬────
    ·                   ╰── 28 modules
 37 │ export * from './notificationBubble';
    ·               ───────────┬──────────
    ·                          ╰── 25 modules
 38 │ export * from './pill';
    ·               ────┬───
    ·                   ╰── 26 modules
 39 │ export * from './popup';
    ·               ────┬────
    ·                   ╰── 225 modules
 40 │ export * from './radio';
    ·               ────┬────
    ·                   ╰── 49 modules
 41 │ export * from './search';
    ·               ─────┬────
    ·                    ╰── 225 modules
 42 │ export * from './slider';
    ·               ─────┬────
    ·                    ╰── 225 modules
 43 │ export * from './swatch';
    ·               ─────┬────
    ·                    ╰── 25 modules
 44 │ export * from './switch';
    ·               ─────┬────
    ·                    ╰── 49 modules
 45 │ export * from './snackbar';
    ·               ──────┬─────
    ·                     ╰── 70 modules
 46 │ export * from './textArea';
    ·               ──────┬─────
    ·                     ╰── 49 modules
 47 │ export * from './toggle';
    ·               ─────┬────
    ·                    ╰── 4 modules
 48 │ export * from './tooltip';
    ·               ─────┬─────
    ·                    ╰── 225 modules
 49 │ export * from './typography';
    ·               ───────┬──────
    ·                      ╰── 31 modules
 50 │ export * from './visuallyHidden';
    ·               ─────────┬────────
    ·                        ╰── 22 modules
    ╰────
  help: Loading 2628 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 260 modules are loaded.
    ╭─[packages/design-system/src/index.ts:35:15]
 34 │ export * from './components';
 35 │ export * from './contexts';
    ·               ──────┬─────
    ·                     ╰── 225 modules
 36 │ export * from './images';
 37 │ export * from './theme';
    ·               ────┬────
    ·                   ╰── 22 modules
 38 │ export * from './utils';
    ·               ────┬────
    ·                   ╰── 13 modules
 39 │ export { setAppElement };
    ╰────
  help: Loading 260 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 381 modules are loaded.
    ╭─[packages/story-editor/src/components/checklist/index.js:33:15]
 32 │ export { Checklist } from './checklist';
 33 │ export * from './checks';
    ·               ─────┬────
    ·                    ╰── 381 modules
 34 │ export { default as ChecklistIcon } from './checklistIcon';
    ╰────
  help: Loading 381 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 138 modules are loaded.
    ╭─[packages/animation/src/parts/index.tsx:18:15]
 17 │ export { default as createAnimationPart } from './createAnimationPart';
 18 │ export * from './getAnimationEffectFields';
    ·               ──────────────┬─────────────
    ·                             ╰── 70 modules
 19 │ export * from './types';
    ·               ────┬────
    ·                   ╰── 68 modules
    ╰────
  help: Loading 138 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 815 modules are loaded.
    ╭─[packages/story-editor/src/components/library/index.js:18:15]
 17 │ export { default } from './library';
 18 │ export * from './constants';
    ·               ──────┬──────
    ·                     ╰── 815 modules
    ╰────
  help: Loading 815 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 236 modules are loaded.
    ╭─[packages/dashboard/src/index.js:18:15]
 17 │ export { default as Dashboard } from './dashboard';
 18 │ export * from './app';
    ·               ───┬───
    ·                  ╰── 38 modules
 19 │ export * from './app/router';
    ·               ───────┬──────
    ·                      ╰── 20 modules
 20 │ export * from './constants';
    ·               ──────┬──────
    ·                     ╰── 10 modules
 21 │ export * from './components';
    ·               ───────┬──────
    ·                      ╰── 78 modules
 22 │ export * from './app/views/shared';
    ·               ──────────┬─────────
    ·                         ╰── 90 modules
 23 │ export { GlobalStyle as DashboardGlobalStyle } from './theme';
    ╰────
  help: Loading 236 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 417 modules are loaded.
    ╭─[packages/story-editor/src/app/rightClickMenu/index.js:19:15]
 18 │ export { default as RightClickMenuProvider } from './provider';
 19 │ export * from './menus';
    ·               ────┬────
    ·                   ╰── 417 modules
    ╰────
  help: Loading 417 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 413 modules are loaded.
    ╭─[packages/story-editor/src/components/header/index.js:17:15]
 16 │ 
 17 │ export * from './buttons';
    ·               ─────┬─────
    ·                    ╰── 413 modules
 18 │ export { default as HeaderTitle } from './title';
    ╰────
  help: Loading 413 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 178 modules are loaded.
    ╭─[packages/animation/src/index.ts:17:15]
 16 │ 
 17 │ export * from './components';
    ·               ───────┬──────
    ·                      ╰── 37 modules
 18 │ export * from './constants';
    ·               ──────┬──────
    ·                     ╰── 68 modules
 19 │ export * from './parts';
 20 │ export * from './outputs';
    ·               ─────┬─────
    ·                    ╰── 5 modules
 21 │ export * from './utils';
    ·               ────┬────
    ·                   ╰── 68 modules
 22 │ export * from './types';
    ╰────
  help: Loading 178 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

  × oxc(no-barrel-file): Barrel file detected, 2446 modules are loaded.
    ╭─[packages/story-editor/src/index.js:25:15]
 24 │ 
 25 │ export * from './components/previewPage';
    ·               ─────────────┬────────────
    ·                            ╰── 288 modules
 26 │ export * from './app/config';
    ·               ───────┬──────
    ·                      ╰── 13 modules
 27 │ export * from './app/story';
    ·               ──────┬──────
    ·                     ╰── 138 modules
 28 │ export * from './app/api';
    ·               ─────┬─────
    ·                    ╰── 40 modules
 29 │ export * from './app/media';
    ·               ──────┬──────
    ·                     ╰── 225 modules
 30 │ export * from './app/history';
    ·               ───────┬───────
    ·                      ╰── 40 modules
 31 │ export * from './components/header';
 32 │ export * from './components/panels/document';
    ·               ───────────────┬──────────────
    ·                              ╰── 422 modules
 33 │ export * from './components/form';
    ·               ─────────┬─────────
    ·                        ╰── 371 modules
 34 │ export * from './components/panels/panel';
    ·               ─────────────┬─────────────
    ·                            ╰── 152 modules
 35 │ export * from './components/panels/shared';
    ·               ──────────────┬─────────────
    ·                             ╰── 378 modules
 36 │ export * from './components/checklist';
 37 │ export { default as FontPicker } from './components/fontPicker';
 38 │ export { focusStyle } from './components/panels/shared/styles';
 39 │ export * from './components/checklistCard';
    ·               ──────────────┬─────────────
    ·                             ╰── 335 modules
 40 │ export * from './app/currentUser';
    ·               ─────────┬─────────
    ·                        ╰── 44 modules
 41 │ 
    ╰────
  help: Loading 2446 modules is slow for runtimes and bundlers.
        The configured threshold is 100.
        See also: <https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7>.

Finished in 191ms on 3710 files with 1 rules using 10 threads.
Found 0 warnings and 11 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Nice to have Type: Code Quality Things that need a refactor, rewrite or just some good old developer ❤️ Type: Infrastructure Changes impacting testing infrastructure or build tooling Type: Performance Performance related issues and enhancements.
Projects
None yet
Development

No branches or pull requests

1 participant