Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 捆绑连接到应用程序商店的NPM包_Reactjs_Npm_Webpack_Redux_Package - Fatal编程技术网

Reactjs 捆绑连接到应用程序商店的NPM包

Reactjs 捆绑连接到应用程序商店的NPM包,reactjs,npm,webpack,redux,package,Reactjs,Npm,Webpack,Redux,Package,在过去的一天半时间里,我一直在与webpack进行斗争,失去了一切,我放弃了,请帮助我 所以我想做的是创建一个NPM包,它将在我们的许多网站上使用。我们有多个具有共享功能的站点,我们正在使用redux,我已经制作了一个npm包,它提供了可以跨多个项目导入的操作、简化程序和中间件。很好,不用担心。我现在尝试创建第二个包,其中包含使用redux存储中主应用程序状态的组件 第二个包使用选择器并分派第一个包提供的操作 我在主应用程序中编写了组件,效果很好 我为第二个包创建了一个新项目,复制并粘贴了组件

在过去的一天半时间里,我一直在与webpack进行斗争,失去了一切,我放弃了,请帮助我

所以我想做的是创建一个NPM包,它将在我们的许多网站上使用。我们有多个具有共享功能的站点,我们正在使用redux,我已经制作了一个npm包,它提供了可以跨多个项目导入的操作、简化程序和中间件。很好,不用担心。我现在尝试创建第二个包,其中包含使用redux存储中主应用程序状态的组件

第二个包使用选择器并分派第一个包提供的操作

  • 我在主应用程序中编写了组件,效果很好
  • 我为第二个包创建了一个新项目,复制并粘贴了组件,它的scss模块文件,添加了第一个包和其他依赖项作为对等依赖项
  • 使用webpack构建(在找不到对等依赖的一些问题后,我不得不使用install peers安装它们,也许这与我的问题有关)
  • 然后我在主应用程序中安装了npm包。。。我得到的是“商店未定义”
我认为我的webpack配置有问题,不知何故,该组件似乎无法访问我的应用程序存储,就好像它存在于自己的小世界中一样。这是我的猜测,我可能在几英里之外

我们正在使用react、next、redux和scss模块

这是我的网页包配置(当我使用peer deps externals网页包插件时,外部被注释掉):

这是我的package.json:

{
  "name": "mm-chat-components",
  "version": "1.0.0",
  "description": "",
  "main": "./build/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build-webpack": "webpack --mode production"
  },
  "author": "",
  "license": "ISC",
  "peerDependencies": {
    "mm-redux-base": "git+https://github.com/MMTSURVEY/mm-redux-base.git",
    "mm-theme": "git+https://github.com/MMTSURVEY/mmj-theme.git",
    "final-form": "^4.18.7",
    "react-final-form": "^6.3.5",
    "react": "^16.13.1",
    "twilio-chat": "^3.3.7",
    "react-redux": "^7.2.0",
    "react-dom": "^16.12.0",
    "mm-chat-redux": "git+https://github.com/MMTSURVEY/mm-chat-redux.git"
  },
  "devDependencies": {
    "@babel/cli": "^7.0.0",
    "@babel/core": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.9.4",
    "babel-loader": "^8.1.0",
    "babel-plugin-react-css-modules": "^5.2.6",
    "babel-plugin-react-css-modules-sass": "^1.1.0",
    "css-loader": "^3.5.3",
    "install-peers": "^1.0.3",
    "mini-css-extract-plugin": "^0.9.0",
    "node-sass": "^4.14.1",
    "peer-deps-externals-webpack-plugin": "^1.0.4",
    "sass-loader": "^8.0.2",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11",
    "webpack-dev-server": "^3.11.0"
  }
}
还有我的巴别塔:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"]
}
我通常在使用网页时会迷失方向,这似乎仍然是我无法理解的魔法。 这是很多信息,我希望一切都清楚!提前感谢您的帮助!你们太棒了

{
  "presets": ["@babel/preset-env", "@babel/preset-react"]
}