luwes / rollup-plugin-size

🍣 Track compressed Rollup asset sizes over time.
65 stars 4 forks source link

Compatibility with rollup-plugin-typescript2 #9

Open kalitine opened 4 years ago

kalitine commented 4 years ago

Rollup: 1.29.1 NodeJS: 12.14.1

My build without rollup-plugin-size works, but when I add the plugin it throws the error:

(plugin rpt2) Error: Unknown object type "asyncfunction"
src/index.ts
Error: Unknown object type "asyncfunction"
    at Object._object (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:218:17)
    at Object._function (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:319:14)
    at Object.dispatch (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:185:30)
    at PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:246:18
    at Array.forEach (<anonymous>)
    at Object._object (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:242:21)
    at Object.dispatch (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:185:30)
    at PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:260:23
    at Array.forEach (<anonymous>)
    at Object._array (PATH_TO_REPO/node_modules/rollup-plugin-typescript2/node_modules/object-hash/index.js:259:20)

Here is my rollup.config.js:

import resolve from '@rollup/plugin-node-resolve'
import typescript from 'rollup-plugin-typescript2'
import commonjs from '@rollup/plugin-commonjs'
import autoExternal from 'rollup-plugin-auto-external'
import size from 'rollup-plugin-size'

export default [
  {
    input: 'src/index.ts',
    output: {
      file: 'dist/server-translator.cjs.js',
      format: 'cjs'
    },
    plugins: [autoExternal(), typescript(), resolve(), commonjs(), size()]
  },
  {
    input: 'src/index.ts',
    output: {
      file: '...',
      format: 'esm'
    },
    plugins: [
      autoExternal(),
      typescript({
        useTsconfigDeclarationDir: true,
        tsconfigOverride: {
          compilerOptions: {
            declarationDir: 'dist/types',
            declaration: true,
            types: ['node', 'got']
          },
          include: ['src/**/*.ts'],
          exclude: ['test/**/*']
        }
      }),
      resolve(),
      commonjs(),
      size()
    ]
  }
]

I presume there is something in using both rollup-plugin-typescript2 and rollup-plugin-size. altogether. It doesn't seem that they should be related in some way, but they still do.

jamiehaywood commented 3 years ago

+1