Babel
re-export
babel-plugin-transform-export-extensions
https://babeljs.io/docs/en/babel-plugin-transform-export-extensions
import * as React from 'react';
export default React;
export * from 'react';
export { default } from 'react';
import React from './reExport';
export { default as anotherName1 } from './someResource1';
export { default as anotherName2 } from './someResource1';
import { anotherName1, anotherName2 } from './upperFolder';
- 範例:
export { default } from './Accordion';
https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/Accordion/index.js
檔案路徑用 @
來替代 ./
的方法,增加引入的一致性
"plugins": [
[
"babel-plugin-module-resolver",
{
"alias": {
"@": "./"
}
}
]
]