代码之家  ›  专栏  ›  技术社区  ›  Dimitri Kopriwa

由于未找到redux和redux表单的默认值,无法导入RollupJS ES6模块

  •  1
  • Dimitri Kopriwa  · 技术社区  · 7 年前

    react-redux redux-form .

    二者都 redux-form 是对等依存关系。

    • 当我尝试将包导入项目时,我有:

    中的警告/node\u模块/登录表单/dist/登录表单。锿。js公司 7455:22-33在“react-redux”中未找到“导出”默认值(导入为“\u reactRedux”)

    我从来没有进口过自己 redux 在我的登录表单项目中。

    • 在我的项目中:

      import { Field, reduxForm } from 'redux-form/immutable';
      

    这是通过汇总捆绑的,并出现在我的es模块中:

    import _reactRedux from 'react-redux';
    import _redux from 'redux';
    

    我一定做错了什么,但我不知道是什么。

    "rollup": "^0.50.0",
    "rollup-plugin-babel": "^3.0.2",
    "rollup-plugin-cleanup": "^1.0.1",
    "rollup-plugin-commonjs": "^8.2.1",
    "rollup-plugin-inject": "^2.0.0",
    "rollup-plugin-json": "^2.3.0",
    "rollup-plugin-node-resolve": "^3.0.0",
    "rollup-plugin-replace": "^2.0.0",
    "rollup-plugin-uglify": "^2.0.1",
    "rollup-plugin-visualizer": "^0.3.1",
    "rollup-watch": "^4.3.1",
    
    3 回复  |  直到 7 年前
        1
  •  0
  •   Matthew Barbara    7 年前

    如果您使用的是5.0.0以上版本,则需要在配置中添加以下内容:

    commonjs({
      namedExports: {
        // left-hand side can be an absolute path, a path
        // relative to the current directory, or the name
        // of a module in node_modules
        'node_modules/my-lib/index.js': [ 'named' ]
      }
    })
    
        2
  •  0
  •   Dimitri Kopriwa    7 年前

    我设法在外部安装它,而不是使用“redux form”=“gt;”redux表单不可变'

        3
  •  0
  •   alanionita    3 年前

    似乎与提出此问题时使用的commonjs包的版本有关。

    就我而言,我使用了最新版本的 @rollup/plugin-commonjs namedExports是自动处理的。