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

issue adding plugin to .babelrc #5

Closed
chalda opened this issue Oct 24, 2017 · 3 comments
Closed

issue adding plugin to .babelrc #5

chalda opened this issue Oct 24, 2017 · 3 comments
Labels

Comments

@chalda
Copy link

chalda commented Oct 24, 2017

Hi there, trying to get your module working in attempt to fix some linenumber issues with mocha/babel.

getting the follow error:

Error: Cannot find module 'source-map-support/register'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

have the following .babelrc file where the plugin is being used:

{
  "presets": ["es2015", "react", "stage-0"],
  "plugins": ["transform-object-rest-spread", "transform-decorators-legacy", "transform-class-properties"],
  "env": {
    "test": {
      "presets": ["es2015", "react", "stage-0"],
      "plugins": ["transform-object-rest-spread", "transform-decorators-legacy", "transform-class-properties", "rewire", "source-map-support"],
      "sourceMaps": "both"
    }
  }
}

and the test is run with babel-instanbul
"test:unit": "cross-env NODE_ENV=test babel-node node_modules/.bin/babel-istanbul cover --config=istanbul.json --dir coverage/unit node_modules/.bin/_mocha -- --require node_modules/ignore-styles 'client/**/*.spec.unit.js'",

its possible the error is coming from babel-istanbul as that tool is somewhat outdated.

@chocolateboy
Copy link
Owner

Error: Cannot find module 'source-map-support/register'

You need to install the source-map-support module:

In conjunction with the source-map-support module, which must be installed separately, this statement hooks into the v8 stack-trace API to translate call sites in the transpiled code back to their corresponding locations in the original code.

@chalda
Copy link
Author

chalda commented Oct 25, 2017

ahh musta missed it. my bad. why not install that module as a dependency or at least indicate it as a peer?

@chocolateboy
Copy link
Owner

chocolateboy commented Oct 25, 2017

Babel runs at compile time, and the dependency is needed at runtime. In practice you'll usually be bundling source-map-support locally for development and disabling it for production, in which case it would make sense to peer-depend on it, but that's just a convention, not an intrinsic requirement of this plugin.

For example, a project could be compiled in one environment (source-map-support not needed), tested in a CI environment (source-map-support needed), and deployed to another (source-map-support not needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants