使用yalc时如何显示代码更改

Kid*_*Kid 7 reactjs

我学习yalc并完全按照它所说的去做,但是当我更改我所做的库代码时yalc publish,我在我的应用程序中看不到代码更改。

该库不是stack

脚步:

  • yalc 在 notistack 中发布
  • 然后我在我的应用程序中运行yalc add notistackyalc link notistack

然后,当我更改 notistack 代码并运行yalc push时,什么也没有发生,但文档说我应该在我的应用程序中更改代码?

我什至重新启动应用程序服务器并执行此操作,yalc update notistack但通知堆栈代码更改不可见。

奇怪的是在我的应用程序 VSCode node_modules 中我看到notistack代码发生了变化。这就像将yalc push通知堆栈更改传播到应用程序,但应用程序没有使用它们。

更奇怪的是,当我重新启动 VSCode 并启动 App Server 进行调试时,仍然使用旧的 notistack 代码。

我尝试删除yalc remove notistack并重新启动笔记本电脑,然后再次执行此操作yalc add notistack。然后我再次看到旧代码。

我尝试在 Chrome 浏览器中对空现金进行硬重置,但没有成功。

当我去 yalc 商店查看时:C:\Users\user\AppData\Local\Yalc\packages\notistack\1.0.10\src:

我看到了最新的代码。

在 Chrome 检查器控制台中,我看到旧代码,但在检查器源下,存在正确的代码。这太令人困惑了。我也无法设置断点,不能在 Inspector 或 VSCode 中设置断点,不能在 notistack 中设置断点。就像 JavaScript 文件错位一样。

Edge 和 Chrome 中都会发生这种情况。

我现在要做的两天后才能继续工作,我必须删除 Yalc 存储文件夹,C:\Users\user\AppData\Local\Yalc\packages\noti............ ...删除应用程序项目中的yalc.lock删除package-lock.json和node_modules

然后重新开始发布并添加通知。这很耗时但有效。

如何使代码更改显示在 Yalc 中?

notistack 的 package.json

{
    "name": "notistack",
    "version": "1.0.10",
    "description": "Highly customizable notification snackbars (toasts) that can be stacked on top of each other",
    "main": "src/index.js",
    "module": "dist/notistack.esm.js",
    "types": "src/index.d.ts",
    "license": "MIT",
    "author": {
        "name": "Hossein Dehnokhalaji",
        "email": "hossein.dehnavi98@yahoo.com",
        "url": "https://github.com/iamhosseindhv/notistack"
    },
    "homepage": "https://www.iamhosseindhv.com/notistack",
    "repository": {
        "url": "git+https://github.com/iamhosseindhv/notistack.git",
        "type": "git"
    },
    "scripts": {
        "build": "tsdx build --transpileOnly --entry ./src/index.js",
        "prebuild": "npm run docs",
        "prepublishOnly": "npm run build",
        "docs": "rimraf typedoc.json && typedoc --tsconfig",
        "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
    },
    "peerDependencies": {
        "@material-ui/core": "^4.0.0",
        "react": "^16.8.0 || ^17.0.0",
        "react-dom": "^16.8.0 || ^17.0.0"
    },
    "dependencies": {
        "clsx": "^1.1.0",
        "hoist-non-react-statics": "^3.3.0"
    },
    "bugs": {
        "url": "https://github.com/iamhosseindhv/notistack/issues"
    },
    "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/notistack"
    },
    "contributors": [
        "Hossein Dehnokhalaji (https://www.iamhosseindhv.com/)"
    ],
    "keywords": [
        "notistack",
        "enqueueSnackbar",
        "snackbarprovider",
        "useSnackbar",
        "multiple",
        "react",
        "javascript",
        "material-ui",
        "toast",
        "redux",
        "snackbar",
        "stacked",
        "notification",
        "material design",
        "hossein",
        "dehnokhalaji",
        "iamhosseindhv"
    ],
    "yalcSig": "073ef039ed1e473029c88b6ad9af16d9"
}
Run Code Online (Sandbox Code Playgroud)

更新

添加应用程序package.json

{
  "name": "greta-thunberg-fff",
  "version": "1.2.9",
  "private": true,
  "homepage": "https://greta.portplays.com",
  "main": "index.js",
  "module": "dist/index.js",
  "files": [
    "dist",
    "README.md"
  ],
  "dependencies": {
    "@material-ui/core": "^4.11.2",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.57",
    "@material-ui/styles": "^4.11.2",
    "axios": "^0.19.2",
    "bootstrap": "^4.5.2",
    "change-case": "^4.1.2",
    "classnames": "^2.3.1",
    "clean-tag": "^3.1.1",
    "clsx": "^1.1.1",
    "comma-separated-values": "^3.6.4",
    "crypto-js": "^4.0.0",
    "date-fns": "^2.23.0",
    "faker": "^5.5.3",
    "firebase": "^7.23.0",
    "formik": "^2.2.5",
    "framer-motion": "^2.9.5",
    "gsap": "^3.5.1",
    "history": "^5.0.0",
    "i": "^0.3.6",
    "lodash": "^4.17.19",
    "lodash.debounce": "^4.0.8",
    "mammoth": "^1.4.11",
    "material-table": "^1.69.2",
    "moment": "^2.27.0",
    "my-notistack-fork": "file:.yalc/my-notistack-fork",
    "normalize-wheel": "^1.0.1",
    "npm": "^7.11.2",
    "pdfjs-dist": "^1.8.357",
    "preval.macro": "^5.0.0",
    "prop-types": "^15.7.2",
    "react": "^17.0.2",
    "react-activity": "^1.2.2",
    "react-bootstrap": "^1.3.0",
    "react-chartjs-2": "^2.11.1",
    "react-data-grid": "^6.1.0",
    "react-detect-offline": "^2.4.0",
    "react-dom": "^17.0.2",
    "react-dropzone": "^11.3.4",
    "react-helmet": "^6.1.0",
    "react-motion": "^0.5.2",
    "react-perfect-scrollbar": "^1.5.8",
    "react-redux": "^7.2.5",
    "react-resize-detector": "^5.0.7",
    "react-router": "^6.0.0-beta.4",
    "react-router-dom": "^6.0.0-beta.4",
    "react-scripts": "^3.4.0",
    "react-slick": "^0.27.3",
    "react-spring": "^8.0.27",
    "react-transition-group": "^4.4.1",
    "react-visibility-sensor": "^5.1.1",
    "rebass": "^4.0.7",
    "recompose": "^0.30.0",
    "redux": "^4.1.1",
    "redux-logger": "^3.0.6",
    "redux-saga": "^1.1.3",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "sass": "^1.41.1",
    "simplebar-react": "^2.3.5",
    "slick-carousel": "^1.8.1",
    "styled-components": "^5.1.1",
    "styled-system": "^5.1.5",
    "three": "^0.85.2",
    "typescript": "^3.9.7",
    "uuid": "^8.3.1",
    "xlsx": "^0.10.1",
    "yup": "^0.32.1"
  },
  "scripts": {
    "start": "set PORT=6545&& react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -b master -d build"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.1.1",
    "@typescript-eslint/parser": "^4.1.1",
    "axios": "^0.19.2",
    "babel-eslint": "^10.1.0",
    "clean-tag": "^3.1.1",
    "eslint": "^6.6.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-hooks": "^4.1.2",
    "gh-pages": "^2.0.1",
    "prettier": "^2.1.1",
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-scripts": "^3.4.3",
    "rebass": "^4.0.7",
    "styled-system": "^5.1.5"
  }
}
Run Code Online (Sandbox Code Playgroud)

die*_*edu 1

我使用复制了您的设置yalc add notistack并注意到它yalc push没有编译该包。--scripts当我按照文档中所述添加标志时,它起作用了:

scriptsoptions 默认为 false,因此它不会运行前/后脚本(可以通过传递--scripts标志来更改此设置)。

您也可以运行yalc publish,然后yalc push,或者yalc publish --push

为了使更改在应用程序中生效,我必须npm start再次运行。

这就是 notistack 依赖项在 package.json 中的样子

"notistack": "file:.yalc/notistack",

更新

my-notistack-fork正如您所指出的,我还尝试通过更改中的名称来将包重命名为package.json

{
    "name": "my-notistack-fork",
    "version": "2.0.2",
    "description": "Highly customizable notification snackbars (toasts) that can be stacked on top of each other",
Run Code Online (Sandbox Code Playgroud)

然后删除我的应用程序中的 notistack 依赖项,yalc remove notistack并使用新名称再次添加它yalc add my-notistack-fork。之后,我对库代码进行了更改并运行yalc publish --push,再次运行应用程序时我可以看到它们得到反映。依赖关系看起来像这样

  "my-notistack-fork": "file:.yalc/my-notistack-fork",
Run Code Online (Sandbox Code Playgroud)

有趣的是,对我来说,在应用程序node_modules中,lib目录已编译文件,并且屏幕截图中的错误有一个目录,src给人的印象是它未编译节点模块