Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #399 from MiguelCastillo/bundle-named-export
cleaned up bundle named exports to make it more clear where we set th…
- Loading branch information
Showing
3 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function configureNamedExports(exportNames) { | ||
if (!exportNames) { | ||
return () => {}; | ||
} | ||
|
||
var exportedNames = ( | ||
exportNames === true ? true : | ||
Array.isArray(exportNames) ? | ||
exportNames.reduce((acc, item) => (acc[item] = item, acc), {}) : | ||
exportNames | ||
); | ||
|
||
return function(mod) { | ||
var name = exportedNames === true && /^\w/.test(mod.name) ? mod.name : exportedNames[mod.name]; | ||
|
||
if (name !== undefined) { | ||
return JSON.stringify(name); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = configureNamedExports; |