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

DevTools failed to load SourceMap #32

Closed
jhess666 opened this issue Jul 22, 2020 · 6 comments
Closed

DevTools failed to load SourceMap #32

jhess666 opened this issue Jul 22, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@jhess666
Copy link

Describe the bug

DevTools can't parse generated source maps.

How it happened?

The error is pretty much trivial and happens because of the path replacements (probably only for Windows).

It's easy to identify the reason just looking at the console log.

DevTools error message:
Unexpected token s in JSON at position 86

Now, let's take a look at the generated source map file.

The source map JSON:

{"version":3,"sources":[],"names":[],"mappings":"","file":"main.css","sourceRoot":"..\src"}

See, the sourceRoot value contains a non-escaped string. Should be "..\\src";

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Parcel version: 1.12.4
  • Plugin version: 1.1.14

Plugin configuration object:

"customDistStructure": {
  "config": {
    "css": [
      ".css",
      ".css.map"
    ],
    "js": [
      ".js",
      ".js.map"
    ]
  },
  "options": {
    "development": true
  }
}
@jhess666 jhess666 added the bug Something isn't working label Jul 22, 2020
@VladimirMikulic
Copy link
Owner

Hi @jhess666. Thank you for reporting this issue.
Do you, by any chance use WSL?

@jhess666
Copy link
Author

Nope. It's a pure Windows environment.

@VladimirMikulic
Copy link
Owner

Hi @jhess666.

I have a Windows 7 in VM and I am unable to reproduce the issue. Could you set up an example repo which reproduces this issue? Thanks.

@jhess666
Copy link
Author

In my tests I have found where the issue is being originated (at least for me):

// File: "./lib/Utils.js"

// ...

exports.replaceInFileSync = (files, stringToReplace, newString) => {
  const regexPattern = escapeRegex(stringToReplace);

  const result = replaceInFile.sync({
    files,
    from: new RegExp(regexPattern, 'g'),
    to: newString // <-- here, it should be escaped
  });

  return result;
};

// ...

@VladimirMikulic
Copy link
Owner

VladimirMikulic commented Jul 29, 2020

@jhess666 Could you please set up an example repo that reproduces this issue? Thanks.

@VladimirMikulic
Copy link
Owner

Closing this since I was unable to reproduce the issue. Feel free to comment here and we'll reopen this if it happens again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants