feat: better bundle size with esmodules

This commit is contained in:
Thomas Osmonson
2020-07-23 11:45:18 -05:00
committed by Thomas Osmonson
parent 4ef2948fee
commit 2c7046f70d
2 changed files with 11 additions and 1 deletions

View File

@@ -91,7 +91,7 @@
]
},
"main": "dist/index.js",
"module": "dist/ui.esm.js",
"module": "dist/index.esm.js",
"peerDependencies": {
"react": "16.x",
"react-dom": "16.x",

View File

@@ -0,0 +1,10 @@
module.exports = {
rollup(config, options) {
if (options.format === 'esm') {
config = { ...config, preserveModules: true };
config.output = { ...config.output, dir: 'dist/', entryFileNames: '[name].esm.js' };
delete config.output.file;
}
return config;
},
};