Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Transpile your TypeScript projects quickly using esbuild + rollup, made to accelerate and simplify the TypeScript development with file watcher and first-class support for JavaScript testing frameworks.
This library doesn't handle type definitions, but you can add them simply by doing
tsc --declaration --emitDeclarationOnly
pnpm add -D bob-ts esbuild
yarn add -D bob-ts esbuild
npm install -D bob-ts esbuild
By default bob-ts
is ESM first, but you can change it to be either CJS with: -f cjs
or -f interop
to transpile for both CommonJS & ESM.
If you don't have "type": "module"
in your package.json
, ESM
will be outputted with the extension .mjs
and CJS
as .js
If you do have "type": "module"
in your package.json
, ESM
will be outputted with the extension .js
and CJS
as .cjs
.
Usage: bob-ts [options]
Options:
-d, --dir <directory> Custom output dir (default: "dist")
-i, --input <patterns...> Input patterns (default: ".")
-f, --format <format> Format, it can be 'cjs', 'esm' or 'interop' (default: "esm")
--cwd <dir> Custom target directory (default: "X")
--no-clean Don't clean output dir (default: true)
-t, --target <target> Javascript runtime target (default: "_YOUR_CURRENT_NODE_VERSION_")
--no-sourcemap Disable sourcemap generation
--paths Resolve tsconfig paths (default: false)
-h, --help display help for command
This will transpile all your
src
folder, and its structure will be kept as is in thedist
folder
{
"scripts": {
"prepare": "bob-ts -i src"
}
}
Usage: bob-ts-watch [options]
Options:
-d, --dir <directory> Custom output dir (default: "dist")
-i, --input <patterns...> Input patterns (default: ".")
-f, --format <format> Output format (choices: "cjs", "esm", "interop", default: "esm")
--clean Clean output dir (default: false)
--cwd <dir> Custom target directory (default: "___")
-c, --command <commands...> Execute scripts after successful JS build, You can specify more than a single command
to be executed concurrently
-t, --target <target> Javascript runtime target (default: "_YOUR_CURRENT_NODE_VERSION_")
--ignore <files...> Patterns of files to ignore watching
--no-sourcemap Disable sourcemap generation
--paths Resolve tsconfig paths (default: false)
-h, --help display help for command
{
"scripts": {
"dev": "bob-ts-watch -i src -c \"node dist/index.mjs\""
}
}
The main reason for the default input being "."
is because this library has first-class support for being used for JavaScript test frameworks like Mocha and Node-Tap.
You can have all the tests files inside a specific test directory, for example, test
, and use the transpiled version of your code with all the required source maps.
In the end, a better and faster alternative than ts-node/register
, and the solution for ESM support with TypeScript, where ts-node
struggles a lot.
Example structure
src/
index.ts
test/
main.test.ts
package.json
pnpm add -D mocha c8
yarn add -D mocha c8
npm install -D mocha c8
{
"scripts": {
"dev": "bob-ts-watch -c \"node/dist/src/index.mjs\"",
"start": "bob-ts && node/dist/src/index.mjs",
"test": "bob-ts && c8 mocha dist/test",
"test:watch": "bob-ts-watch -c \"c8 mocha dist/test\""
},
"mocha": {
"enable-source-maps": true
}
}
{
"scripts": {
"dev": "bob-ts-watch -f cjs -c \"node dist/src/index.js\"",
"start": "bob-ts -f cjs && node dist/src/index.js",
"test": "bob-ts -f cjs && c8 mocha dist/test",
"test:watch": "bob-ts-watch -f cjs -c \"c8 mocha dist/test\""
},
"mocha": {
"enable-source-maps": true
}
}
pnpm add -D tap @istanbuljs/esm-loader-hook
yarn add -D tap @istanbuljs/esm-loader-hook
npm install -D tap @istanbuljs/esm-loader-hook
Assuming that your tests are inside a
test
directory
{
"scripts": {
"dev": "bob-ts-watch -c \"node/dist/src/index.mjs\"",
"start": "bob-ts && node/dist/src/index.mjs",
"test": "bob-ts && tap dist/test",
"test:watch": "bob-ts-watch -c \"tap dist/test\""
},
"tap": {
"node-arg": ["--no-warnings", "--experimental-loader", "@istanbuljs/esm-loader-hook"]
}
}
{
"scripts": {
"dev": "bob-ts-watch -f cjs -c \"node/dist/src/index.js\"",
"start": "bob-ts -f cjs && node/dist/src/index.js",
"test": "bob-ts -f cjs && tap dist/test",
"test:watch": "bob-ts-watch -f cjs -c \"tap dist/test\""
}
}
MIT
FAQs
[![npm](https://img.shields.io/npm/v/bob-ts)](https://npm.im/bob-ts)
The npm package bob-ts receives a total of 237 weekly downloads. As such, bob-ts popularity was classified as not popular.
We found that bob-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.