Skip to content

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

Open
@maneetgoyal

Description

@maneetgoyal

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,CAAC;SACjB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC;SAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,2CAA2C;SAChE,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAAC,kBAAkB;IAC7D,OAAO,IAAI,IAAI,CAAC,KAAK,C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;;;;;;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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions