Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
update-ts-references
Advanced tools
Updates TypeScript references automatically while using workspaces
If your repository is a multi package repository (via lerna.js, yarn workspaces, pnpm workspaces or since v7 npm workspaces) in combination with project references from TypeScript, this tool will be very helpful by reading dependencies out of the package.json and applying them to the tsconfig.json as references.
There's a blog post that's a good introduction to it Optimizing multi-package apps with TypeScript Project References.
You can just use it via npx
npx update-ts-references --help
Usage: update-ts-references [options]
Options:
--configName The name of the config files which needs to be updated. Default: tsconfig.json
--rootConfigName The name of the root config file which needs to be updated. Default: tsconfig.json
--check Checks if updates would be necessary (without applying them)
--help Show help
--createTsConfig Create default TS configs for packages where the main entry in the package.json have a ts|tsx extension (Note: respects the --configName parameter)
--createPathMappings Create paths mappings under compilerOptions for a better IDE support. It respects the rootDir if no rootDir available it falls back to "src"
--cwd Set working directory. Default: /Users/john-doe/projects/my-project
--verbose Show verbose output. Default: false
--usecase Use a specific usecase configuration. Default: update-ts-references.yaml
or you add it as dev dependency and include it in the postinstall
script in the package.json
yarn add update-ts-references --dev -W
"scripts": {
"postinstall": "update-ts-references"
},
"husky": {
"hooks": {
"pre-push": "update-ts-references --check"
}
},
enable pre-push via husky
npx husky add .husky/pre-push "npx update-ts-references --check"
git add .husky/pre-push
Creates a basic tsconfig file for each package where the main entry in the package.json have a .ts
or .tsx
extension. It will respect the --configName
parameter.
The output for the created file looks like the following
{
"extends": "../tsconfig.base.json", // add's extends in case you have a base config in the root directory
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"references": [ // will be added after running update-ts-references
{
"path": "../some-other-package"
}
]
}
will create path mappings under compilerOptions
for a better IDE support. It assumes the source files are under src
.
{
"extends": "../tsconfig.base.json", // add's extends in case you have a base config in the root directory
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"paths": { // will be added after running update-ts-references with --createPathMappings
"@my-project/some-other-package": ["../some-other-package/src"]
}
},
"references": [ // will be added after running update-ts-references
{
"path": "../some-other-package"
}
]
}
You can configure workspace paths via the update-ts-references.yaml file. This is useful if your repo is having no package.json or pnp-workspace.yaml in the root folder. Additional to that it can also being used to extend the paths config next to the normal workspace setup via npm, pnpm, yarn and lerna so you can include or exclude some packages.
Additional to that you can configure also the following options:
Example configuration see here
Executing update-ts-references with different configurations via the parameter --usecase
.
update-ts-references is currently not supporting Referencing workspace packages through aliases yet. See issue #13
Copyright 2023 mobile.de Developer: Mirko Kruschke
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
FAQs
Updates TypeScript references automatically while using workspaces
The npm package update-ts-references receives a total of 0 weekly downloads. As such, update-ts-references popularity was classified as not popular.
We found that update-ts-references demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.