Remove pragmas, rely on identifier instead#2
Merged
threepointone merged 1 commit intothreepointone:masterfrom Nov 21, 2016
Merged
Remove pragmas, rely on identifier instead#2threepointone merged 1 commit intothreepointone:masterfrom
threepointone merged 1 commit intothreepointone:masterfrom
Conversation
Owner
|
This is great! I'll remove the bit with self linking and use a webpack resolve alias instead. Thanks much! |
Owner
|
merged and published in 1.1.3. Thank you very much! |
Contributor
Author
|
Cool, it's worth noting that this is not totally foolproof, the following should work: var foo = require('markdown-in-js') // ok
var bar;
bar = require('markdown-in-js') // okthe following will cause pain var foo = require('markdown-in-js') // ok
function demo () {
var foo = 123
console.log(foo) // boom because we don't know that foo is shadowed.
}and var foo = require('markdown-in-js') // ok
foo = 123
console.log(foo) // oh dear, we don't know that foo has been reassignedIt's not hard to fix this issue but it's worth adding a note in the README in the meantime |
Owner
|
yes, it's also why I went with a simple hardcoded value in the first place, just needed something that worked. I'll also make the error more meaningful in the above cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's fragile and precarious to rely on a particular identifier name for this kind of thing. It's too easy to call an identifier
markdownsome time in the future and find yourself fighting a bug that seems totally impossible. This PR scraps the idea of pragmas and relies on the name of the identifier being imported or required instead.