Module name is treated as undefined
- Dominant language
- JavaScript
- Stars
- 434
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
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`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Grunt task for src/module1.js and compare its generated wrapper with the output from the Babel CLI command. Trace how the expanded src/*.js input determines the module name. Done when the Grunt output uses module1 instead of undefined while preserving the CLI behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100