React 脚本问题:循环加载 chunk.js

Posted

技术标签:

【中文标题】React 脚本问题:循环加载 chunk.js【英文标题】:React scripts issue: loop loading chunk.js 【发布时间】:2019-11-18 01:05:50 【问题描述】:

我正在使用 React 脚本 v3。每当我在页面中执行操作(鼠标事件、表单...)时,我都会遇到此问题,应用程序会不断下载 chunk.js

这是我的 package.json


  "version": "0.1.0",
  "private": true,
  "dependencies": 
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^4.3.1",
    "cors": "^2.8.5",
    "lodash.flatten": "^4.4.0",
    "lodash.get": "^4.4.2",
    "lodash.intersection": "^4.4.0",
    "mockdate": "^2.0.2",
    "moment": "^2.24.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-app-polyfill": "^1.0.1",
    "react-dom": "^16.8.6",
    "react-router": "4.3.1",
    "react-router-dom": "4.3.1",
    "react-scripts": "^3.0.1",
    "recompose": "^0.30.0",
    "url-search-params-polyfill": "^6.0.0",
    "uuid": "^3.3.2"
  ,
  "scripts": 
    "mocks": "cd mocks && npm start",
    "start-dotnet": "react-scripts start",
    "start": "concurrently \"npm run mocks\" \"react-scripts start\"",
    "build": "react-scripts build",
    "test": "set NODE_ICU_DATA=node_modules/full-icu&& react-scripts test --env=jsdom",
    "test:staged": "npm run test -- --coverage --findRelatedTests --watchAll=false",
    "test-coverage": "npm run test -- --coverage --watchAll=false"
  ,
  "husky": 
    "hooks": 
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    
  ,
  "lint-staged": 
    "*src/**/*.js": [
      "prettier --write",
      "npm run test:coverage",
      "git add"
    ]
  ,
  "commitlint": 
    "extends": [
      "@commitlint/config-conventional"
    ]
  ,
  "eslintConfig": 
    "extends": "react-app"
  ,
  "jest": 
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ]
  ,
  "browserslist": [
    ">0.2%",
    "ie 11",
    "not dead",
    "not op_mini all"
  ],
  "devDependencies": 
    "@commitlint/cli": "^8.0.0",
    "@commitlint/config-conventional": "^8.0.0",
    "concurrently": "^4.1.0",
    "enzyme": "^3.9.0",
    "enzyme-adapter-react-16": "^1.12.1",
    "enzyme-to-json": "^3.3.5",
    "eslint-plugin-react-hooks": "^1.6.0",
    "full-icu": "^1.3.0",
    "husky": "^2.4.1",
    "jest": "^24.7.1",
    "jest-cucumber": "^2.0.11",
    "lint-staged": "^8.2.1",
    "node-sass": "^4.11.0",
    "prettier": "^1.18.2"
  

有人知道这个问题吗?

【问题讨论】:

从未遇到过这个令人惊讶的问题。你能提供一个minimal reproducible example吗? 您找到解决方案了吗?我在 react-scripts 3.3.0 上,有时我也会得到这个。有点随机发生。 我今天也得到了这个 - 还不知道为什么 【参考方案1】:

我遇到了同样的问题,它一直在请求块。 发生这种情况是因为我的 JS 块中有一个引用问题,我是延迟加载。 所以我懒加载页面数据,为此在 JS 中,我正在导入一个不存在的文件。这导致了这个问题。

为我修复它。

【讨论】:

【参考方案2】:

我今天遇到了这个问题。我错误地将 onChange 操作设置为字符串而不是函数,因此将其更改为对我有用的函数。

【讨论】:

以上是关于React 脚本问题:循环加载 chunk.js的主要内容,如果未能解决你的问题,请参考以下文章

定位解析一个因脚本劫持导致webpack动态加载异常的问题

react项目打包

static/js/main.89d5e2e7.chunk.js net::ERR_ABORTED 404 (Not Found) 除非我在重新构建之前删除 docker 映像

Shell脚本之while循环

制作循环链表并找到循环的开头

如何从 React JS 中父组件上的对象循环子组件中的项目