Skip to content
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

fix: no longer warns when no name was provided for global module #2359

Merged
merged 3 commits into from
Jul 31, 2018

Conversation

alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Jul 28, 2018

When the dictionary lookup or function look up return undefined or null, a warning should be emitted and the module name should be guessed.

If the user, doesn't receive a warning that the global name was not found, they won't be able to fix a possible issue. If the global name is incorrect or later set to null.

Closes: #2358

Some more context
ng-packagr/ng-packagr#1026 (comment)

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This is an important fix.

I've provided a suggestion around trying to isolate your use case from more simple workflows. Let me know your thoughts.


if (globalName) {
return globalName;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok to not warn when the user has not specified any configuration, as in many cases this is the required behaviour that the package name be the request package name (eg this is the default on npm that a request package name and output package name can match).

The issue maybe arises in environments in which you are defining a global function or map that is trying to be authoritative and then has these invisible misses.

Instead, perhaps let's only warn for the case where globals is provided but has misses, by adding that as another case above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not 100% sure about this, as for UMD, I noticed that a lot of guessed name would be incorrect. If for instance having a . in the name. Or when the umd bundle name is totally different, and without a warning, it's hard to rollup users to know that something might be wrong.

However I can do what you suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@guybedford pushed an update.

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Seems like a worthy regression fix to me.

src/Chunk.ts Outdated
return globalName;
}

if (hasExports || (hasExports ** globals && !globalName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean && here?

Copy link
Contributor Author

@alan-agius4 alan-agius4 Jul 30, 2018

Choose a reason for hiding this comment

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

yeah looks like the IDE didn't save :P, re-pushed. Thanks for your patience 👍

src/Chunk.ts Outdated
return globalName;
}

if (hasExports || (hasExports && globals && !globalName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (hasExports || globals && !globalName) would be simpler here I think.

@guybedford
Copy link
Contributor

I've been thinking about this some more and maybe you are right we should always warn actually...

@alan-agius4
Copy link
Contributor Author

alan-agius4 commented Jul 30, 2018 via email

@guybedford
Copy link
Contributor

LGTM

@lukastaegert lukastaegert merged commit d07d5bf into rollup:master Jul 31, 2018
@alan-agius4 alan-agius4 deleted the feature_fix_global branch July 31, 2018 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rollup no longer warns when no name was provided for global module
3 participants