export.macro
v1.0.2
Published
export all from current path(all files and all dirs)
Downloads
3
Readme
English | 简体中文
install
npm i -D export.macro
// or
yarn add -D export.macro
ensure you have installed babel-plugin-macros
.babelrc
{
plugins: ['babel-plugin-macros']
}
usage
import exportAll from "export.macro";
exportAll("./", {
exclude: ["**/*.test.js"],
noDefault: false,
onlyIndex: true,
});
output:
export {default as Something} from "./Something";
export * from "./Something";
...
custom import
add a config file:
- .babel-plugin-macrosrc
- .babel-plugin-macrosrc.json
- .babel-plugin-macrosrc.yaml
- .babel-plugin-macrosrc.yml
- .babel-plugin-macrosrc.js
- babel-plugin-macros.config.js
- babelMacros in package.json
Configuration is as follows:
options
exclude
string[]: glob ignore config, alreday addnode_modules/**/*
noDefault
boolean: make sure don't needexport {default as Filename} from './Filename'
, default is falseonlyIndex
boolean: for dir, just export index file, default is true
// .babel-plugin-macrosrc.js
module.exports = {
exportAllHelper: {
exclude: ["node_modules/**/*"],
noDefault: false,
onlyIndex: true,
},
};
then, you can import customImport
from export.macro
:
import exportAll from "export.macro";
exportAll("filename", {
exclude: ["node_modules/**/*"],
noDefault: false,
onlyIndex: true,
});