Separate .js and .d files for commonjs

I am trying to create one .js and .d file for my entire library. this is my .json package:

{ "compilerOptions": { "module": "commonjs", "target": "es6", "noImplicitAny": false, "outDir": "build", "sourceMap": true, "removeComments": true, "watch": false, "declaration": true, "outFile": "file.js" }, "exclude": [ "node_modules", "build" ] } 

but when I run tsc , I get this error: error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.

So how can I do this?

+5
source share
1 answer

This is a conceptual thing. Commonjs modules are allowed in such a way that combining them into a single file does not make sense. See this topic in TypeScript for more details:

https://github.com/Microsoft/TypeScript/issues/7252

If you create your library as commonjs, you can of course provide some kind of index file that imports all your other files and exports parts under separate keys so that you can import the entire library or only parts of it.

+2
source

Source: https://habr.com/ru/post/1245111/


All Articles