Bys is an npm/yarn library to merge your js and ts files into one file.

Overview

Bundle your scripts (bys)

Bys is an npm/yarn library to merge your js and ts files into one file.

Installation

Use the npm or yarn package manager to install bys.

# Using npm
npm i @flamesx128/bys -g
# Using yarn
yarn add @flamesx128/bys -g

Usage

Bys needs to know what the main file is, by default it will look in the package.json file, but it can be specified by a bys.config.json file or by the "entry" flag.

Flags

With the flags you can change how the program will work.

  • entry

    • This flag specifies which is the main file.
    • Usage: $ bys --entry="main.js"
    • Required flag.
  • output-extention

    • This flag specifies the extension that the file created by bys will have.
    • If not specified, defaults to ".js".
    • Usage: $ bys --output-extention=".js"
    • Optional flag.
  • output-filename

    • This flag specifies what is the name of the file created by bys.
    • If not added, the default name is "bundle".
    • Usage: $ bys --output-filename="bundle.js"
    • Optional flag.
  • output-path

    • This flag specifies the directory where the file created by bys is saved.
    • If not added, the file is placed in the directory where it was called bys.
    • Usage: $ bys --output-path="main.js"
    • Optional flag.

Configuration file

You can create a configuration file for bys called bys.config.js with the following structure:

export interface Config {
  // Main file that read.
  entry?: string,
  output?: {
    // File extension to use when creating.
    extention?: string,
    // Name of the file that will be assigned when it is created.
    filename?: string,
    // Path of the directory where the file created by bys will be saved
    path?: string
  },
  // This method is to transpire the code at the end of joining the files.
  transpiler?(code: string): Promise<string> | string
  // This method is used to transpile the files at the moment they are read.
  transpilers?: {
    execute?(code: string): Promise<string> | string,
    extentions?: RegExp
  }[]
}

Configuration file example

// File: bys.config.js
const { join } = require('path');

module.exports = {
  entry: 'main.js',
  output: {
    extention: ".js",
    filename: 'bundle',
    path: join(__dirname, "dist")
  },
  transpilers: []
}

Bys usage example

Here are some examples of using bys with js and ts.

Using JavaScript
// File: bys.config.js

module.exports = {
  entry: 'main.js',
  output: {
    extention: ".js",
    filename: 'bundle',
    path: join(__dirname, "dist")
  }
}
// File: sum.js

const sum = (x, y) => x + y;
// @bys-import ./sum.js \\

console.log(sum(2, 2));
// Result after using bys.
// File: dist/bundle.js

const sum = (x, y) => x + y;

console.log(sum(2, 2));
Using TypeScript
transpile(code, { /* Language and Environment */ target: "es2016", /* Modules */ module: "AMD", moduleResolution: "node", /* Emit */ removeComments: true, /* Interop Constraints */ esModuleInterop: true, forceConsistentCasingInFileNames: true, /* Type Checking */ strict: true, alwaysStrict: true, }) }">
// File: bys.config.js
const { transpile } = require('typescript');
const { join } = require('path');

module.exports = {
  entry: 'main.ts',
  output: {
    extention: ".js",
    filename: 'bundle',
    path: join(__dirname, "out")
  },
  transpiler: (code) => transpile(code, {
    /* Language and Environment */
    target: "es2016",

    /* Modules */
    module: "AMD",
    moduleResolution: "node",

    /* Emit */
    removeComments: true,

    /* Interop Constraints */
    esModuleInterop: true,
    forceConsistentCasingInFileNames: true,

    /* Type Checking */
    strict: true,
    alwaysStrict: true,
  })
}
// File: user.ts

class User {
  private username: string
  public readonly email: string

  constructor(username: string, email: string) {
    this.username = username,
    this.email = email
  }

  public hello(): void {
    console.log("Hello")
  }
}
// File: main.ts

// @bys-import user.ts \\

const user = new User("carlos", "[email protected]");
user.hello();
// Result after using bys.
// File: out/bundle.js

define(["require", "exports"], function (require, exports) {
  "use strict";
  class User {
      constructor(username, email) {
          this.username = username,
              this.email = email;
      }
      hello() {
          console.log("Hello");
      }
  }
  const user = new User("carlos", "[email protected]");
  user.hello();
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

You might also like...

A JavaScript library to read, write, and merge ZIP archives in web browsers.

Armarius About Armarius is a JavaScript library to read, write, and merge ZIP archives in web browsers. This library mainly focuses on a low memory fo

Nov 9, 2022

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu. More info in User Guide.

Jul 31, 2022

Node module for synchronously and recursively merging multiple folders or collections of files into one folder.

merge-dirs Node module for synchronously and recursively merging multiple folders or collections of files into one folder. Install yarn add @nooooooom

Mar 20, 2022

Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.

vite-plugin-i18next-loader yarn add -D vite-plugin-i18next-loader Vite plugin to client bundle i18next locales composited from one to many json/yaml f

Nov 30, 2022

A script that combines a folder of SVG files into a single sprites file and generates type definitions for safe usage.

remix-sprites-example A script that combines a folder of .svg files into a single sprites.svg file and type definitions for safe usage. Technical Over

Nov 9, 2022

File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

Dec 16, 2022

Make a release for Jitsi test browser page (minify js/css files, pack the app in one file).

Make a release for Jitsi test browser page (minify js/css files, pack the app in one file).

JitsiTestBrowserTool This tools allows you to make a release for Jitsi test browser page (minify js/css files, pack the app in one file). /!\ Not work

Aug 15, 2022

A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM deffiniation and appropriate file structure.

Welcome to function-stencil πŸ‘‹ A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM

Jun 20, 2022

Serve file server with single zip file as file system in Deno.

zipland Serve file server with one-single zip file in Deno. Support zip just zip32 with deflated or uncompressed serving plaintext deflate Examples Yo

Nov 2, 2022
Releases(v2.0.2)
  • v2.0.2(Jan 26, 2022)

    Bundle your scripts (bys)

    Bys is an npm/yarn library to merge your js and ts files into one file.

    Installation

    Use the npm or yarn package manager to install bys.

    # Using npm
    npm i @flamesx128/bys -g
    
    # Using yarn
    yarn add @flamesx128/bys -g
    

    Usage

    Bys needs to know what the main file is, by default it will look in the package.json file, but it can be specified by a bys.config.json file or by the "entry" flag.

    Flags

    With the flags you can change how the program will work.

    • entry

      • This flag specifies which is the main file.
      • Usage: $ bys --entry="main.js"
      • Required flag.
    • output-extention

      • This flag specifies the extension that the file created by bys will have.
      • If not specified, defaults to ".js".
      • Usage: $ bys --output-extention=".js"
      • Optional flag.
    • output-filename

      • This flag specifies what is the name of the file created by bys.
      • If not added, the default name is "bundle".
      • Usage: $ bys --output-filename="bundle.js"
      • Optional flag.
    • output-path

      • This flag specifies the directory where the file created by bys is saved.
      • If not added, the file is placed in the directory where it was called bys.
      • Usage: $ bys --output-path="main.js"
      • Optional flag.

    Configuration file

    You can create a configuration file for bys called bys.config.js with the following structure:

    export interface Config {
      // Main file that read.
      entry?: string,
      output?: {
        // File extension to use when creating.
        extention?: string,
        // Name of the file that will be assigned when it is created.
        filename?: string,
        // Path of the directory where the file created by bys will be saved
        path?: string
      },
      // This method is to transpire the code at the end of joining the files.
      transpiler?(code: string): Promise<string> | string
      // This method is used to transpile the files at the moment they are read.
      transpilers?: {
        execute?(code: string): Promise<string> | string,
        extentions?: RegExp
      }[]
    }
    

    Configuration file example

    // File: bys.config.js
    const { join } = require('path');
    
    module.exports = {
      entry: 'main.js',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "dist")
      },
      transpilers: []
    }
    

    Bys usage example

    Here are some examples of using bys with js and ts.

    Using JavaScript
    // File: bys.config.js
    
    module.exports = {
      entry: 'main.js',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "dist")
      }
    }
    
    // File: sum.js
    
    const sum = (x, y) => x + y;
    
    // @bys-import ./sum.js \\
    
    console.log(sum(2, 2));
    
    // Result after using bys.
    // File: dist/bundle.js
    
    const sum = (x, y) => x + y;
    
    console.log(sum(2, 2));
    
    Using TypeScript
    // File: bys.config.js
    const { transpile } = require('typescript');
    const { join } = require('path');
    
    module.exports = {
      entry: 'main.ts',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "out")
      },
      transpiler: (code) => transpile(code, {
        /* Language and Environment */
        target: "es2016",
    
        /* Modules */
        module: "AMD",
        moduleResolution: "node",
    
        /* Emit */
        removeComments: true,
    
        /* Interop Constraints */
        esModuleInterop: true,
        forceConsistentCasingInFileNames: true,
    
        /* Type Checking */
        strict: true,
        alwaysStrict: true,
      })
    }
    
    // File: user.ts
    
    class User {
      private username: string
      public readonly email: string
    
      constructor(username: string, email: string) {
        this.username = username,
        this.email = email
      }
    
      public hello(): void {
        console.log("Hello")
      }
    }
    
    // File: main.ts
    
    // @bys-import user.ts \\
    
    const user = new User("carlos", "[email protected]");
    user.hello();
    
    // Result after using bys.
    // File: out/bundle.js
    
    define(["require", "exports"], function (require, exports) {
      "use strict";
      class User {
          constructor(username, email) {
              this.username = username,
                  this.email = email;
          }
          hello() {
              console.log("Hello");
          }
      }
      const user = new User("carlos", "[email protected]");
      user.hello();
    });
    

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    Please make sure to update tests as appropriate.

    License

    MIT

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Jan 25, 2022)

    Bundle your scripts (bys)

    Bys is an npm/yarn library to merge your js and ts files into one file.

    Installation

    Use the npm or yarn package manager to install bys.

    # Using npm
    npm i @flamesx128/bys -g
    
    # Using yarn
    yarn add @flamesx128/bys -g
    

    Usage

    Bys needs to know what the main file is, by default it will look in the package.json file, but it can be specified by a bys.config.json file or by the "entry" flag.

    Flags

    With the flags you can change how the program will work.

    • entry

      • This flag specifies which is the main file.
      • Usage: $ bys --entry="main.js"
      • Required flag.
    • output-extention

      • This flag specifies the extension that the file created by bys will have.
      • If not specified, defaults to ".js".
      • Usage: $ bys --output-extention=".js"
      • Optional flag.
    • output-filename

      • This flag specifies what is the name of the file created by bys.
      • If not added, the default name is "bundle".
      • Usage: $ bys --output-filename="bundle.js"
      • Optional flag.
    • output-path

      • This flag specifies the directory where the file created by bys is saved.
      • If not added, the file is placed in the directory where it was called bys.
      • Usage: $ bys --output-path="main.js"
      • Optional flag.

    Configuration file

    You can create a configuration file for bys called bys.config.js with the following structure:

    export interface Config {
      // Main file that read.
      entry?: string,
      output?: {
        // File extension to use when creating.
        extention?: string,
        // Name of the file that will be assigned when it is created.
        filename?: string,
        // Path of the directory where the file created by bys will be saved
        path?: string
      },
      // This method is to transpire the code at the end of joining the files.
      transpiler?(code: string): Promise<string> | string
      // This method is used to transpile the files at the moment they are read.
      transpilers?: {
        execute?(code: string): Promise<string> | string,
        extentions?: RegExp
      }[]
    }
    

    Configuration file example

    // File: bys.config.js
    const { join } = require('path');
    
    module.exports = {
      entry: 'main.js',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "dist")
      },
      transpilers: []
    }
    

    Bys usage example

    Here are some examples of using bys with js and ts.

    Using JavaScript
    // File: bys.config.js
    
    module.exports = {
      entry: 'main.js',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "dist")
      }
    }
    
    // File: sum.js
    
    const sum = (x, y) => x + y;
    
    // @bys-import ./sum.js \\
    
    console.log(sum(2, 2));
    
    // Result after using bys.
    // File: dist/bundle.js
    
    const sum = (x, y) => x + y;
    
    console.log(sum(2, 2));
    
    Using TypeScript
    // File: bys.config.js
    const { transpile } = require('typescript');
    const { join } = require('path');
    
    module.exports = {
      entry: 'main.ts',
      output: {
        extention: ".js",
        filename: 'bundle',
        path: join(__dirname, "out")
      },
      transpiler: (code) => transpile(code, {
        /* Language and Environment */
        target: "es2016",
    
        /* Modules */
        module: "AMD",
        moduleResolution: "node",
    
        /* Emit */
        removeComments: true,
    
        /* Interop Constraints */
        esModuleInterop: true,
        forceConsistentCasingInFileNames: true,
    
        /* Type Checking */
        strict: true,
        alwaysStrict: true,
      })
    }
    
    // File: user.ts
    
    class User {
      private username: string
      public readonly email: string
    
      constructor(username: string, email: string) {
        this.username = username,
        this.email = email
      }
    
      public hello(): void {
        console.log("Hello")
      }
    }
    
    // File: main.ts
    
    // @bys-import user.ts \\
    
    const user = new User("carlos", "[email protected]");
    user.hello();
    
    // Result after using bys.
    // File: out/bundle.js
    
    define(["require", "exports"], function (require, exports) {
      "use strict";
      class User {
          constructor(username, email) {
              this.username = username,
                  this.email = email;
          }
          hello() {
              console.log("Hello");
          }
      }
      const user = new User("carlos", "[email protected]");
      user.hello();
    });
    

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    Please make sure to update tests as appropriate.

    License

    MIT

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Jan 24, 2022)

    Bundle your scripts (bys)

    Bys is an npm/yarn library to merge your js and ts files into one file.

    Installation

    Use the npm or yarn package manager to install bys.

    # Using npm
    npm i @flamesx128/bys -g
    
    # Using yarn
    yarn add @flamesx128/bys -g
    

    Usage

    Bys needs to know what the main file is, by default it will look in the package.json file, but it can be specified by a bys.config.json file or by the "entry" flag.

    Flags

    With the flags you can change how the program will work.

    • entry

      • This flag specifies which is the main file.
      • Usage: $ bys --entry="main.js"
      • Required flag.
    • output-dirname

      • This flag specifies the name of the folder where the file will be added.
      • If not added, the file is placed in the directory where it was called bys.
      • Usage: $ bys --output-dirname="main.js"
      • Optional flag.
    • output-filename

      • This flag specifies what is the name of the file created by bys.
      • If not added, the default name is "bundle".
      • Usage: $ bys --output-filename="bundle.js"
      • Optional flag.

    Configuration file

    You can create a configuration file for bys called bys.config.json with the following structure:

    {
      "entry": "",
      "output": {
        "dirname": "",
        "filename": ""
      }
    }
    

    Example

    Here are some examples of using bys with js and ts.

    Using JavaScript (JS)

    // File: sum.js
    
    function sum(x, y) {
      return x + y;
    }
    
    // File: main.js
    
    // @bys-import ./sum.js \\
    console.log(sum(1, 3))
    

    Result after using bys:

    // File: bundle.js
    function sum(x, y) {
      return x + y;
    }
    console.log(sum(1, 3))
    

    Using TypeScript (TS)

    // File: pong.ts
    
    function pong() {
      return "Pong!";
    }
    
    // File: main.ts
    
    // @bys-import ./pong.ts \\
    console.log(pong())
    

    Result after using bys:

    // File: bundle.ts
    function pong() {
      return "Pong!";
    }
    console.log(pong())
    

    Contributing

    Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

    Please make sure to update tests as appropriate.

    License

    MIT

    Source code(tar.gz)
    Source code(zip)
Owner
FlamesX128
I'm a junior developer.
FlamesX128
mior - Merge into one RSS

mior Merge into one RSS mior is a lightweight web service to filter and merge multiple RSS feeds into one. It provides a pure web-based, responsive us

Eric Fu 29 Nov 6, 2022
Detect npm packages by author name in your package-lock.json or yarn.lock.

detect-package-by-author Detect npm packages by author name in your package-lock.json or yarn.lock. Install Install with npm: # Not Yet Publish # npm

azu 2 Jan 11, 2022
Get packages from a monorepo (pnpm, yarn, npm, lerna)

?? You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. @egoist/get-packages Get packages from a monorepo (p

EGOIST 45 Jun 1, 2022
Detects which package manager (bun, pnpm, yarn, npm) is used.

@skarab/detect-package-manager Detects which package manager (bun, pnpm, yarn, npm) is used based on the current working directory. Features Support p

null 5 Sep 3, 2022
npm i uuid, npm i nodemon, npm i commander

goit-nodejs-hw-01 ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ ΠΈ Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ вСсь список ΠΊΠΎΠ½Ρ‚Π°ΠΊΡ‚ΠΎΠ² Π² Π²ΠΈΠ΄Π΅ Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹ (console.table) node index.js --action list ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ ΠΊΠΎΠ½Ρ‚Π°ΠΊΡ‚ ΠΏΠΎ id node inde

Oksana Banshchykova 3 Jul 5, 2022
Merge multiple JSON files - Vanilla JavaScript and HTML (graphic mode: browser+explorer)

JSON Merger Usage First, git clone project git clone https://github.com/mtacnet/json-merger.git Move to cloned repository and open generate.html with

Tac 1 Sep 18, 2022
Merge multiple Prisma schema files, model inheritance, resolving name conflicts and timings reports, all in a simple tool.

Prisma Util What is Prisma Util? β€’ How to use? β€’ The configuration file β€’ Support What is Prisma Util? Prisma Util is an easy to use tool that merges

David Hancu 21 Dec 28, 2022
Tool made to easily merge multiple GTA 5 vehicle meta files.

mmVehiclesMetaMerger Tool made to easily merge multiple GTA5 vehicle meta files. Showcase Go to Youtube video. Download Click here to go to the releas

Mateusz Mleczek 11 Jan 2, 2023
CLI utility that parses argv, loads your specified file, and passes the parsed argv into your file's exported function. Supports ESM/TypeScript/etc out of the box.

cleffa CLI tool that: Parses argv into an object (of command-line flags) and an array of positional arguments Loads a function from the specified file

Lily Scott 9 Mar 6, 2022
Feel free to create new file, don't hesitate to pull your code, the most important thing is that the file name here must match your nickname so that file does not conflict with other people.

Hacktoberfest Indonesia Apa Itu Hacktoberfest ? Hacktoberfest adalah acara tahunan yang bertujuan untuk mendorong berkontribusi kedalam ekosistem open

Juan Daniel 5 Dec 15, 2022