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

[Bug]: Source Map Errors from Headless Dependencies #4883

Open
markdav opened this issue Jan 21, 2025 · 3 comments · May be fixed by #4921
Open

[Bug]: Source Map Errors from Headless Dependencies #4883

markdav opened this issue Jan 21, 2025 · 3 comments · May be fixed by #4921
Assignees
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request

Comments

@markdav
Copy link

markdav commented Jan 21, 2025

Which product are you using?

Headless

product version

3.13.2

bug description

Source Map Errors from Dependencies

Description

When using @coveo/headless in a Create React App project, multiple source map parsing errors appear in the console during development. These errors come from two dependencies:

  1. @microsoft/fetch-event-source
  2. exponential-backoff

Impact

While these errors don't affect functionality, they:

  • Clutter the development console
  • Make it harder to spot actual issues
  • May confuse developers new to the library

Proposed Solutions

Option 1: Bundle Dependencies (Recommended)

Bundle @microsoft/fetch-event-source and exponential-backoff into the main package output instead of keeping them as external dependencies. This would involve:

  1. Updating webpack/rollup config:
module.exports = {
  optimization: {
    concatenateModules: true,
  },
  externals: {
    '@microsoft/fetch-event-source': false,
    'exponential-backoff': false
  }
}

Option 2: Fix Source Map Generation

If keeping these as external dependencies is preferred:

  1. Strip source map references during build if sources won't be included
  2. Or ensure proper source map generation by including necessary TypeScript sources

Workarounds for Users

Until this is fixed, users can:

  1. Disable source maps in their CRA project (not an option for us):
GENERATE_SOURCEMAP=false
  1. Or ignore these specific warnings using react-app-rewired, craco or similar (not a good option for us):
module.exports = function override(config) {
  config.ignoreWarnings = [/Failed to parse source map/];
  return config;
};

Environment

  • @coveo/headless: [latest version]
  • create-react-app: 5.0.1
  • Node.js: 16+
  • OS: [tested on Linux, likely affects all platforms]

Let me know if you need any additional information or clarification.

Steps to reproduce

Reproduction Steps

  1. Create a new CRA project:
npx create-react-app repro
cd repro
  1. Install @coveo/headless:
npm install @coveo/headless
  1. Add minimal usage code:
import { buildSearchEngine } from '@coveo/headless';

const engine = buildSearchEngine({
  configuration: {
    organizationId: 'dummy',
    accessToken: 'dummy',
  }
});
  1. Run npm start

Error Output

Failed to parse source map from '.../node_modules/@microsoft/fetch-event-source/src/fetch.ts'
Failed to parse source map from '.../node_modules/@microsoft/fetch-event-source/src/parse.ts'
Failed to parse source map from '.../node_modules/exponential-backoff/src/backoff.ts'
Failed to parse source map from '.../node_modules/exponential-backoff/src/delay/always/always.delay.ts'
[...additional similar errors...]

Relevant log output

@markdav markdav added the bug Something isn't working label Jan 21, 2025
@markdav
Copy link
Author

markdav commented Jan 21, 2025

coveo-error-reproduction.tar.gz

Sample project to demonstrate.

@louis-bompart louis-bompart self-assigned this Jan 23, 2025
@louis-bompart
Copy link
Collaborator

louis-bompart commented Jan 23, 2025

Hey @markdav , thanks for this detailed issue :)

What we'll probably do is:

  • We will stop bundling Headless altogether on our NPM output. Indeed, regardless, those who consume Headless through NPM already need to run a bundler of their own on this project, and double bundling almost always has a detrimental effect on bundle size, as it prevents code deduplication.
  • We will include as production dependencies everything being used by Headless outputted code & sourcemaps.

That's our plan; we will validate whether it can be applied in the coming weeks without breaking changes.
If those changes are breaking, we will fix try to find alleviating solutions, but we also may fix this behaviour only on our next major release.

@markdav
Copy link
Author

markdav commented Jan 27, 2025

Excellent - thanks Louis - that sounds better again - appreciate the attention!

@alexprudhomme alexprudhomme added dependencies Pull requests that update a dependency file enhancement New feature or request and removed bug Something isn't working labels Jan 27, 2025
louis-bompart added a commit that referenced this issue Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants