Code Monkey home page Code Monkey logo

Comments (6)

0xR avatar 0xR commented on July 26, 2024 2

Ok if the example is wrong I have created a new example that does work:

original.js:

require('source-map-support').install();

throw new Error('test'); // This is the original code

compiled.js:

throw require("source-map-support").install(),new Error("test");
//# sourceMappingURL=compiles.js.map

compiled.js.map:

{"version":3,"sources":["original.js"],"names":["require","install","Error"],"mappings":"AAEA,KAFAA,SAAQ,sBAAsBC,UAExB,GAAIC,OAAM"}

from node-source-map-support.

julien-f avatar julien-f commented on July 26, 2024 1

This project is not broken, I use it regularly!

But indeed, the demo is not working as it should…

from node-source-map-support.

0xR avatar 0xR commented on July 26, 2024

Maybe put this in a example dir in the repo? to make it easier for people?

from node-source-map-support.

CrabDude avatar CrabDude commented on July 26, 2024

Ditto. It looks like the culprit for me is the "transform-strict-mode" plugin:

$ cat foo.js 
require('source-map-support').install();

throw new Error('test'); // This is the original code
$ babel-node foo.js 
Error: test
    at Object.<anonymous> (/private/tmp/foo/foo.js:5:7)
    at Module._compile (module.js:399:26)
    at loader (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:130:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:345:32)
    at Function.Module._load (module.js:302:12)
    at Function.Module.runMain (module.js:431:10)
    at /Users/crabdude/.npmprefix/lib/node_modules/babel-cli/lib/_babel-node.js:161:27
    at Object.<anonymous> (/Users/crabdude/.npmprefix/lib/node_modules/babel-cli/lib/_babel-node.js:162:7)
    at Module._compile (module.js:399:26)
$ babel-node -V
6.3.17
$ npm ls source-map-support
[email protected] /private/tmp/foo
└── [email protected]  extraneous

$ node -v
v5.2.0
$ cat .babelrc 
{
  "plugins": ["transform-strict-mode"]
}

It would be nice to know if this is a bug with babel-plugin-transform-strict-mode or node-source-map-support.

Phabricator issue

from node-source-map-support.

seanpoulter avatar seanpoulter commented on July 26, 2024

Re: @CrabDude's "transform-strict-mode" plugin issue:

This isn't a problem for me from babel-node 6.24.0 and node 6.10.

$ npm i babel-cli babel-plugin-transform-strict-mode source-map-support

$ cat foo.js
require('source-map-support').install();
throw new Error('test'); // This is the original code

$ cat .babelrc
{
  "plugins": ["transform-strict-mode"]
}

$ babel-node foo.js
throw new Error('test'); // This is the original code
      ^
Error: test
    at Object.<anonymous> (F:/tmp/@CrabDude/foo.js:2:7)
    at Module._compile (module.js:570:32)
    at loader (F:\tmp\@CrabDude\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (F:\tmp\@CrabDude\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.Module.runMain (module.js:604:10)
    at Object.<anonymous> (F:\tmp\@CrabDude\node_modules\babel-cli\lib\_babel-node.js:154:22)
    at Module._compile (module.js:570:32)

$ babel foo.js --out-file compiled-foo.js --source-maps

$ node compiled-foo.js
throw new Error('test'); // This is the original code
      ^
Error: test
    at Object.<anonymous> (F:\tmp\@CrabDude\foo.js:2:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

from node-source-map-support.

LinusU avatar LinusU commented on July 26, 2024

This is fixed now 👏

from node-source-map-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.