How to make node module by typescript module

204 views Asked by At

How to build typescript module to javascript module

this is my tsconfigFile

{
  "compilerOptions": {
    "target": "ES5",
    "module": "CommonJS",
    "declaration": true,
    "outDir": "./dist",
    "strict": true,
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

I want to Buiding This Code --------------

Typescript Module

import getData from './getData';


export default {
 getData 
};

node Module

const getData = require("./getData")';

module.exports = {
  getData
};

1

There are 1 answers

0
habbes On

Since your config seems to have the needed settings to generate node modules, I think you just need to run the tsc command, and it will generate the JS code and store it in the ./dist directory.