ampproject / rollup-plugin-closure-compiler

Leverage Closure Compiler to minify and optimize JavaScript with Rollup.
Apache License 2.0
292 stars 30 forks source link

UnhandledPromiseRejectionWarning: SyntaxError: Duplicate export #333

Closed bluebill1049 closed 4 years ago

bluebill1049 commented 4 years ago

Hi,

Thanks for this awesome rollup plugin and your hard work.

I have would like to use this plugin for this lib that i am working on: https://github.com/react-hook-form/react-hook-form

I did encounter an issue with the plugin and the error log is below:

Screen Shot 2020-02-28 at 7 42 00 pm

(useForm as duplicated export is not the root cause as the file only have a single export)

and here is my rollup config:

import typescript from 'rollup-plugin-typescript2';
import compiler from '@ampproject/rollup-plugin-closure-compiler';
import pkg from './package.json';

export function getConfig({
  tsconfig = './tsconfig.json',
  output = [
    {
      file: `dist/${pkg.name}.js`,
      format: 'cjs',
      exports: 'named',
    },
    {
      file: `dist/${pkg.name}.es.js`,
      format: 'esm',
    },
  ],
} = {}) {
  return {
    input: 'src/index.ts',
    external: ['react', 'react-dom'],
    plugins: [
      typescript({
        tsconfig,
        clean: true,
      }),
      compiler(),
    ],
    output,
  };
}

export default getConfig();

Here is the commit which i made for the config: https://github.com/react-hook-form/react-hook-form/commit/df7fb536234aa1dd13f6c77f7450bfc60b70b2ee

util i had the error above and reverted the commit.

Thanks for taking a look at this.

kristoferbaxter commented 4 years ago

Resolved with 0.23.0.

bluebill1049 commented 4 years ago

wow thanks a lot @kristoferbaxter much appreciated your hard work.

kristoferbaxter commented 4 years ago

Happy to help!

bluebill1049 commented 4 years ago
Screen Shot 2020-03-02 at 7 06 04 pm

sorry to report this, but looks like the latest is broken the bundle. rollup config is stay unchanged.

here is the PR: https://github.com/react-hook-form/react-hook-form/pull/1129