Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single .js and .d files for commonjs

Tags:

typescript

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

{
    "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?

like image 530
MuriloKunze Avatar asked Mar 15 '16 19:03

MuriloKunze


1 Answers

This is a conceptual thing. Commonjs modules are resolved in a way that concatenating them into one file doesn't make sense. See this thread in the TypeScript issues for details:

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

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

like image 145
Andreas Jägle Avatar answered Oct 20 '22 23:10

Andreas Jägle