fetch-event-source
fetch-event-source copied to clipboard
Warning due to incomplete sourcemaps
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
- Scaffold new app using create-react-app
npx create-react-app my-app
-
npm install --save @microsoft/fetch-event-source
- Add
import {fetchEventSource} from '@microsoft/fetch-event-source
to top of index.js -
npm run start
, warnings should show
I am also having same issue. Any solution would be appreciated.
@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.
Idem.
Any solutions for this???
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(),
)
};
This is still an issue
MS doin' MS, I suppose...
You might want to check out extended-eventsource as potential new replacement. It's codebase looks proper.
So, what's the solution here? Is this project abandoned I should use something else? The problem obviously still exists…
Also having this issue...
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.