-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added support for using require(...) in code examples. #25
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
Added support for using require(...) in code examples. #25
Conversation
|
I thought more about it, and it should be actually possible to infer the right context from the example code (rather than specifying the context regex upfront, for all examples at once). And for sure this would also be the most user-friendly way to do it. What do you think? |
|
That would be very nice because now it’s hard to understand. |
|
Well, I researched this a bit, but apparently webpack doesn't expose its internal behaviour of creating a require contect containing whatever the module needs. The context API lets me create a context giving a regex, so I could look for What do you think? |
|
I think it’s much better ;-) |
a6d3e5d to
a32b2cc
Compare
|
Okay, see the new commit. I'd add some tests for my helper functions but I don't see any test framework installed. Could you take care of this? |
|
Cool! I’ll add Mocha soon. |
8c87b17 to
facceef
Compare
|
Check my new commit |
|
Mocha is here! |
facceef to
e4af933
Compare
|
I thought about it again and I realized that I don't need the webpack's I still didn't add any tests, but I don't know what exactly could I test. Please look at the code and tell me if you feel like some part of it might break in the future. |
|
Cool, thanks! About tests:
|
This is harder than I thought because the loader is in ES5 and utils are ES6, so I can't just |
|
Or you can just export these function from the loader and use them in tests. |
|
That's what I do: Btw, there's a simpler way to check JS (ES5) validity: http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.2.1 :
|
|
Cool! And a simpler way is always better ;-) |
|
Done! |
cdc6736 to
999a30c
Compare
|
Cooooool! |
999a30c to
828436c
Compare
|
commit updated, ihmo it's good to merge now. |
Added support for using require(...) in code examples.
|
Thank you very much!
|
@sapegin, I need your help with testing this code. And I wait for any other comments. ;)