Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
EBX is a command-line tool that simplifies the process of building and running TypeScript code. It is designed to work with ECMAScript Modules (ESM) and takes advantage of the lightning-fast build tool esbuild: https://esbuild.github.io/.
EBX stands for ES Module Build and Execute and works well with CommonJS (CJS).
You can install EBX globally using the following command:
npm install -g ebx
After installing EBX, you can use it from the command line as follows:
ebx [options] <filename>
Where <filename>
is the name of the TypeScript file you want to build and run.
EBX provides several options that you can use to customize the build and run process:
-w, --watch
: Watch for changes in the source files and automatically rebuild when changes are detected.-r, --run
: Run the compiled program after a successful build.-nc, --no-clean
: Do not clean the build output directory before building.-s, --sourcemap
: Generate sourcemaps for the compiled JavaScript code.--tsconfig <tsconfig>
: Path to a custom TypeScript configuration file (tsconfig.json).-m, --minify
: Minify the output JavaScript code.--ignore-types
: Ignore type errors.--node-options
: Add node options to runner.Basic Build and Run:
To build and run a TypeScript file named app.ts
, use the following command:
ebx -r app.ts
To build ES Modules (ESM)
just add "type": "module"
in your package.json
file
Watching Changes:
To watch for changes in the app.ts
file and automatically rebuild and run it when changes occur:
ebx -w -r app.ts
Custom Configuration:
To use a custom TypeScript configuration file named tsconfig.custom.json
and generate sourcemaps:
ebx -s --tsconfig tsconfig.custom.json -r app.ts
Minification:
To enable minification building and running app.ts
:
ebx -m app.ts
EBX supports ES Modules by default. To use ES Modules in your project, simply add the "type": "module"
field to your package.json file.
When working with ECMAScript Modules (ESM), you might encounter compatibility issues, such as require
, __filename
and __dirname
not being defined.
To address these you can use a polyfill.
To add the necessary polyfills for ESM compatibility, follow these steps:
Open your package.json
file.
Inside the JSON structure, add a key named "polyfills"
and specify an array of polyfill names. In this case, we're using "cjs"
to include CommonJS-related polyfills.
"polyfills": ["cjs"]
By adding this configuration, you ensure that the specified polyfills are loaded when your ESM code runs, addressing compatibility issues related to __filename
, require
and __dirname
.
cjs
- to add cjsdecorators
- enable ts decoratorsnestjs
- enable nestjs support (decorators and more)By default, EBX outputs the compiled JavaScript code to the dist
directory. You can change the output directory by defining the "main"
field in your package.json file.
ex: "main": "lib/app.js"
it will now compile and run app.js
in lib
directory
every modules will be considered as external and it won't bundle, if you want to include
add following in package.json
"external": {
"include": ["lodash"]
}
now lodash will be include in the compiled bundle.
To integrate EBX with your NestJS project, follow these steps:
Install EBX as a development dependency using the following command:
yarn add -D ebx
Add the following scripts to your package.json
file:
{
"scripts": {
"start:dev": "ebx src/main.ts --watch --run --sourcemap",
"build": "ebx src/main.ts"
}
}
note: decorators are partially supported, if you want full support for decorators, enable
decorators
polyfill.
Update tsconfig.json
file:
{
"compilerOptions": {
"moduleResolution": "Bundler",
"module": "ESNext"
}
}
start:dev
script uses EBX to watch the src/main.ts
file, run the development server, and generate source maps for debugging purposes.build
script uses EBX to build your project.If you want to use ES modules (ESM), ensure that you have "type": "module"
in your package.json
file.
For a practical example of integrating EBX with NestJS, you can refer to the following GitHub repository:
EBX Example ExpressJS with PNP
Harness the power of EBX to bundle and optimize your Node.js backend applications built with NestJS, ExpressJS or any other.
EBX is a powerful tool that can help you simplify the process of bundling and optimizing JavaScript code for Node.js applications. It is a versatile tool that can be used for both development and production environments.
FAQs
Command Line Tool for Building and Running TypeScript Code
The npm package ebx receives a total of 83 weekly downloads. As such, ebx popularity was classified as not popular.
We found that ebx 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.