Git Product home page Git Product logo

babel-plugin-console's Introduction

Hey there ๐Ÿ‘‹, I'm Matt Phillips.

Twitter Sponsor Blog


I'm a software engineer who is passionate about open-source software, functional programming, and testing. I'm a perpetual learner who loves sharing my knowledge on all things code, career development and building products.

If I'm not tinkering on my own products, I'm working on open-source. I've published multiple successful packages, which are downloaded millions of times each month, and most notably helped maintain Jest and the Jest Community.

I also share my experiences over on my blog. You can expect to learn more about Typescript, Node, React, Testing, and Functional Programming โ€“ with some content on career development and founding products thrown in too.

Twitter is the best place to keep up to date with what I'm working on, so follow along there for:

  • ๐Ÿ‘จโ€๐Ÿ’ป Web dev, functional programming & testing in Typescript
  • ๐Ÿคฉ Getting into / maintaining open source software
  • ๐Ÿ’ธ Tech entrepreneurship
  • ๐Ÿ“ข Building in public
  • ๐Ÿง‘โ€๐Ÿš€ Career advice

Or wanna chat? My DMs are always open ๐Ÿ˜Š.

If you want to help support my work then please consider sponsoring me on GitHub.

What I work on

Package Description Role Downloads
Jest Delightful JavaScript Testing. Maintainer jest downloads
jest-each Data driven testing for Jest. Author jest-each downloads
deep-object-diff Deep diff two JavaScript Objects. Author deep-object-diff downloads
jest-extended Additional Jest matchers ๐Ÿƒ๐Ÿ’ช Author jest-extended downloads
jest-expect-message Add custom message to Jest expects. Author jest-expect-message downloads
jest-chain Chain Jest matchers together to create one powerful assertion. Author jest-chain downloads

babel-plugin-console's People

Contributors

mattphillips avatar stevebluck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

babel-plugin-console's Issues

Errors with usage in CRAv2

Bug

  • babel-plugin-console version: 0.2.1
  • node version: 9.5.0
  • npm (or yarn) version: yarn 1.7.0

Relevant code or config

import React, { Component } from "react";
import scope from "scope.macro";

function add100(a) {
  const oneHundred = 100;
  scope("Add 100 to another number");
  return add(a, oneHundred);
}

function add(a, b) {
  return a + b;
}

class App extends Component {
  componentDidMount = () => {
    add100(1);
  };

  render() {
    return (
      <div className="App">
      </div>
    );
  }
}

export default App;

What you did:

  1. npx create-react-app@next --scripts-version=2.0.0-next.66cc7a90
  2. yarn add babel-plugin-console & yarn add scope.macro
  3. Inserted above example code from this plugins pages in barebones CRAv2 App.js
  4. yarn start

What happened (please provide anything you think will help):

index.js:2214 ./src/App.js
Module build failed: Error: Unknown substitution "args" given
    at Array.forEach (<anonymous>)
    at Array.map (<anonymous>)
    =============
    at Array.map (<anonymous>)
    at Array.forEach (<anonymous>)

As far as I know, the upcoming Create-React-App version 2 comes with built-in support for babel-macros.
I also checked with another babel-macro plugin, which is working fine.

Edit: missed a line.

Fails on class member methods

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.

upgrade to babel-plugin-macros

I think you're running on a rather old version of babel-macros so there will be a handful of changes you'll need to make (in addition to some docs updates and make sure you add babel-plugin-macros to the keywords in your package.json).

I suggest reading through the author docs briefly to make sure you don't miss anything.

babel-plugin-macros is about to become big with the release of CRA v2.0 and I'd love your plugin to be a part of that!

TypeError: Cannot destructure property `node` of 'undefined' or 'null'

Bug

  • babel-plugin-console version: 0.2.1
  • node version: 10
  • npm (or yarn) version: 6

Relevant code or config

I tried putting the console.scope anywhere

What you did:
I think this plugin doesn't work with babel 7 because I used this plugin with babel
"babel-core": "^7.0.0-bridge.0",
"@babel/core": "^7.0.0-beta.52",

What happened (please provide anything you think will help):

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot destructure property `node` of 'undefined' or 'null'.
    at getCurriedFunctionSignature (/home/capaj/git_projects/looop/project-alpha/node_modules/babel-plugin-console/dist/scope/signatures/index.js:34:46)
    at exports.default (/home/capaj/git_projects/looop/project-alpha/node_modules/babel-plugin-console/dist/scope/signatures/index.js:10:12)
    at traverseFunctions (/home/capaj/git_projects/looop/project-alpha/node_modules/babel-plugin-console/dist/scope/index.js:115:41)
    at exports.default (/home/capaj/git_projects/looop/project-alpha/node_modules/babel-plugin-console/dist/scope/index.js:28:17)
    at PluginPass.CallExpression (/home/capaj/git_projects/looop/project-alpha/node_modules/babel-plugin-console/dist/index.js:37:43)
    at newFn (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitSingle (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:90:19)
    at TraversalContext.visit (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:146:19)
    at Function.traverse.node (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:94:17)
    at NodePath.visit (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:95:18)
    at TraversalContext.visitQueue (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitMultiple (/home/capaj/git_projects/looop/project-alpha/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:85:17)

Reproduction repository (if possible):

Fails to transpile if function assigned to computed property

Bug

  • babel-plugin-console version: 0.2.0
  • node version: v6.9.4
  • npm (or yarn) version: yarn v0.27.5
{
    [ActionTypes.FOO_BAR](payload) {
        // ...
        console.scope('debug')
    },
}

Put console.scope inside a function, which is assigned to a computed property.

Result: transpile fails, says Cannot read property 'name' of undefined.

Update Readme (broken link(

Readme says:

NOTE: There's also a separate package available called scope.macro which you can install and use instead if you prefer to type less.

That links to an empty repo. If this package no longer exists, please remove, else please update the link. I'd love to type less :D

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.