Skip to content
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

UMD (Universal Module Definition) #14

Closed
wants to merge 2 commits into from
Closed

UMD (Universal Module Definition) #14

wants to merge 2 commits into from

Conversation

duzun
Copy link

@duzun duzun commented Jun 10, 2015

I've added AMD and CommonJs support to jSmart.

This should close issue #10

Avcajaraville added a commit to Avcajaraville/jsmart that referenced this pull request May 10, 2016
- Add UMD, CommonJS & web/browser support. Based on [this pull request](umakantp#14).
- Remove **String.prototype.fetch** function (since this is a very bad practice), and instead, modifying the export of the module. Now it exports the constructor and the fetch function.
- The module now exports the following object: `{ jSmart: jSmart, fetch: fetch }`. This is, `jSmart` constructor and `fecth` function
Avcajaraville added a commit to Avcajaraville/jsmart that referenced this pull request May 10, 2016
- Add UMD, CommonJS & web/browser support. Based on [this pull request](umakantp#14).
- Remove **String.prototype.fetch** function (since this is a very bad practice), and instead, modifying the export of the module. Now it exports the constructor and the fetch function.
- The module now exports the following object: `{ jSmart: jSmart, fetch: fetch }`. This is, `jSmart` constructor and `fecth` function
Avcajaraville added a commit to Avcajaraville/jsmart that referenced this pull request May 10, 2016
- Add UMD, CommonJS & web/browser support. Based on [this pull request](umakantp#14).
- Remove **String.prototype.fetch** function (since this is a very bad practice), and instead, modifying the export of the module. Now it exports the constructor and the fetch function.
- The module now exports the following object: `{ jSmart: jSmart, fetch: fetch }`. This is, `jSmart` constructor and `fecth` function
@umakantp
Copy link
Owner

This feature already exists. See commits done after:- Aug 11, 2015

Please use the latest version.

@umakantp umakantp closed this Aug 11, 2017
@duzun
Copy link
Author

duzun commented Aug 11, 2017

Nice!

Thanks for adding AMD and CommonJS support.

Yet there is something not really good about this code in Browser environment:

(function(){
// ...
 jSmart = function(tpl) { /*...*/ };
// ...
}());

For someone with enough expertise in JS this looks like assigning a function to a global variable, which still is not quite obvious, as you have to scan the entire IIFE function to make sure there is nothing like var jSmarty anywhere.

On the other hand, it doesn't work well for minification and runtime performance, as accessing a global variable is much slower than accessing a local variable.

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