rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
502 stars 126 forks source link

NamedModules: cloneElement is not exported by react #345

Closed jamespantalones closed 4 years ago

jamespantalones commented 6 years ago

Not sure what to do here... Keep getting error thrown cloneElement is not exported by node_modules/react/index.js

I know it needs to be specified in namedModules in comonjs plugin, and that works for every other react export, but it is not recognizing cloneElement. Any ideas?

Thanks

rollup config

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import uglify from 'rollup-plugin-uglify-es';
import flow from 'rollup-plugin-flow';
import external from 'rollup-plugin-peer-deps-external';

export default {
  inputOptions: {
    input: './src/client/index.js',
    plugins: [
      flow(),
      external(),
      babel({ exclude: 'node_modules/**' }),
      resolve(),
      commonjs({
        include: [
          'node_modules/**',
        ],
        exclude: [
          'node_modules/process-es6/**',
        ],
        namedExports: {
          'node_modules/react/index.js': [
            'Children',
            'Component',
            'PureComponent',
            'PropTypes',
            'createElement',
            'Fragment',
            'cloneElement',
            'StrictMode',
            'createFactory',
            'createRef',
            'createContext',
            'isValidElement',
            'isValidElementType',
          ],
          'node_modules/react-dom/index.js': [
            'render',
            'hydrate',
          ],
        },
      }),
      replace({
        ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
      }),
      (process.env.NODE_ENV === 'production' && uglify()),
    ],
  },
  outputOptions: {
    name: 'BBGCustom',
    file: './tmp/main.pkgd.js',
    format: 'umd',
  },
};
sholladay commented 5 years ago

I cannot reproduce this. In my app, cloneElement is imported via semantic-ui-react. If I remove cloneElement from namedExports, then Rollup throws an error. If I add it back, then the build succeeds.

I think a minimal reproducible example is going to be needed here.

shellscape commented 4 years ago

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. :beer: