@mohmmed_aariz/common
v1.0.2
Published
every module and every folder in a monorepo needs to have a package.json and tsconfig.json so bootstrap it accordingly
Downloads
1
Readme
every module and every folder in a monorepo needs to have a package.json and tsconfig.json so bootstrap it accordingly
now common folder contains modules that are used by both client and the server
here in our common folder we will write our zod types
// if you want to create a module and publish it to npm so other people can locally bring using npm install is by npmjs.org website. this is a registry where other people just put their code and allow others to use it
// rule of thumb:: when publishing into npm we don't publish typescript file. publishing ts file to npm means publishing your code to npm
changes in package.json : "name": "@mohmmed_aariz/common", "main": "dist/index.js",
to publish code
npm login
npm publish --access=public
npm pack // to show what files you published ie. mohmmed_aariz-common-1.0.0.tgz we see a compressed file which shows what goes to npm here, we see that we have also published .ts file so we can stop uploading it by using .npmignore file same as .gitignore
now we can run npm install @mohmmed_aariz/common in our repositiory then it will still work
// now to integrate it to our application we do npm install in both client and server
- .d.ts is a declaration file it gives just the types of the code. not actual js code neither complete ts file which has both js and ts so to create it go to tsconfig.json and make declaration true here
now, dist has two files:: - .js and .d.ts here .d.ts just contain all the declaration and no js code which can be executed