Fork of https://gitlab.com/nightlycommit/twing with a better build system
Go to file
2024-12-31 17:40:56 +02:00
src Replace stream with readable-stream 2024-12-31 17:40:56 +02:00
.editorconfig Resolve issue #577 2023-10-30 22:37:51 +01:00
.gitignore Add package-lock.json 2024-12-28 15:15:52 +02:00
.odzrc.json Resolve issue #616 2024-07-25 07:54:18 +00:00
LICENSE Improve homepage and license 2018-03-06 00:28:47 +01:00
package-lock.json Replace stream with readable-stream 2024-12-31 17:40:56 +02:00
package.json Replace stream with readable-stream 2024-12-31 17:40:56 +02:00
README.md Update README 2024-12-31 12:21:53 +02:00
tsconfig.json Fix SHA1 implementation 2024-12-30 21:31:32 +02:00

Fork notice

This repo is a fork of https://gitlab.com/nightlycommit/twing, with the goal of reducing the bundle size.

Changes made:

  • Replaced Browserify with ESBuild
  • Removed vulnerable dependencies
  • Replaced some of the dependencies with own implementations
  • Removed iconv-lite
  • Removed asynchronous versions of the functions

This results in a bundle size reduction from 841 kB to 227 kB. The package still passes Twing's original tests (except for encoding, see below).

Caveats:

  • Non-UTF-8 runtimes have limited support
  • A modern runtime (one that supports TextEncoder, typed arrays etc) is required
  • Only UTF-8 is supported as the output charset in convert_encoding
  • SHA256 is replaced by SHA1 in error messages

ORIGINAL README

Twing

NPM version Build Status Coverage percentage Donate

First-class TypeScript and JavaScript Twig compiler

Prerequisites

This projects needs at least node.js 16.0.0 to run.

It is also strongly recommended to have ts-node and One Double Zero installed globally to ease the writing of tests and the tracking of the code coverage.

Usage

Installation

npm install

Build the library

npm run build

Build and run the test suite

npm run build:test
npm run test

Build and run the test suite in a browser

npm run build:test
npm run test:browser

Writing and executing tests

Assuming one want to execute the test located in src/test/tests/integration/comparison/to-array.ts, one would run:

ts-node src/test/tests/integration/comparison/to-array.ts

It is even possible - and recommended - to track the coverage while writing tests:

odz ts-node src/test/tests/integration/comparison/to-array.ts

Of course, it is also perfectly possible to pipe the result of the test to your favorite tap formatter:

src/test/tests/integration/comparison$ ts-node . | tap-nyan
 9   -_-_-_-_-_,------,
 0   -_-_-_-_-_|   /\_/\ 
 0   -_-_-_-_-^|__( ^ .^) 
     -_-_-_-_-  ""  "" 
  Pass!

Contributing

  • Fork this repository
  • Code
  • Implement tests using tape
  • Issue a pull request keeping in mind that all pull requests must reference an issue in the issue queue

License

Copyright © 2018-2023 Eric MORAND. Released under the 2-Clause BSD License.