Skip to content

Improved Browserify compatibility#155

Merged
oblador merged 2 commits into
oblador:masterfrom
mchambaud:master
Oct 30, 2015
Merged

Improved Browserify compatibility#155
oblador merged 2 commits into
oblador:masterfrom
mchambaud:master

Conversation

@mchambaud
Copy link
Copy Markdown
Contributor

  • Package.json should not specify minified version as main.
  • Module should export itself for UMD builds.

oblador added a commit that referenced this pull request Oct 30, 2015
Improved Browserify compatibility
@oblador oblador merged commit f466465 into oblador:master Oct 30, 2015
@oblador
Copy link
Copy Markdown
Owner

oblador commented Oct 30, 2015

Looks great, thanks!

@mchambaud
Copy link
Copy Markdown
Contributor Author

Awesome thank you!

Any chance for a version bump and publish to NPM?

@ctaepper
Copy link
Copy Markdown

ctaepper commented Nov 4, 2015

to make that even more compliant with best practices, module.exports should not export the module itsself, but the name of the module, i.e. module.exports = "duScroll" or module.exports = duScroll.name

@mchambaud
Copy link
Copy Markdown
Contributor Author

I agree with @ctaepper that's how I do it for myself, but I find people tend to export the module itself.

@oblador do you have a preference?

@ctaepper
Copy link
Copy Markdown

ctaepper commented Nov 4, 2015

those people just don't know better yet... :)

@oblador
Copy link
Copy Markdown
Owner

oblador commented Nov 4, 2015

Using angular with browserify makes me a bit uncomfortable because they both try to solve the same problem. Haven't read any best practices for this and am not too opinionated, personally for my angular projects I export both :-) Somehow feels weird for an AMD to only return strings.

Got any links on the matter?

@ctaepper
Copy link
Copy Markdown

ctaepper commented Nov 4, 2015

Finally, to match the convention for CommonJS set up within Angular, you’ll need to expose the string that people use to load your module. You’ll do this using module.exports. Note, this is a convention that Angular uses, and it doesn’t necessarily apply to other front-end projects.

see http://blog.npmjs.org/post/114584444410/using-angulars-new-improved-browserify-support

basically like this

// require the module
var scroll = require('angular-scroll')

// and add it as dependency to your app
angular.module('app', [scroll])

@oblador
Copy link
Copy Markdown
Owner

oblador commented Nov 19, 2015

@ctaepper: As of 0.7.4 this is now the behavior. If you want to access the module itself then do a require('angular-scroll/angular-scroll').

@ctaepper
Copy link
Copy Markdown

👍

1 similar comment
@mchambaud
Copy link
Copy Markdown
Contributor Author

👍

@oblador
Copy link
Copy Markdown
Owner

oblador commented Nov 19, 2015

It's actually 1.0.0 now since it broke someone's installation :-)

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.

3 participants