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.

Loading preexisting source map: "Unexpected token"

See original GitHub issue

I’m trying to load a preexisting source map using:

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

Unfortunately, I’m getting this warning:

WARNING in ./modules/MyFile.js.map
Module parse failed: /Users/me/MyFile.js.map Unexpected token (1:10)
You may need an appropriate loader to handle this file type.
| {"version":3,"file":"MyFile.js","sourceRoot":"","sources":["components/MyFile.tsx"],"names":[],"mappings":"AAAA,qCAAqC;;;;;;;;;;;;;AAErC,[...],GA2BnD"}

The source map was originally built by the TypeScript compiler. But in my opinion, this shouldn’t matter, since it is a standardized format and source-map-loadershould probably not have a problem with that.

I’m using the latest stable of Webpack (2.3.3) as well as the latest stable of source-map-loader (0.2.1).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
hiradimircommented, Aug 15, 2017

@kraftwer1 I had same issue, and solve it.

It is not occured by source-map-loader. This problem was occured this problem by pure webpack config, not include devtool, source-loader etc… I think almost webpack/typescript user using ts-loader.


Solution

I am using ignore-loader see https://stackoverflow.com/a/39886771/1960600


yarn add -D ignore-loader

module.exports = {
    module: {
        rules: [
            ...
            {
                test: /\.js.map$/,
                loader: 'ignore-loader'
            }
        ]
    },

Now, I can debug with source-map what typescript generate. And webpack not showing WARNING ~~ Unexpected token

0reactions
TAGCcommented, Apr 19, 2017

Oh okay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp-sourcemaps, Uncaught SyntaxError: Unexpected token
A sourcemap is a json object. You should load them properly; although Chrome knows it is a sourcemap and will treat it as...
Read more >
Node.js v19.3.0 Documentation
Building; Linking to libraries included with Node.js; Loading addons using require() ... The Module object; Source map v3 support ... parseArgs tokens.
Read more >
DevTools failed to load source map - Microsoft Q&A
Per my research you could try to uncheck "Enable JavaScript source maps" in developer tools settings. Press F12 > Settings > Uncheck "Enable ......
Read more >
Debugging — Emscripten 3.1.26-git (dev) documentation
Compiler debug information flags that allow you to preserve debug information in compiled code and even create source maps so that you can...
Read more >
Adding Google Maps to a Flutter app - Google Codelabs
In this codelab, you'll build a Google Maps experience using the Flutter mobile app SDK for crafting high-quality native experiences on iOS ...
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