5

So I'm using bundlephobia to audit the bundle size of my packages. Bundlephobia has a section called "Export Analysis" that gives you the bundle size of the individual exports.

export analysis

So each of these functions in this bundle are pure functions so, unless I'm missing something, I think these should show a smaller size for each function but all of them (except the re-exported one) have the same size.

I tried:

  • Adding "sideEffects": false" to my package.json
  • Marking every function with #__PURE__

I'm using rollup and this is my rollup config:

// rollup.config.js
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';

const extensions = ['.js', '.ts', '.tsx'];

export default [
  {
    input: './src/index.ts',
    plugins: [
      resolve({
        extensions,
      }),
      babel({
        babelrc: false,
        presets: ['@babel/preset-env', '@babel/preset-typescript'],
        babelHelpers: 'bundled',
        extensions,
      }),
    ],
    output: {
      file: 'dist/index.js',
      format: 'umd',
      name: 'parseToRgba',
      sourcemap: true,
    },
  },
  {
    input: './src/index.ts',
    plugins: [
      resolve({
        extensions,
        modulesOnly: true,
      }),
      babel({
        babelrc: false,
        presets: ['@babel/preset-typescript'],
        plugins: ['@babel/plugin-transform-runtime'],
        babelHelpers: 'runtime',
        extensions,
      }),
    ],
    output: {
      file: 'dist/index.esm.js',
      format: 'esm',
      sourcemap: true,
    },
    external: ['@ricokahler/parse-to-rgba'],
  },
];

Nothin.

How do I do this?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Rico Kahler
  • 17,616
  • 11
  • 59
  • 85
  • Maybe @shubham-kanodia knows, the author of Bundlephobia: https://stackoverflow.com/a/43166167 (I'm not sure if tagging him works though :) ) – Vincent Jun 17 '20 at 09:09

0 Answers0