8000 Remove pragmas, rely on identifier instead by phpnode · Pull Request #2 · threepointone/markdown-in-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove pragmas, rely on identifier instead #2

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
Nov 21, 2016

Conversation

phpnode
Copy link
Contributor
@phpnode phpnode commented Nov 21, 2016

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 markdown some 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.

@threepointone threepointone merged commit 5ee50c3 into threepointone:mast 8000 er Nov 21, 2016
@threepointone
Copy link
Owner

This is great! I'll remove the bit with self linking and use a webpack resolve alias instead. Thanks much!

@threepointone
Copy link
Owner

merged and published in 1.1.3. Thank you very much!

@phpnode
Copy link
Contributor Author
phpnode commented Nov 21, 2016

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') // ok

the 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 reassigned

It's not hard to fix this issue but it's worth adding a note in the README in the meantime

@threepointone
Copy link
Owner
threepointone commented Nov 21, 2016

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.

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.

2 participants
0