Re-exporting modules does not work with object spread

Viewed 2500

i have an index.js file that reads:

import aReducer from './ducks/a';
import bReducer from './ducks/b';
import * as aSelectors from './ducks/a';
import * as bSelectors from './ducks/b';

console.log(aReducer) //function i expect
console.log(aSelectors) //object with keys to selectors i expect

export { aReducer, bReducer, ...aSelectors, ...bSelectors };

If I console.log in this file I see that the reducers are functions I expect and the selectors alias are objects with keys to the selectors I expect. The reducers are default exports for the duck files and the selectors are exports from the same respective file.

However, when I try to import this module with another file I am only able to import the two reducers. The two selectors are undefined. I thought that de-structuring would add each key to my export object. What am I doing wrong?

other_file1.js

import { aReducer, bReducer } from 'my-module'; //works!

other_file2.js

import { someSelectorThatWasInMyaSelectorsObject } from 'my-module'; //does NOT work!
1 Answers
Related