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.

The sources field in the generated sourceMap is always ["sourceMap"]

See original GitHub issue

I obfuscate my code use config

{
    compact: true,
    controlFlowFlattening: true,
    controlFlowFlatteningThreshold: 1,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: false,
    identifierNamesGenerator: 'hexadecimal',
    log: true,
    renameGlobals: false,
    rotateStringArray: true,
    selfDefending: true,
    stringArray: true,
    stringArrayEncoding: 'rc4',
    stringArrayThreshold: 1,
    transformObjectKeys: true,
    unicodeEscapeSequence: false,
    sourceMap: true,
    sourceMapMode: 'inline',
}

after I decode the base64 encoded sourceMap, I found “sources”:[“sourceMap”], this made all the error stack shows the correct line number with wrong filename ''sourceMap"

Expected Behavior

the error stack from a file a.js should have error stack with filename a.js

Current Behavior

the error stack from a file a.js have error stack with filename sourceMap.js

Steps to Reproduce (for bugs)

  1. create a file ‘a.js’
  2. the first line of ‘a.js’ should require('source-map-support').install();.
  3. throw error in ‘a.js’, use console.log() print the error stack
  4. do obfuscate with the config above
  5. run the obfuscated a.js
  6. the error stack show the bug

Your Environment

  • Version used: node: 8.10.0 javascript-obfuscator: latest

Stack trace

Minimal working example that will help to reproduce issue

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
sanex3339commented, Jun 8, 2018

Obfuscator has two interfaces: CLI and Node API.

With CLI - obfuscator reads file and know file name of this file. With CLI obfuscator passing internallyinputFileName based on name of the input file, and as result - you wont to do this manually. inputFileName is not available with CLI.

With Node API (all plugins are using this variant) obfuscator knows nothing about files. It obfuscating strings with source code and you should pass inputFileName value, so obfuscator will know name of the file that contains source code.

1reaction
sanex3339commented, Jun 7, 2018

Fix in master branch now. Until release you can use version from master branch.

When 0.17.0 will released, you have two options:

  • wait until author of plugin manually added passthrough of input file name to the inputFileName option
  • manually add input file name as value of inputFileName option.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Source Map Revision 3 Proposal
The original source map format (v1) was created by Joseph Schorr for use by Closure Inspector to enable ... Always present if there...
Read more >
Anatomy of source maps | Bugsnag Blog
Source maps help you debug errors in your JavaScript code by mapping minified code to your original source. Learn how source maps work...
Read more >
Source Maps are Great … When You Get It Right | by Coursera
sourcesContent is an array field in sourcemaps where you can embed the original source into the map itself. this means you no longer...
Read more >
How to set up source maps to help debug production JavaScript
Developers can use source maps to map transpiled code back to their original source code. These five tips help developers get source maps ......
Read more >
Use a source map — Firefox Source Docs documentation
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original...
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