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

Warn if a module is loaded at the same path twice #1273

Merged
merged 2 commits into from Sep 25, 2017
Merged

Conversation

m-mujica
Copy link
Contributor

Closes #1264

screen shot 2017-09-21 at 16 33 43

@m-mujica
Copy link
Contributor Author

  • The extension is pretty much a no-op is console.warn is not available
  • The extension is only added to the unminified steal versions.

Any feedback about the message?

I feel it could use some explanation on why multiple instantiation might be bad, but the error is already kinda long.

cc: @justinbmeyer @matthewp

var loads = (loader._traceData && loader._traceData.loads) || {};
var map = (loader._traceData && loader._traceData.parentMap) || {};

var parents = (map[load.name] ? Object.keys(map[load.name]) : [])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matthewp is it safe to use Object.keys? I think it's in IE9+

" is being instantiated twice",
"This happens when module identifiers normalize to different module names.\n",
"HINT: Import the module using the ~/[modulePath] identifier" +
(parents ? " in " : ""),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we should be defensive about modules without registered parents, I was thinking about main maybe.... Not sure.

@m-mujica
Copy link
Contributor Author

@matthewp this is ready to review now. I was doing console.warn.bind(console) and console is weird in IE9. ಠ_ಠ

@matthewp
Copy link
Member

👍

@matthewp matthewp merged commit de374a1 into master Sep 25, 2017
@matthewp matthewp deleted the loads-twice-warning branch September 25, 2017 18:39
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.

None yet

2 participants