Skip to content
Rubén Díaz edited this page Jun 27, 2017 · 16 revisions

TypeScript Merger

TS-Merger is a tool designed to parse and merge a base and a patch file into one single file depending on the merge strategy defined.

Currently, the merger supports the following AST node types:

  1. ImportDeclaration

  2. ClassDeclaration

  3. Constructor

  4. MethodDeclaration

  5. Parameter

  6. PropertyDeclaration

  7. Decorator

  8. ObjectLiteralExpression

  9. ArrayLiteralExpression

  10. PropertyAssignment

  11. CallExpression

  12. VariableAssignment

  13. Body (only merges variable declarations with same identifier)

  14. FunctionDeclaration

Requirements

  1. Node 6.9.2 or higher

  2. Webpack

    npm install -g webpack

Optional requirements

  1. ts-node

    npm install -g ts-node
  2. yarn

    npm install -g yarn

Usage

The TS Merger can be launched in two ways depending the file you want to launch:

  1. Launching the TS code directly

    ts-node src\index.ts -f -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>> -o <<OUTPUT_FILE_PATH>> -e <<ENCODING>>
ts-node src\index.ts -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>> -e <<ENCODING>>
ts-node src\index.ts -f -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>>
  1. From compiled JS file resultant from webpack:

    node dist\tsmerger.js -f -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>> -o <<OUTPUT_FILE_PATH>> -e <<ENCODING>>
node dist\tsmerger.js -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>> -e <<ENCODING>>
node dist\tsmerger.js -f -b <<BASE_FILE_PATH>> -p <<PATCH_FILE_PATH>>
  1. To set patchOverride to true just use the -f flag

  2. If not -o or -e flags are used, no output file will be generated and UTF-8 encoding will be used.

Overview

Development

Clone this wiki locally