Coder Social home page Coder Social logo

rollup-plugin-size's Introduction

rollup-plugin-size npm

Prints the gzipped sizes of your rollup assets and the changes since the last build.

rollup-plugin-size

๐Ÿ™‹ Using Webpack? Check out the original size-plugin.

Installation

Install rollup-plugin-size as a development dependency using npm:

npm i -D rollup-plugin-size

Usage

Add the plugin to your rollup configuration:

// rollup.config.js
+ import size from 'rollup-plugin-size';

plugins: [
+   size()
]

License

Apache 2.0

Credits

This is a port of size-plugin by Jason Miller.

rollup-plugin-size's People

Contributors

kuldeepkeshwar avatar luwes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rollup-plugin-size's Issues

options gets overwrite in case of multiple instances of rollup-plugin-size

rollup-plugin-size uses below code to extend default options check here

const coreOptions = Object.assign(defaults, options);

In case of multiple instance of rollup-plugin-size, the options gets overwritten by the last instance's option.

e.g
rollup.config.js

import size from 'rollup-plugin-size';
import pkg from './package.json'

export default [
  {
    input: 'src/index.js',
    output: {
      file: 'dist/index.js'
      format: 'cjs',
    },
    plugins: [ size({filename:'sizes-cjs.json'})],
  },
  {
    input: 'src/index.js',
    output: {
      file: 'dist/index.es.js'
      format: 'es',
    },
    plugins: [ size({filename:'sizes-es.json'})],
  },
]

above configuration only create sizes-es.json file, ideally, it should create both(sizes-es.json & sizes-cjs.json) files

Mantan

Nama luwes saya ambil dari masa laluku.

Compatibility with rollup-plugin-typescript2

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.

[IDEA] configuable size limit?

It would be great if it support to add config in package.json

  "size": [
    {
      "file": "dist/*.js",
      "limit": "3 KB"
    }
  ]

and fail build if size is greater

Saving filesizes to disk doesn't happen

I can see there's an option writeFile and it is set to true by default, and a file named size-plugin.json should appear where sizes are being written to. Such a file never appears for me
and when I rollup my sources (without the watch option) it always looks like there were no changes to last run:

Screenshot 2019-12-12 at 10 38 57

I tested in Nodejs 12.10.0 as well as 13.2.0.

Here's an excerpt of my rollup config (I have tried to specify an explicit file name there, but both relying on the default and using an explicit file name fail):

export default [
  {
    input: 'src/api.mjs',
    output: [
      // config for <script type="module">
      {
        file: pkg.module,
        format: 'esm'
      },
      // config for <script nomodule>
      {
        file: pkg.browser,
        format: 'umd',
        name: 'Cookies',
        noConflict: true,
        banner: ';'
      }
    ],
    plugins: [licenseBanner]
  },
  {
    input: 'src/api.mjs',
    output: [
      // config for <script type="module">
      {
        file: pkg.module.replace('.mjs', '.min.mjs'),
        format: 'esm'
      },
      // config for <script nomodule>
      {
        file: pkg.browser.replace('.js', '.min.js'),
        format: 'umd',
        name: 'Cookies',
        noConflict: true
      }
    ],
    plugins: [
      terser(),
      licenseBanner, // must be applied after terser, otherwise it's being stripped away...
      size({ filename: 'sizes-min.json' })
    ]
  }
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.