npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nasriya/postbuild

v1.1.5

Published

A package that does some tasks after compilation

Downloads

13

Readme

N|Solid

PostBuild.

Static Badge Repository Size Last Commit Status

Visit us at www.nasriya.net.

PostBuild is a utility pacakge for TypeScript that runs useful tasks after transpiling TypeScript into ESM and CJS JavaScript file.

Made with ❤️ in Palestine 🇵🇸

[!IMPORTANT] 🌟 Support Our Open-Source Development! 🌟 We need your support to keep our projects going! If you find our > work valuable, please consider contributing. Your support helps us > continue to develop and maintain these tools.

Click here to support us!

Every contribution, big or small, makes a difference. Thank you for > your generosity and support!


Installation

Install the pacakge as a dev. dependency:

npm i --save-dev @nasriya/postbuild

Config File

The postbuild.configs.json is the file where all your configurations reside, and is needed to perform the tasks or the build process will fail.

If you don't have a file, just run the following command and a file will be generated with recommended configurations:

npm run postbuild-init
Config File Content

The above comand will generate a file with all the features set to their recommended values. This table below explains them in details.

| Property | Description | Posible values | Default value | | ------------------- | ------------------------------------------------------------------------ | ------------------------ | ------------- | | esmDir | The directory of the generated ESM folder. | auto or the directory | auto | | cjsDir | The directory of the generated CJS folder. | auto or the directory | auto | | verbose | An option to enable logging extra details . | true or false | true | | addExtensions | Appending .js to all import statements. | true or false | true | | copyFiles | An options object to copy assets to the dist folder after transpiling. | object or undefined | Notice below | | copyFiles.from | The directory where you want to copy the assets to. | directory | src | | copyFiles.exclude | An array of file extensions to exclude. | string[] | ['.ts'] | | aliases | Define aliases to your imports | Record<string, string> | Nothing |

The default configurations works well if your project is structured like this:

├── dist/
│   ├── @types
│   ├── cjs
│   └── esm
├── src
│   ├── folder1
│   ├── folder2
│   ├── folder3
│   └── index.ts
├── package.json
└── README.md

Usage

The best way to use this package is to integrate it with your build process by appending the postbuild worker to the end of the build command:

// package.json
{
    "scripts": {
        "build": "npm run build:esm && npm run build:cjs && postbuild",
        "build:esm": "tsc --project tsconfig.esm.json",
        "build:cjs": "tsc --project tsconfig.cjs.json",        
    }
}

Defining aliases

In postbuild.config.json, you can add your aliases as such:

{
    "aliases": {
        "my-module": "/modules/my-module",
        "@elements/*": "/elements/"
    }
}

Using __dirname

All __dirname matches in ESM will be replaced with import.meta.dirname, for example:

// TypeScript
const dirname: string = __dirname;

Will be compiled to:

// CommonJS (CJS)
const dirname = __dirname;
// ECMAScript Modules (ESM)
const dirname = import.meta.dirname;

License

Please read the license from here.