NPM Pack doesn't update all files in the second project

23 Views Asked by At

I am creating a npm package using TypeScript and React. To test it I use second testing project by using commands: npm run build npm pack. In the second project I do npm unistall PACKAGE npm i PACKAGE_FILE.tgz

The Package has 3 files, two of them are frequently changing: index.tsx, FormGroup.tsx. When I update the code, index.tsx file shows updates perfectly, while FormGroup.tsx does not. It still has the same code when I first installed it in the Testing Project.

I tried to google it, but no luck

I viewed following places, and see that the new version is there:

  1. FormGroup.js in an unpacked PACKAGE_FILE.tgz

  2. FormGroup.js file in node_modules/PACKAGE/dist

code in node_modules

But Chrome doesn't show any updated code in the source tab:

code in Chrome Source tab

Thank you in advance

Some source code:

tsconfig.json

{
  "include": ["src", "__tests__/index.test.js", "babel.config.js", "__tests__/FormGroup.test.js"], /* Include only the src directory */
  "compilerOptions": {
    "jsx": "react",
    "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
    "module": "commonjs" /* Specify what module code is generated. */,
    "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
    "outDir": "dist",
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
    "strict": true /* Enable all strict type-checking options. */,
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  }
}

package.json

{
  "main": "dist/index.js",
  "files": [
    "dist"
  ],
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "default": "./dist/index.js"
    }
  },
  "scripts": {
    "test": "jest --env=jsdom --coverage --silent",
    "clean": "rimraf dist",
    "prebuild": "npm run clean",
    "build": "tsc",
    "preversion": "npm run build",
    "version": "npm publish"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.23.9",
    "@babel/preset-react": "^7.23.3",
    "@babel/preset-typescript": "^7.23.3",
    "@testing-library/jest-dom": "^6.4.2",
    "@testing-library/react": "^14.2.1",
    "@types/react": "^18.2.55",
    "jest": "^29.7.0",
    "jest-environment-jsdom": "^29.7.0",
    "rimraf": "^5.0.5",
    "typescript": "^5.1.6"
  }
}
0

There are 0 best solutions below