fetch-event-source icon indicating copy to clipboard operation
fetch-event-source copied to clipboard

Warning due to incomplete sourcemaps

Open schnerd opened this issue 2 years ago • 11 comments

Description

The sourcemaps in the published package reference files that are not included in the published package.

When I use this package in my create-react-app project, I see the following warning:

WARNING in ./node_modules/@microsoft/fetch-event-source/lib/esm/fetch.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/[REDACTED]/node_modules/@microsoft/fetch-event-source/src/fetch.ts' file: Error: ENOENT: no such file or directory, open '/[REDACTED]/node_modules/@microsoft/fetch-event-source/src/fetch.ts'

fetch.js has //# sourceMappingURL=fetch.js.map. And fetch.js.map starts as follows:{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAA.

The "sources":["../../src/fetch.ts"] points to a file that doesn't exist in the package, which causes the warning to be emitted.

Proposed solution

Either (a) include the src directory in the published package, or (b) update tsconfig to inline the ts file content using the inlineSources option

Steps to reproduce

  1. Scaffold new app using create-react-app npx create-react-app my-app
  2. npm install --save @microsoft/fetch-event-source
  3. Add import {fetchEventSource} from '@microsoft/fetch-event-source to top of index.js
  4. npm run start, warnings should show

schnerd avatar Apr 27 '22 20:04 schnerd

I am also having same issue. Any solution would be appreciated.

sureshHARDIYA avatar Aug 25 '22 08:08 sureshHARDIYA

@vishwam @firedog1024 Do you plan to maintain and accept PRs for this repo (e.g. #23)? Otherwise our team may just fork it if fixes won't be merged in.

schnerd avatar Feb 05 '23 19:02 schnerd

Idem.

inad9300 avatar Mar 08 '23 13:03 inad9300

Any solutions for this???

OldManMeta avatar Jun 14 '23 15:06 OldManMeta

There's a workaround.

If you are using webpack, set ignoreWarnings option to skip parse error. https://webpack.js.org/configuration/other-options/#ignorewarnings

module.exports = {
  // ...
  ignoreWarnings: [/Failed to parse source map/]
}

If you are using custome-cra, add the following code in config-overrides.js.

const addIgnoreWarnings = (_loaderOptions) => config => {
  // https://github.com/facebook/create-react-app/blob/0a827f69ab0d2ee3871ba9b71350031d8a81b7ae/packages/react-scripts/config/webpack.config.js#L353
  const loader = config.module.rules.find(({
    enforce, loader
  }) => enforce === 'pre' && typeof loader === 'string' && loader.includes('source-map-loader'));
  if (loader) {
    if (!config.ignoreWarnings) {
      config.ignoreWarnings = [];
    }
    config.ignoreWarnings.push(/Failed to parse source map/,)
  }
  return config
}


module.exports = {
  webpack: override(
    // ...
    addIgnoreWarnings(),
  )
};

ziyoung avatar Jul 18 '23 09:07 ziyoung

This is still an issue

jordanarldt avatar Aug 07 '23 20:08 jordanarldt

MS doin' MS, I suppose...

peplocanto avatar Oct 17 '23 11:10 peplocanto

You might want to check out extended-eventsource as potential new replacement. It's codebase looks proper.

dargmuesli avatar Feb 21 '24 05:02 dargmuesli

So, what's the solution here? Is this project abandoned I should use something else? The problem obviously still exists…

Calamari avatar Mar 14 '24 14:03 Calamari

Also having this issue...

woutkonings avatar Mar 25 '24 13:03 woutkonings

See linked issue comment https://github.com/shafkevi/lambda-bedrock-s3-streaming-rag/issues/1#issuecomment-1943448686 above - SSE events can be streamed directly using nothing but fetch, making fetch-event-source unnecessary.

motin avatar Apr 03 '24 05:04 motin