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

Module name is treated as undefined #97

Open
wasimpathan5 opened this issue Jan 18, 2019 · 0 comments
Open

Module name is treated as undefined #97

wasimpathan5 opened this issue Jan 18, 2019 · 0 comments

Comments

@wasimpathan5
Copy link

Here's my simple module (named module1.js)

var someVar = 1; export default {someVar};

I have a grunt task as below,
babel: { files: { expand: true, src: ['src/*.js'], dest: 'dist/' }, options: { sourceMap: true, presets: ['env'] } }

This transpiles module1.js as,
`(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.undefined = mod.exports;
}
})(this, function (exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
var someVar = 1;
exports.default = {
someVar: someVar
};
});
//# sourceMappingURL=module1.js.map`

Actual behavior: Note the highlighted code in above output
Expected behavior: It should be the module name instead of undefined i.e.
global.module1 = mod.exports;

Note: This works fine when I run it through cmd as,
$ babel src/module1.js --out-file dist/module1.js

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

1 participant