Skip to content

build: import tslib instead of letting tsc generate helpers #4787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2017

Conversation

jelbourn
Copy link
Member

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 24, 2017
@jelbourn jelbourn force-pushed the tslib branch 2 times, most recently from 0f23592 to c02284e Compare May 24, 2017 22:35
bundleOptions.plugins = [rollupNodeResolutionPlugin()];

// Clone ROLLUP_GLOBALS so we don't accidentally modify it.
bundleOptions.globals = Object.assign({}, ROLLUP_GLOBALS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to change writeOptions.globals?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I don't think this part is doing anything at all (and isn't needed)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -67,5 +72,19 @@ export function createRollupBundle(config: BundleConfig): Promise<any> {
sourceMap: true
};

// When creating a UMD, we want to exclude tslib from the `external` and `globals` bundle options
// so that it is inlined into the bundle.
if (config.format === 'umd') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rather add a new option to the BundleConfig that says includeTslib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be redundant, though, since we only want to do this for UMDs anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just too much magic IMO. The rollup-helpers is a helper file that should be at least a bit generic.

Especially when we expose the package utilities (to for example flex-layout)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would want the same behavior for flex-layout (and anything else we build). The UMD really is the special case.

Copy link
Member

@devversion devversion May 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just an example. At some point it will end up similar as with the convertIndexShorthandImports in tsc-wrapped.

It's basically the same question about just inferring the dest path on our own. Being flexible just opens more doors and is less like a black-box.

Anyway, your decision. I don't like it to be honest and this makes the helper into something more magic.

// When creating a UMD, we want to exclude tslib from the `external` and `globals` bundle options
// so that it is inlined into the bundle.
if (config.format === 'umd') {
bundleOptions.plugins = [rollupNodeResolutionPlugin()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could always add this plugin. It shouldn't change anything for normal FESM bundles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather leave it where it's needed rather than just installing it all the time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that's a fair point.

@tinayuangao
Copy link
Contributor

LGTM

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker pr: merge safe labels May 25, 2017
@tinayuangao tinayuangao merged commit e3b2587 into angular:master May 25, 2017
devversion added a commit to devversion/material2 that referenced this pull request May 26, 2017
Recently with angular#4787 the tsc generated helpers got replaced with helpers from the `tslib` package.

This means that the generated IIFE statements are different than before and the pure annotations RegExps don't work anymore.
tinayuangao pushed a commit that referenced this pull request May 26, 2017
Recently with #4787 the tsc generated helpers got replaced with helpers from the `tslib` package.

This means that the generated IIFE statements are different than before and the pure annotations RegExps don't work anymore.
@jelbourn jelbourn deleted the tslib branch September 13, 2017 04:38
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants