When using externalHelpers: true, all helpers are imported from the helpers.js file.
This is not optimal because the helpers.js file is not a module and therefore will prevent tree shaking when bundling.
Instead we should provide a package.json that handles the export of the helpers. There we can set sideEffects: false and also use the .mjs file if possible.
I tried that out by adding the following package.json in node_modules/babel-plugin-transform-async-to-promises/helpers/package.json
Notice that I prefixed the helpers files with a- to ensure that the bundler picks the package.json instead of the plain file when importing like import { _await } from "babel-plugin-transform-async-to-promises/helpers";.
This worked for me and decreased the overall bundle size.
When using
externalHelpers: true
, all helpers are imported from thehelpers.js
file. This is not optimal because the helpers.js file is not a module and therefore will prevent tree shaking when bundling. Instead we should provide a package.json that handles the export of the helpers. There we can setsideEffects: false
and also use the.mjs
file if possible.I tried that out by adding the following package.json in
node_modules/babel-plugin-transform-async-to-promises/helpers/package.json
Notice that I prefixed the helpers files with
a-
to ensure that the bundler picks the package.json instead of the plain file when importing likeimport { _await } from "babel-plugin-transform-async-to-promises/helpers";
.This worked for me and decreased the overall bundle size.