question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to parse source map from [path] warning

See original GitHub issue
  • Operating System: macOS Catalina 10.15.6
  • Node Version: 12.18.2
  • NPM Version: 6.14.5
  • Yarn version: 1.22.4
  • webpack Version: 4.43.0
  • source-map-loader version: 1.0.1

Actual Behavior

Failed to parse source map from [path] file: Error: ENOENT: no such file or directory, open [path] warnings are logged in the terminal (as well in the browser console log).

Remarks

  • It failed to load all standardized-audio-context package source map files
  • Seems that source-map-loader treats the path //# sourceMappingURL=/build/es2019/constants.js.map as an absolute path, what cause the failure Error: ENOENT: no such file or directory
  • For my test, removing the prefixed slash / from the path /build/es2019/constants.js.map fixes the issue, so:
// not work 😢
//# sourceMappingURL=/build/es2019/constants.js.map

// work 😍
//# sourceMappingURL=build/es2019/constants.js.map

Expected Behavior

No Failed to parse source map from... warnings should logged in the terminal and in the browser console log.

Code

{
  test: /\.js$/,
  enforce: 'pre',
  use: ['source-map-loader'],
},

Example of how the sourceMappingURL directive that fails looks like:

//# sourceMappingURL=/build/es2019/constants.js.map

How Do We Reproduce?

Prerequisite

Web app project that make use of source-map-loader

Steps

  1. Install standardized-audio-context package
  2. Import any module from standardized-audio-context into a *.js/*.ts file
  3. Start/build the project

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Aug 20, 2020

@shimizacken yes, let’s open an issue and wait an answer, if they will not fix it, I will think about it deeply, and provide fallback for this cases

1reaction
alexander-akaitcommented, Aug 20, 2020

@shimizacken I investigate this issue and I’m afraid to say that we cannot fix it, sourceMappingURL is strange:

//# sourceMappingURL=/build/es2019/factories/native-constant-source-node-factory.js.map

In file node_modules/standardized-audio-context/build/es2019/factories/native-constant-source-node-factory.js

it is relative to package root, but we don’t know it is package or not, this would require additional logic that would decrease performance dramatically.

Right sourceMappingURL:

//# sourceMappingURL=./native-constant-source-node-factory.js.map
//# sourceMappingURL=native-constant-source-node-factory.js.map

Ideally it should be always relative to file, not to directory/package root or other contexts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack Module Warning: Failed to parse source map from ...
If you're experiencing this issue with react-scripts /cra version 5.0.0 . You'll need to add the following to your .env file.
Read more >
webpack 5: Failed to parse source map from "@mswjs ...
I'm seeing these warnings when starting the dev server using react-scripts start , If i exclude the above config by setting GENERATE_SOURCEMAP= ...
Read more >
Failed to parse source map warnings - Dynamic Docs
If using create-react-app v5, you may see some warnings (although they appear like errors) when running/building your react application. This has been reported ......
Read more >
source-map-loader - webpack
Extracts source maps from existing source files (from their sourceMappingURL ). Getting Started. To begin, you'll need to install source-map-loader : npm i ......
Read more >
upgrading to webpack 5 causes sourcemap issues : r/typescript
As it is a component library, I am getting a warning for every file but ... node_modules/source-map-loader/dist/cjs.js): Failed to parse ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found