Re-exporting modules does not work with object spread

给你一囗甜甜゛ 提交于 2019-12-02 03:10:12

You cannot use ... in an export {}; block. It is an explicit list of names just like import {name} from is. It is not an object with keys being exported. e.g. the same way imports do

import { foo as fooRenamed } from "";

with export it is

export {
  fooVar as foo,
};

The export block is an explicit list of variables to export, with an optional explicit name for the export. There are no objects involved.

Specifically, there are no objects involved because the names of the exports are processed and known before the body of the file has even executed, so not only are objects not allowed, they are impossible to allow because objects require execution to exist.

To get what you'd want, you should use:

// Export the referenced files' default under two specific names.
export { default as aReducer } from './ducks/a';
export { default as bReducer } from './ducks/b';

// Re-export every named export from these two files.
export * from './ducks/a';
export * from './ducks/b';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!