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

fix(commerce): replace barrel import with proper import #3729

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

Spuffynism
Copy link
Contributor

As part of CAPI-496, we compared bundle sizes for different changes we wanted to make to headless and spotted issues with imports in the commerce package.

Running dependency cruiser to map a graph of dependencies in the packages/headless folder showed that index.ts was being included (full dependencies.svg file here):

npx depcruise --no-config \
  --exclude "^node_modules" \
  --output-type dot \
  src/commerce.index.ts > dependencies.out && dot dependencies.out -T svg -o dependencies.svg

image

We then found the source of the issue was product-listing-recent-results with:

npx depcruise --no-config \
  --exclude "^node_modules" \
  --output-type dot \
  --ts-config tsconfig.json \
  --do-not-follow "^src/index.ts" \
  --focus "^src/index.ts" \
  src/commerce.index.ts > dependencies.out && dot dependencies.out -T svg -o dependencies.svg

image

This PR replace the index.ts barrel import with the proper redux import.

Copy link

github-actions bot commented Mar 20, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 209.5 209.5 0
commerce 297.4 253.9 -14.6
search 367.3 367.3 0
insight 332 332 0
product-listing 302.2 263.8 -12.7
product-recommendation 182.2 182.2 0
recommendation 224.4 224.4 0
ssr 361.4 361.4 0

@Spuffynism
Copy link
Contributor Author

We still depend on a few bits and pieces that we could not depend on (slices, actions, etc.), but I don't think it's worth it to invest some more time in this at this time. Nonetheless, here they are:

  • did you mean
  • trigger
  • folded result list
  • breadcrumb
  • history
  • static-filter-set
  • question-answering
  • dictionary-field-context
  • context
  • search-hub
  • search-and-folding

If one ever wishes to reduce the bundle size for commerce, these would be good starting points. Using the interactive mode with dependency cruiser can help identify these issues (interactive.html):

npx depcruise --no-config \
  --exclude "^node_modules" \
  --output-type dot \
  --ts-config tsconfig.json \
  src/commerce.index.ts | dot -T svg -Grankdir=TD | npx depcruise-wrap-stream-in-html > interactive.html && open interactive.html

@Spuffynism Spuffynism marked this pull request as ready for review March 20, 2024 18:37
@Spuffynism Spuffynism requested review from a team as code owners March 20, 2024 18:37
@Spuffynism Spuffynism added this pull request to the merge queue Mar 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 20, 2024
@Spuffynism Spuffynism added this pull request to the merge queue Mar 21, 2024
Merged via the queue into master with commit 8f4d68d Mar 21, 2024
90 checks passed
@Spuffynism Spuffynism deleted the fix-capi-496-barrel-import branch March 21, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants