Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Conversation

Zlatkovsky
Copy link
Member

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!

@WrathOfZombies
Copy link
Contributor

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.

Copy link

@siewmoi siewmoi left a 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.

@markpete
Copy link

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.

@siewmoi
Copy link

siewmoi commented Apr 28, 2017 via email

@markpete
Copy link

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?

Copy link
Contributor

@WrathOfZombies WrathOfZombies left a 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.

> ![Import](.github/images/unpkg.jpg)

#### Moderate: NPM package is an AMD module, but the library is also available via a "dist" build
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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>`.
Copy link
Contributor

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:
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

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!)
Copy link
Contributor

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:
Copy link
Contributor

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.

Copy link
Contributor

@WrathOfZombies WrathOfZombies left a 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.

@WrathOfZombies
Copy link
Contributor

@markpete we support upto ES7 and we down compile back to ES5.

@WrathOfZombies
Copy link
Contributor

WrathOfZombies commented Apr 28, 2017

@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.
some background: wrt to our MS Graph samples, we had many repos, one for each platform, etc and to top it they were also getting started samples on dev.office.com. We used the wiki during preview and had to move to dev.office.com repo at GA.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants