All is in the title, trying to compile my TypeScript project to ./bin folder, the tsc commend execute without error resulting in nothing created, can't figure out why.
my tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"checkJs": false,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["es6", "es7", "dom", "esnext"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"outDir": "bin",
"removeComments": true,
"sourceMap": true,
"target": "es2017",
"rootDirs": ["src/", "config/"],
"typeRoots": ["./node_modules/@types", "./typings"]
},
"include": ["src/**/*", "./typings"],
"exclude": ["node_modules", "bin", "**/__mocks__*", "**/*.spec.**", "test", "assets"]
}
In my package.json this is my scripts to compile:
"scripts": {
"build-ts": "tsc",
"watch-ts": "tsc -w",
},
the structure of my project:
rootdir
|
|-----src
| |----server.ts
| |----app.ts
|-----test
|-----node_modules
|-----typings
|-----config
|-----tsconfig.json
|-----package.json
Any idea what I'm doing wrong?
The dist folder, short for distribution folder, is dynamically generated when using the nuxt generate commands and includes the generated production ready HTML files and assets that are necessary to deploy and run your statically generated Nuxt application.
The dist folder is for production website it's not necessary to have it. It will contain for example your image, css, script, vendor folder ready for production (minified and concatenated). You can check on google for this.
dist — the folder that has the output from the compiler. node_modules — the folder containing the packages that the app and dev tools require. src — the folder containing the source code files that will be compiled by the TypeScript compiler. package.
The noEmit
option causes TypeScript to not emit any files. You need to either remove "noEmit": true or pass --noEmit false in your build-ts script.
Bonus tip: Rename the script to prepack
to have npm
compile the TypeScript for you when you run npm pack
or npm publish
.
Another situation where TypeScript might not create a dist
folder is when "incremental": true
or "composite": true
is set in compilerOptions
in tsconfig.json
, and you delete the dist
folder without deleting the tsconfig.tsbuildinfo
that keeps track of the incremental builds.
If you keep tsconfig.tsbuildinfo
around and delete or modify dist
, the compiler won't see a need to output anything, since tsconfig.tsbuildinfo
is telling it that there's no work to do. The problem is the tsconfig.tsbuildinfo
references an old state of dist
.
Say your npm run clean
command runs rimraf dist
. You'll have to update it to also rimraf tsconfig.tsbuildinfo
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With