swansontec / rollup-plugin-flow-entry

Allows Flow to find the original typed source code for a Rollup bundle
14 stars 4 forks source link

onwrite hook deprecated #1

Closed mg901 closed 5 years ago

mg901 commented 5 years ago

Thank you for the great plugin. I write my library, I get this error when building it

rollup-plugin-flow-entry plugin: The onwrite hook used by plugin rollup-plugin-flow-entry is deprecated. The generateBundle hook should be used instead.

My rollup config

import flow from 'rollup-plugin-flow';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
import replace from 'rollup-plugin-replace';
import flowEntry from 'rollup-plugin-flow-entry';
import pkg from './package.json';

const configuredFlow = flow({ all: true, pretty: true });

export default [
  // CommonJS
  {
    input: './src/index.js',
    output: {
      file: 'lib/styled-breakpoints.cjs.js',
      format: 'cjs',
      indent: false,
      sourcemap: false,
    },
    external: [
      ...Object.keys(pkg.dependencies || {}),
      ...Object.keys(pkg.peerDependencies || {}),
    ],
    plugins: [
      configuredFlow,
      babel(),
      uglify(),
      resolve(),
      commonjs(),
      flowEntry(),
    ],
  },

  // ES
  {
    input: './src/index.js',
    output: {
      file: 'es/styled-breakpoints.es.js',
      format: 'es',
      indent: false,
      sourcemap: false,
    },
    external: [
      ...Object.keys(pkg.dependencies || {}),
      ...Object.keys(pkg.peerDependencies || {}),
    ],
    plugins: [
      configuredFlow,
      resolve(),
      babel(),
      terser(),
      commonjs(),
      flowEntry(),
    ],
  },

  // ES for Browsers
  {
    input: 'src/index.js',
    output: {
      file: 'es/styled-breakpoints.es.mjs',
      format: 'es',
      indent: false,
      sourcemap: false,
    },
    plugins: [
      configuredFlow,
      resolve({
        jsnext: true,
      }),
      replace({
        'process.env.NODE_ENV': JSON.stringify('production'),
      }),
      terser(),
      commonjs(),
      flowEntry(),
    ],
  },
];
swansontec commented 5 years ago

Thanks for the high-quality bug report. Yup, looks like Rollup has changed their internal API, so I'll need to update this plugin to match.

swansontec commented 5 years ago

I have just published v0.2.1, which should fix the problem.

mg901 commented 5 years ago

Thank you! I would advise you to enable Greenkeeper so that you are always aware of new changes in rollup.

swansontec commented 5 years ago

Great! I'll go ahead and close the issue, then. I'll also checkout Greenkeeper when I have some time.