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

ESM output contains many duplicated helpers #2230

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

ESM output contains many duplicated helpers #2230

rschristian opened this issue Apr 9, 2024 · 0 comments

Comments

@rschristian
Copy link

rschristian commented Apr 9, 2024

Description

As @docsearch/react compiles each of its files in isolation for the ESM output, the module as a whole ends up with a dozen duplicated helpers even in the most simple demonstration.

Edit: This applies for all dependencies of @docsearch/react too.

This heavily bloats the bundles of applications which use it, and bloats them needlessly.

Steps to reproduce

  1. Start a Vite (though every bundler would be impacted similarly) React project, pasting the following into src/main.jsx:
import React from 'react';
import ReactDOM from 'react-dom/client';
import { DocSearch } from '@docsearch/react';

function App() {
  return (
    <DocSearch
      appId="YOUR_APP_ID"
      indexName="YOUR_INDEX_NAME"
      apiKey="YOUR_SEARCH_API_KEY"
    />
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)
  1. npm run build
  2. Open built JS
  3. See 10 copies of the iterator helper ("Invalid attempt to destructure non-iterable instance....")

Expected behavior

That there aren't heavily duplicated helpers throughout the bundles.

This likely means moving to better build tooling, as compiling each module in isolation isn't really viable, nor has it ever been. The asset quality takes a pretty big hit when doing so.

Environment

  • OS: N/A
  • Browser: N/A
  • DocSearch version: 3.6.0
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