Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Konstantin Tarkus
@koistya
@fergusg, using ES7 async/await with Promise like objects (e.g. postcss.process(..) returns a LazyResult object) works fine in Babel. Not sure what the official implementations will bring, but most likely they will also work with then-able objects.
Konstantin Tarkus
@koistya
@fergusg I have changed this piece of code in tools/utils/compile.js to use ES7 async/await
Dominik
@dezet
Yea, used some of ES7 async/await at my side project, runned like week or so like a charm ;)
chetanism
@chetanism
Hi, I have a quick question. When I build my library it also outputs the original source as *.babel.js files. Just wondering what's the use for this?
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya, how do I run tests in browser? I want to make use of dev tools for debugging.
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya, ping?
Konstantin Tarkus
@koistya
@lolmaus did you check WebdriverIO? It might be a good option for testing your components in real browsers
@/all just published Babel Starter Kit v1.1.0 with unit test code coverage support via Coveralls and Istanbul
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Not yet. Did you try plugging it into Babel Starter Kit?
Konstantin Tarkus
@koistya
@lolmaus nope, not sure yet if it's applicable to the majority of use cases
Andrey Mikhaylov (lolmaus)
@lolmaus

@koistya There's another node boilerplate that does allow running tests in the browser: https://github.com/babel/generator-babel-boilerplate

Can you implement it in Babel Starter Kit accordingly?

Konstantin Tarkus
@koistya
@lolmaus ok, will do
Konstantin Tarkus
@koistya
Just have updated README.md; added CHANGELOG.md and CONTRIBUTING.md files.
Konstantin Tarkus
@koistya
@lolmaus do you need to run unit or e2e tests in the browser?
Konstantin Tarkus
@koistya
@lolmaus here is an example, how you can run unit test in a browser environment via jsdom: https://github.com/koistya/babel-starter-kit/blob/master/docs/recipes/testing-with-mocha-and-jsdom.md
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya That's a completely different task.
@koistya JSDOM is for testing browser UI components in Node. I want the opposite -- testing a Node module in a browser, so that I can leverage Developer Tools for debugging.
Konstantin Tarkus
@koistya
@lolmaus that's why I asked you previously whether you need that for unit tests or e2e tests
@lolmaus as a rule of thumb, it's better to run unit tests with jsdom because it works much faster and easier to work with
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya JSDom is super limited. If you develop a browser package, the change of facing JSDom restrictions is too high.
@koistya And I totally would develop a standalone browser component in Babel Starter Kit, because it's so convenient.
Konstantin Tarkus
@koistya
@lolmaus as far as I understand, you just want being able to see how your UI component looks like in a browser during development and being able to debug it with Chrome Dev Tools, right?
Andrey Mikhaylov (lolmaus)
@lolmaus

@koistya Yes. But the "being able to debug it with Chrome Dev Tools" part also stands true for developing Node modules.

I just wish I had a universal starter kit, capable of building both browser and Node modules.

Konstantin Tarkus
@koistya
@lolmaus are you building an isomorphic library, that should work in both node and browser environments? Or, you want to use the same template for different project types?
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya The latter.
Konstantin Tarkus
@koistya
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya That would look way better with decorators.
Konstantin Tarkus
@koistya
@lolmaus can you give an example?
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Never mind, turns out you can't decorate variables, only methods and properties.
Andrey Mikhaylov (lolmaus)
@lolmaus

@koistya Can you please please please impelment in-browser testing?

I'm anxious to release my own assertion library, but generator-babel-boilerplate sucks and babel-starter-kit does not allow browser testing, so I'm stuck.

My goal is to replace this:

    if (typeof name !== 'undefined') {
      invariant(
        typeof name === 'string' || name instanceof String,
        'The name argument must be a string'
      );
      invariant(
        name.length >= 5 && name.length <= 7
        'The name argument be of length between 5 and 7'
      );
    }
    this.name = name;

With this:

    Assertron({name}, {string: true, length: {min: 5, max: 7}, optional: true});
    this.name = name;

The Assertron function can be replaced with a noop for max performance in production. Or you can leave it for decent error messages.

Konstantin Tarkus
@koistya
That's what fbjs-scripts/babel-6/dev-expression plugin does, when you use fbjs/lib/invariant function for testing application's state
@lolmaus invariant(validate(name).length({ min: 5, max: 7 }), 'The name argument is invalid.')
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Can you link to validate docs please?
Konstantin Tarkus
@koistya
though.. validate won't be replaced
@lolmaus check it out - https://www.npmjs.com/package/validator
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Looks like dev-expression does not replace, but rather wrap. Increased performance at the cost of larger file size.
Konstantin Tarkus
@koistya
@lolmaus it adds process.env.NODE_ENV check, which is replaced by a string literal on build by webpack/browserify, which is then stripped off by js minimizer (uglifyjs)
invariant(...) -> if (process.env.NODE_ENV !== 'production') { invariant(..) } else { .. } -> if ('production' !== 'production') { invariant(..) } else { .. } -> ..
..assuming that you bundle your application code before deploying to a production server. This is considered to be a good practice if you're using ES2105+ / Babel
Andrey Mikhaylov (lolmaus)
@lolmaus
This message was deleted

@koistya validator seems to be only for strings? My goal is a universal assertion library with extremely agile syntax (e. g. you can use and, or, satisfy, etc.) and automatically generated error messages (with optional manually provided messages).

I'm not aware of an assertion library that can do this:

Assertron({name}, {           // Uses key in error messages, e. g. "name must be of length between 5 and 7, was 9"
  optional: true,             // Will not perform checks if the value is undefined
  length:   {min: 5, max: 7}, // For a POJO will count own keys.
  or: {                       // Will be true if one of the requirements is true. Keys mean type checks.
    string: {match:         /foo|bar/},
    array:  {containsOneOf: ['foo', 'bar']},
    object: {hasOneOfKeys:  ['foo', 'bar']}
  }
});

Imagine writing that in Chai or validator or whatever assertion library you like the most. you'll end up with nested ifs, it will look terrible and unreadable. And the necessity to wrap it into dev-expression makes it even worse.

Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Whatcha say?
Konstantin Tarkus
@koistya
@lolmaus something similar to what used in React (PropTypes)?
Andrey Mikhaylov (lolmaus)
@lolmaus

@koistya Probably, except for my approach is not limited to checking types. You can add whatever checks you want.

I draw inspiration from this library's assertions collection and plugins: http://unexpected.js.org/assertions/any/to-be/

I don't use Chai and Unexpected because their API is method chaining, and method chaining:

  • does not allow the or operand;
  • does not allow swapping the main assertion object with a noop.

I find a JSON-like API to be the most powerful.

What do you think?
Konstantin Tarkus
@koistya
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya Any news on debugging babel-starter-kit modules in Chrome?
Konstantin Tarkus
@koistya
@lolmaus I'm not sure if it's a good idea to include that into the kit, maybe on a separate branch..
@lolmaus it might depend to much on what exactly you're building... e.g. if you're developing React components, it might be a great idea to use react-storybook for testing in a browser
Andrey Mikhaylov (lolmaus)
@lolmaus
@koistya I'm building a generic library, useful in both Node and browser.