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

Unbundle dependencies from @docsearch/js #2224

Open
rschristian opened this issue Apr 1, 2024 · 0 comments
Open

Unbundle dependencies from @docsearch/js #2224

rschristian opened this issue Apr 1, 2024 · 0 comments

Comments

@rschristian
Copy link

rschristian commented Apr 1, 2024

Description

preact and @docsearch/react are listed as dependencies of @docsearch/js, however, both are inlined into the bundles. This totally breaks any usage of Docsearch on a Preact site as Preact, like React, requires that it be a singleton in order for functionality like hooks to work. Preact being bundled will always result in an additional copy being loaded.

This also introduces an additional issue in that most CDNs will try to (helpfully) provide listed dependencies of modules. With this setup, that means each of these modules are downloaded twice: once inlined into the bundle, and another time as a separate module. Now this can be worked around in some CDNs, but still isn't ideal, as the default behavior causes wasted network trips.

Steps to reproduce

  1. Load up NPM's code viewer (which annoyingly doesn't allow for direct links to files): https://www.npmjs.com/package/@docsearch/js?activeTab=code
  2. Look in the ESM bundle and spot Preact.
  • If you don't know what you're looking for, ctrl + f for xlink and you'll spot this line

Live reproduction:

N/A

Expected behavior

They're either dependencies or they're bundled, not both.

Environment

  • OS: N/A
  • Browser: N/A
  • DocSearch version: 3.6.0
@rschristian rschristian changed the title Unbundle dependencies Unbundle dependencies from @docsearch/js Apr 1, 2024
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

No branches or pull requests

1 participant