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
@/all Welcome! :)
Konstantin Tarkus
@koistya
@/all Published generator-javascript v0.0.9 (changelog)
fergusg
@fergusg
This message was deleted

I'm brand new to ES7 async/await. Can the compile.js css (for example) be written as

const css = async (source, options)  => {
    options = options || {};
    return (await postcss.process(source, {
            from: 'docs/css/main.css',
            to: 'docs/css/main.min.css',
            map: !!options.map
        })).css;
};

i.e, without the extra Promise. It certainly seems to work but I expect I've missed something.

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.')