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

Not transpiling to ES5 #214

Closed
vaibhav93 opened this issue Feb 15, 2016 · 11 comments
Closed

Not transpiling to ES5 #214

vaibhav93 opened this issue Feb 15, 2016 · 11 comments

Comments

@vaibhav93
Copy link

Here's my package.json deps

"devDependencies": {
        "babel-core": "^6.5.2",
        "babel-preset-es2015": "^6.5.0",
        "babel-preset-stage-2": "^6.5.0",
        "babel-loader": "^6.2.2",
        "webpack": "^1.12.13"
    }

and webpack config

module: {
            loaders: [
                {
                    test: /\.js?$/,
                    loader: 'babel',
                    exclude: /node_modules/,
                    query: {
                        presets: ['es2015']
                    }
                }
            ]
        }

The output file is not transpiled to es5.
npm v3.7.3
node v4.3.0

@Couto
Copy link
Member

Couto commented Feb 15, 2016

Can you show some example of the output code?

@vaibhav93
Copy link
Author

bundled output:
https://gist.github.com/vaibhav93/6a68b7a0b341c54416b2

Here's the cmd output of running webpack

Hash: 33c6b192930e966770ab
Version: webpack 1.12.13
Time: 56ms
 Asset       Size            Chunks             Chunks name
bundle.js  1.53 kB       0  [emitted]        main
   [0] ./script.js 135 bytes {0} [built]

The compile es6 function should have looked like:

"use strict";

var nameBuilder = function nameBuilder() {
    var firstName = arguments.length <= 0 || arguments[0] === undefined ? "John" : arguments[0];
    var lastName = arguments.length <= 1 || arguments[1] === undefined ? "Doe" : arguments[1];

    console.log(firstName + " " + lastName);
};
nameBuilder();

@Couto
Copy link
Member

Couto commented Feb 15, 2016

Does this also happens if you feed the babel binary directly?

@vaibhav93
Copy link
Author

No. It works perfectly fine with

babel --presets es2015 script.js --out-file bundled.js

@Couto
Copy link
Member

Couto commented Feb 15, 2016

Maybe I'm missing something, but i'm not able to replicate your issue.
I'm using the following example: https://gist.github.com/Couto/6c6164c24ae031bff935

@vaibhav93
Copy link
Author

@Couto Thanks. Some silly mistake at my end. Had the module object in webpack config inside the output object.

@emretekince
Copy link

I have the same issue :(
my loader settings:

{
                test: /\.js$/,
                // Skip any files outside of your project's `src` directory
                include: [
                    './public/js/src/'
                ],
                loader: "babel",
                query: {
                    presets: ['es2015']
                }
            }

@Couto
Copy link
Member

Couto commented Feb 16, 2016

@emretekince can you post your full config please?

@Couto Couto reopened this Feb 16, 2016
@emretekince
Copy link

@Couto I have fixed it now by removing babel-loader from config file.
And now using inline command like :require('babel!./script');

@Couto Couto closed this as completed Feb 16, 2016
@airtonix
Copy link

@emretekince @Couto this doesn't really fix it, just avoids the problem.

@DavidShmu
Copy link

had the same issue here, was pulling my hair till I bump into this post.
babel --presets es2015 script.js --out-file bundled.js --> did the trick

Thank you so much !

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

5 participants