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

.js.map source map parsing warnings in Webpack source-map-loader #240

Open
maneetgoyal opened this issue Mar 11, 2021 · 5 comments · May be fixed by #256
Open

.js.map source map parsing warnings in Webpack source-map-loader #240

maneetgoyal opened this issue Mar 11, 2021 · 5 comments · May be fixed by #256

Comments

@maneetgoyal
Copy link

Getting the following warning:

WARNING in xxx/node_modules/timeago.js/esm/register.js
xxx     Module Warning (from xxx/node_modules/source-map-loader/dist/cjs.js):
xxx     Failed to parse source map from 'xxx/node_modules/timeago.js/src/register.ts' file: Error: ENOENT: no such file or directory, open 'xxx/node_modules/timeago.js/src/register.ts'

Looking at the build routine in package.json, this package has:

"build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm",

TSC emits source map (abcd.js.map) like this:

{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,IAAM,SAAS,GAAG;IAChB,EAAE;IACF,EAAE;IACF,EAAE;IACF,CAAC;IACD,GAAG,GAAG,CAAC,GAAG,EAAE;IACZ,EAAE;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAA8B;IACnD,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC;IACxC,aAAa;IACb,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QACnB,aAAa;SACZ,IAAI,EAAE;SACN,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,sBAAsB;SAC3C,OAAO,CAAC,GAAG,EAAE,GAAG,C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,CAAC,IAAW,EAAE,YAAmB;IACtD,IAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IACjE,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;AAC3C,CAAC;AAED;;;;;;;;IAQI;AACJ,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,GAAG,GAAG,CAAC,EACT,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxD,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;QACrB,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;KACrB;IACD,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACZ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC"}

The issue is related to "source" property above. Since src folder is missing from the timeago.js NPM distribution, Webpack source-map-loader is throwing warnings.


My current solution for the Webpack config is:

{
          enforce: "pre", // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
          test: /\.js$/,
          loader: require.resolve("source-map-loader"),
          /**
           * timeago.js has issues since their source maps refer to the actual TS source files.
           */
          exclude: [/node_modules\/timeago.js/],
        }

which basically tells source-map-loader to ignore parsing the source maps for timeago.js.


Is any other solution suggested? Since end users won't have access to TS source files in the dist, should this library stop distributing source maps altogether?

@kallaspriit
Copy link

I'm also facing the same problem and since I'm using Create React App then the webpack config is not easily configurable.

@cmdcolin
Copy link

cmdcolin commented Apr 6, 2022

I think adding "src" to the "files" array in package.json would fix this (in this package, not as a workaround in consumers of timeago)

@kYem
Copy link

kYem commented Apr 8, 2022

This would be useful to reduce the noise created by webpack, any downsides of adding src files?

@cmdcolin cmdcolin linked a pull request Jun 24, 2022 that will close this issue
@imagine10255
Copy link

You can remove the warning by adding GENERATE_SOURCEMAP=false to your .env file

Actually, CRA with Webpack 5.x cause it. They are working on resolving (facebook/create-react-app#11752)

@cmdcolin
Copy link

cmdcolin commented Jun 7, 2024

just for anyone that still lands on this, an alternative library that has a timeago.js-style feature is date-fns https://date-fns.org/

(big thanks to the timeago.js devs, just mentioning :))

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

Successfully merging a pull request may close this issue.

5 participants