What is the best practice for keeping tsconfig.json in a subdirectory of the project root? - tsc

I have a project with /src directory at the project root and I want to keep all my configuration files (tsconfig.json included) in a /config directory. The problem is when I call tsc from the root directory passing the --project flag tsc only looks under the /config directory for .ts files. I've tried --rootDir flag in addition to --project but --rootDir seems to be overridden. I've tried including rootDir in the tsconfig.json file but that doesn't work either. Is there an attribute in tsconfig.json that will let me specify where to look for sources other than listing each file to include in the files section?

Related

npm pack doesn't include all files in the package

I run npm pack inside dist folder, but it doesn't include all it's files.
it just contains: package.json, ReADME.md, index.js (main).
there is no .gitignore file, and I tried to create an empty .npmignore file, but it didn't help.
I also tried to add files array to package.json.
all files in the root or subfolders (js or other files) don't included in the pack file.
I found another files property in my package.json, so adding another one has no effect, also .gitignore and .npmignore have no effect.

npm publish is renaming .gitignore to .npmignore

I've created a Yeoman generator to create a basic Git repository folder structure. One of the assets is a .gitignore file. This is in the \generators\app\templates\ folder.
When I publish this generator to my NPM registry, the .gitignore file is renamed to .npmignore and then the generator fails as it's trying to copy a file that no longer exists.
How can I stop this happening?
What we ended up doing is renaming the .gitignore files to dot-gitignore and renaming them after the generation :
in index.js :
// called at the end by yeoman
end() {
extfs.copyFileSync('_gitignore','.gitignore);
extfs.unlinkSync('_gitignore');
}

vue project include htaccess file in dist

The project was initialised with vue init webpack. It doesn't have a public directory. I tried adding the .htaccess file at the same level as the index.html but it does not get included in the dist folder when I run npm run build

Yarn removes folder within installed dependency

I am using Yarn v0.19.1 to install some dependencies. I deleted my node_modules folder completely and did a fresh yarn install.
I am trying to install the dependency leaflet using yarn add leaflet. The module installs successfully, except during the Cleaning Modules... phase, Yarn removes the images folder which would typically live within leaflet/dist/images. When I do a npm install leaflet this folder does not get removed.
During a yarn install, the images folder is present until the Cleaning modules phase happens.
Who/what is doing this? Is this something yarn does? Or is this something specified within the leaflet library? How could I resolve this?
I checked the package.json in the leaflet library and nothing seemed out of the ordinary there. It runs a jake file, but even within that file nothing is being deleted related to images.
Here is what the folder looks like, within my node_modules folder, for both package manager installs:
yarn
npm
There was a .yarnclean file in my project. This added some files/folders to ignore when installing dependencies. Running yarn clean added this file and I wasn't aware until I saw this issue. Viewing the docs also gave the same info.
I resolved this by removing images from the set of ignored directories.
Here is my .yarnclean file for an example:
# test directories
__tests__
test
tests
powered-test
# asset directories
docs
doc
website
assets
# examples
example
examples
# code coverage directories
coverage
.nyc_output
# build scripts
Makefile
Gulpfile.js
Gruntfile.js
# configs
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
# misc
*.gz
*.md

npm publish isn't including all my files

I npm publish'd a module. It went up fine, but then when I installed it from the registry, it turned out to be missing certain files.
When I run irish-pub in my module's project directory, sure enough, the output doesn't list those filenames.
I've checked:
I do not have an .npmignore file.
I do have a .gitignore but this only contains /node_modules/
the missing files are normal JS files, not things that could be ignored by default
What else could be blocking them?
The problem was I had a files array in package.json. If this is present, then only the specified files get published, and everything else is effectively npmignored.
https://docs.npmjs.com/files/package.json
i've had the "files" property in package.json as well (intentionaly) but used relative pathes to the list of files and directories starting with dot slash ("./"), but neither npm pack nor npm publish worked with that. removed these, all worked as expected!
so change:
"files": [ "./bin", "./lib" ]
to:
"files": [ "bin", "lib" ]
and run:
$ npm pack
check the gnu zipped tarfile and finaly:
$ npm publish <projectname>-<semver>.tgz
For anyone not fixed by the above answers, npm pack and publish respect any package.json files you have in the directory tree, not just at the root.
In my case, I had a module that templated out another module with ejs, but because npm was treating the child package.json as real it was reading the files from there and not bundling everything I needed.
Lookout for the files in any package.json, not just your root.
For me, having the .gitignore file with files listed in it, inside the package folder to be published was causing the issues.
In general,
"All files in the package directory are included if no local .gitignore or
.npmignore file exists. If both files exist and a file is ignored by .gitignore
but not by .npmignore then it will be included."
I just ran into the same problem and found the answer here.
You need include the path to the directory (or tarball) you're trying to publish. While the documentation on npmjs.org doesn't really indicate it, if you run npm help publish you'll get the man page, which shows that the correct usage is actually
npm publish <tarball> [--tag <tag>]
npm publish <folder> [--tag <tag>]
I also found that I had to actually type out the path: I couldn't just use npm publish . from the directory containing my package.json file.
Hope that helps.
Something not mentioned in other solutions is that there is an undocumented, racing precedence. For instance, I had "files": ["lib"] in my package.json. lib is my gitignore. with just that state, it works. however, there was also a lib/path/.gitignore, which trumped my files array, yielding no included lib folder.
lesson--take heed of nested .gitignore files