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

Problems with babel-polyfill and debug #32

Closed
nasushkov opened this issue May 6, 2016 · 3 comments
Closed

Problems with babel-polyfill and debug #32

nasushkov opened this issue May 6, 2016 · 3 comments

Comments

@nasushkov
Copy link

Hi, I'm trying this boilerplate for one of my personal projects. Two problems that I faced at the very beginning:

  1. babel-polyfill works only when I explicitly call babel-register with presets like this:
    require("babel-register")({ presets: [ 'es2015', 'react', 'stage-0'], plugins: [ "add-module-exports", "babel-root-import", "react-require", ["provide-modules", { "debug": "debug" }] ] });
    It seems that it ignores .babelrc. So how can I fix it without calling require("babel-register") explicitely/
  2. debug doesn't work with babel-polyfill. I tried various configurations (exact as in the boilerplate, explicitly requiring debug), but it works only when I remove babel-polyfill at all. Any thoughts how to work around this?

Thanks.

@tomatau
Copy link
Owner

tomatau commented May 6, 2016

Hi - how are you starting this commands? Could you give me some repro steps as when I run npm start it works for me.

@nasushkov
Copy link
Author

nasushkov commented May 6, 2016

I simplified your code for my case So this one doesn't work:

require('babel-polyfill');
const argv = require('yargs').argv;
const fileWithPath = (() => {
    switch(true) {        
        case argv.build:
            return './build.js';
        default:
        case argv.start:
            return '../app/server';
    }
})();
require(fileWithPath);

And this works fine:

require('babel-polyfill');
require("babel-register")({
    presets: [ 'es2015', 'react', 'stage-0'],
    plugins: [
        "add-module-exports",
        "babel-root-import",
        "react-require",
        ["provide-modules", {
            "debug": "debug"
        }]
    ]
});
const argv = require('yargs').argv;

const fileWithPath = (() => {
    switch(true) {        
        case argv.build:
            return './build.js';
        default:
        case argv.start:
            return '../app/server';
    }
})();

require(fileWithPath);

Everything else is pretty same. Maybe it's because I'm running it on windows 10.
The second problem is not valid anymore (I was too late to set DEBUG variable, my mistake)

@tomatau
Copy link
Owner

tomatau commented May 6, 2016

how are you starting this command? babel needs to know that it should be applied to the files still, so you would either need to compile it with babel or start using babel-node.

I prefer to use the babel-register in combination with a babelrc.

The problems you're facing aren't with this boilerplate as you've changed the boilerplate. Your problems are with using babel the way you expect to.

@tomatau tomatau closed this as completed May 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants