question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: enable tslib helpers

See original GitHub issue

Type of Issue

[ ] Bug Report
[x] Feature Request

Description

Not sure if you already have considered this, however, doesn’t make sense to enable tslib helpers by default? if not some kind of config override might be needed in order to allow this.

all it needs

    "compilerOptions": {
        "importHelpers": true
    }
  1. add tslib as dependency

https://github.com/Microsoft/tslib

Expected Behaviour

tslib helpers not emitted in the output, as this will make the build smaller.

Version Information

ng-packagr: v2.0.0-rc.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenlautiercommented, Nov 29, 2017

Sure I will check it out 👍

Not sure if it make sense to add tslib as a dependency in the generated package.json, or you recommend simply have to it to add it to your main package.json manually?

1reaction
dhergescommented, Nov 29, 2017

Hi @stephenlautier,

considered, yes. Aren’t the __ decorate, __extends, and so on helpers not required to be included at least once in the esm5 bundle?

You made me check Angular’s GitHub builds repos and @angular/common is:

FESM’5 Bundle:

import { __assign, __extends } from 'tslib';

https://github.com/angular/common-builds/blob/master/esm5/common.js

UMD Bundle:

var extendStatics = Object.setPrototypeOf ||
    ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
    function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = Object.assign || function __assign(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
    }
    return t;
};

https://github.com/angular/common-builds/blob/master/bundles/common.umd.js#L32-L44


TL;DR: you’re right … the quickest way to get there is to set "importHelpers": true and then let rollup inline the tslib helpers to the top of the bundles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

importHelpers - TypeScript: TSConfig Option
importHelpers. For certain downleveling operations, TypeScript uses some helper code for operations like extending class, spreading arrays or objects, and async ...
Read more >
External Helpers Library in TypeScript - Marius Schulz
TypeScript 2.1 adds a compiler option for importing helper functions from an external library. The helpers aren't injected into every file, ...
Read more >
How to use the tslib.__decorate function in tslib - Snyk
To help you get started, we've selected a few tslib.__decorate examples, based on popular ways it is used in public projects.
Read more >
Webpack and Typescript `__extends` - Stack Overflow
aliases: { 'tslib$': 'tslib/tslib.es6.js', }. And configure your tsc / tsconfig.json not to emit the helper functions for every module:
Read more >
Using tslib for TypeScript 2.1 with Aurelia to save bandwidth
Support for external helpers library (tslib) TypeScript injects a handful of helper functions ... in the tsconfig.json file to enable this feature to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found