Skip to content

Fails on class member methods #3

@kmannislands

Description

@kmannislands

Bug

  • babel-plugin-console version: v0.2.0
  • node version: tried v6.11.4 and v8.4.0
  • npm (or yarn) version: v1.1.0 and v1.3.2, respectively

What you did:
Added a console.scope to a class member method.

What happened (please provide anything you think will help):
Babel failed to build.

Relevant code or config:

To demonstrate using the babel REPL, run babel-node --plugins console and then do something like:

> class myClass { memberMethod() { console.log('foo'); } }
undefined
> new myClass().memberMethod()
foo
undefined
> class anotherClass { memberMethod() { console.scope('inside member') } }
undefined
> new anotherClass().memberMethod()
undefined

if you try and build something like the above example with webpack and babel-loader you get something like:

./foo/src/components/file-containing-class.js
Module build failed: TypeError: /abs/path/to/foo/src/module-editor/components/module-editor-page.js: Cannot read property 'start' of undefined
    at getFunctionSignature (/abs/path/to/foo/node_modules/babel-plugin-console/dist/scope/signatures/index.js:60:51)
    at exports.default (/abs/path/to/foo/node_modules/babel-plugin-console/dist/scope/signatures/index.js:13:10)
    at traverseFunctions (/abs/path/to/foo/node_modules/babel-plugin-console/dist/scope/index.js:115:41)
    at exports.default (/abs/path/to/foo/node_modules/babel-plugin-console/dist/scope/index.js:28:17)
    at PluginPass.CallExpression (/abs/path/to/foo/node_modules/babel-plugin-console/dist/index.js:37:43)
    at newFn (/abs/path/to/foo/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/abs/path/to/foo/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/abs/path/to/foo/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/abs/path/to/foo/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/abs/path/to/foo/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/abs/path/to/foo/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/abs/path/to/foo/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/abs/path/to/foo/node_modules/babel-traverse/lib/index.js:114:17)
    at NodePath.visit (/abs/path/to/foo/node_modules/babel-traverse/lib/path/context.js:115:19)
    at TraversalContext.visitQueue (/abs/path/to/foo/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/abs/path/to/foo/node_modules/babel-traverse/lib/context.js:103:17)
 @ ./src/baz/index.js 38:24-66
 @ ./src/app/app-router.js
 @ ./src/app/index.js
 @ multi (webpack)-dev-server/client?https://0.0.0.0:9090 webpack/hot/dev-server ./src/app/index.js

I would really like to use this babel-plugin (looks cool), but I can't introduce it if it kills the webpack build when a dev puts a console.scope in a wrong place.

Interested in helping to see this through if this package is still maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions