Skip to content

Commit

Permalink
Support default exports. (#59)
Browse files Browse the repository at this point in the history
* Support default exports.

* Update README.md

* Update README.md
  • Loading branch information
IRT-fbachmann authored and adrai committed Aug 28, 2017
1 parent 2f7379c commit 5feebdb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,27 @@ or depending on the last guarded event:
denormalizer.clear(function (err) {
});

## ES6 default exports
Importing ES6 style default exports is supported for all definitions where you also use `module.exports`:
```
module.exports = defineCollection({...});
```
works as well as
```
exports.default = defineCollection({...});
```
as well as (must be transpiled by babel or tsc to be runnable in node)
```
export default defineCollection({...});
```

Also:
```
exports.default = defineViewBuilder({...});
exports.default = defineEventExtender({...});
// etc...
```
Exports other than the default export are then ignored by this package's structure loader.

[Release notes](https://github.com/adrai/node-cqrs-eventdenormalizer/blob/master/releasenotes.md)

Expand Down
4 changes: 4 additions & 0 deletions lib/structure/structureParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ function pathToJson (root, paths, addWarning) {
return;
}

if (typeof required === 'object' && typeof required.default !== 'undefined') {
required = required.default;
}

if (_.isArray(required)) {
_.each(required, function (req) {
res.push({
Expand Down

0 comments on commit 5feebdb

Please sign in to comment.