-
Notifications
You must be signed in to change notification settings - Fork 53
README details on using external libraries + some reorganization #391
base: master
Are you sure you want to change the base?
Conversation
Would you want to split this readme into Wiki's instead? It would be easier to consume and only look for what you want thanks to a TOC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to non-libraries sections, looks good (for now). I can do a more thorough review/step thru post build. wrt the libraries sections, defer to Bhargav.
Is it worth talking about nested library dependencies and how they get loaded? My assumption is that this is all automatic like a normal npm package, but I'm curious if there are cases where you need to add the nested dependencies to the Library list. |
Wikis are great but I found wiki not so portable (compared to md files). When I was doing MS Graph samples we used shared wiki to point ppl to small how to this and that. Keeping track of them was a pain too.
From: Bhargav Krishna [mailto:[email protected]]
Sent: Friday, April 28, 2017 12:53 PM
To: OfficeDev/script-lab <[email protected]>
Cc: Siew Moi Khor <[email protected]>; Review requested <[email protected]>
Subject: Re: [OfficeDev/script-lab] README details on using external libraries + some reorganization (#391)
Would you want to split this readme into Wiki's instead? It would be easier to consume and only look for what you want thanks to a TOC.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub<OfficeDev/script-lab#391 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AJ-LPNrcUGTb9lWcnN3f04t1wkez2cPEks5r0kOMgaJpZM4NL3Im>.
|
Also, what version(s) of ES does ScriptLab support? I'm assuming ES5/6 yes and ES7 no. Is it the same as Edge, IE, or Chrome? Chakra? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading through it, I feel it would benefit both the way we document stuff and engagement if we went ahead and shaved off some content and added it here:
https://medium.com/office-app-development
and link that in this readme as good to read. Also linking https://basarat.gitbooks.io/typescript/content/docs/getting-started.html will help.
>  | ||
|
||
#### Moderate: NPM package is an AMD module, but the library is also available via a "dist" build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong title for the given example. An AMD module is one that is loaded from require.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont mention "dist" in title as its not a hard and fast rule to have stuff available from dist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your further docs, i think you mean to add a NOT?
NPM package is an **NOT** AMD module, b
"https://unpkg.com/[email protected]", | ||
3302, 1, ReferenceError: module is not defined {}] | ||
|
||
If you are lucky, even though the *NPM* package doesn't contain a web-ready version of the package, the web-compatible version may be available elsewhere. In the case of this `javascript-qrcode` package, the [NPM entry](https://www.npmjs.com/package/javascript-qrcode) points to a GitHub repo, <https://github.com/siciarek/javascript-qrcode>. And the repo, in turn, has a "dist" folder (convention), along with exampe usage that also shows `<script src="dist/qrcode.min.js"></script>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead taking a fail first approach would help, as the developer to verify that the library is web compatible. Then try and reference via unpkg. If it still doesnt work, examine the contents of the package, try rawgit. else post an issue on the developers repository to expose an npm package.
|
||
This just means that you need to have required an additional library, tinycolor. Again, find its location (with https://unpkg.com being the easiest way of procuring it), and add it to the config paths list (*again, remembering to omit just the `.js` part of the filename). Also include the library name in the array in the `require` statement. When you patch up both bits, you will end up with the following: | ||
|
||
// At the top of the file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark code range with typescript instead of tabs/4 spaces.. and end it with
This will allow you to get coloring.
|
||
In your libraries tab, add a reference to `require.js` and to its IntelliSense types (note that `require.js` itself should be loaded from a web-compatible CDN version, not its NPM package): | ||
|
||
https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use unpkg!!!
requirejs
@types/requirejs
Include this in your Libraries tab, and you're good to go! | ||
|
||
|
||
#### Harder: NPM package is an AMD module (must be loaded with `require.js`), and is *not* available in "dist" form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is the medium
difficulty one. Given that there's a possibility of loading stuff in.
@Zlatkovsky a todo would be adding a require.config tab when we see require.js being a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea of making require a native part of ScriptLab. It's pretty commonly used across the web app world these days.
console.log(gradient.rgb(10)); | ||
}); | ||
|
||
If you're lucky, it will work right off the bat. If you're slightly less lucky, you might still get a useful error that will help you fix the issue (which is why the `require.onError` line described in step #1 is so important!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about this feels weird. Luck has nothing to do with it.
Its code. there's either a true or a false.
Error: Script error for "tinycolor", needed by: tinygradient | ||
http://requirejs.org/docs/errors.html#scripterror {...} | ||
|
||
This just means that you need to have required an additional library, tinycolor. Again, find its location (with https://unpkg.com being the easiest way of procuring it), and add it to the config paths list (*again, remembering to omit just the `.js` part of the filename). Also include the library name in the array in the `require` statement. When you patch up both bits, you will end up with the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we are teaching folks how to use require.js today. In that case how do we plan to support say system.js or X.js when its out tomorrow. May be we should avoid this. Have it as a blog post on your personal blog or medium saying "How do you load AMD libraries in Script Lab". There you can explain all you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want let's have a chat first about this before we make it public. I feel certain things are out of place.
@markpete we support upto ES7 and we down compile back to ES5. |
@siewmoi Could you explain what you meant by port? Where are we porting them to? Also why would we port something on this repository elsewhere? @WrathOfZombies - if we don't foresee a need to port, then it's ok to use wiki. |
I added a bunch of detail on how to use external libraries, and also used this as an opportunity for some minor reorganization.
Could one of you take a look and see if it all makes sense and is grammatically sound? @WrathOfZombies, could you also help make sure I'm using the right terminology and explanation of the various types of modules? Thanks!