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

netteForms.js: common js, amd #69

Closed
davidkudera opened this issue Mar 2, 2015 · 5 comments
Closed

netteForms.js: common js, amd #69

davidkudera opened this issue Mar 2, 2015 · 5 comments

Comments

@davidkudera
Copy link

Since nette-forms is registered in bower repository, it would be really greate if netteForms.js could work with common js or amd environments.

Eg. I'm using browserify with gulp to build my js files. But it's little bit difficult with nette forms, because I have to use something like browserify-shim to actually simulate wanted behavior.

Prons:

  • In common js or amd environment, Nette object will not be in global object
  • Easy to use in these environments
  • Nette is trying to encourage everyone to not use global services like old Environment, so this is just another step 😉

Cons:

  • Pull request will be for whole file, because all code needs to be wrapped in function

Good example is at nprogress package.

Edit

So even browserify-shim doesn't work

@JanTvrdik
Copy link
Contributor

netteForms.js must be able to work without common js or amd environment

@vojtech-dobes
Copy link
Contributor

common js / amd compatibility should be achievable without dependency on anything, I think.

@davidkudera
Copy link
Author

@JanTvrdik I know and that is why I send link to nprogress, which works great in each environment and without any dependency.

Actually I had to (temporary) create custom transform function for browserify which will wrap netteForms.js into function like that:

(function() {
    var Nette = Nette || {};

    // ...

    module.exports = Nette;
});

Edit:

Of course this code is just for common js

@davidkudera
Copy link
Author

The only thing I would do differently from nprogress is line 14, where I would use window instead of this. Thats because for example browserify wraps each module (file) in another function with different scope

Edit:

It really doesn't matter.... If I'm using browserify, than I don't need any window.. Sorry for useless comment

@dg dg closed this as completed in 6f27810 Mar 14, 2015
@davidkudera
Copy link
Author

Thank you sir

Dne so, 14. 3. 2015 17:53 uživatel David Grudl [email protected]
napsal:

Closed #69 #69 via 6f27810
6f27810
.


Reply to this email directly or view it on GitHub
#69 (comment).

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

No branches or pull requests

3 participants