Skip to content

Instantly share code, notes, and snippets.

@justinbmeyer
Last active August 29, 2015 14:04
Show Gist options
  • Save justinbmeyer/8cf8172d3c962783873d to your computer and use it in GitHub Desktop.
Save justinbmeyer/8cf8172d3c962783873d to your computer and use it in GitHub Desktop.
Understanding

Ryan, Thanks for your patience. I'm not trying to be willfully ignorant, but I'm still not sure what you are trying to say exactly. Twitter is the worst except for everything that's come before it. Let me try to break down your last tweet:

its not for lib authors who want to depend on other libs that aren't UMD or export to everything, that's my entire point.

What is "its"? I'm assuming you were referring to my previous tweet: "interop is possible for lib authors". So you mean:

Interop is not possible for lib authors who want to depend on other libs that:

  • are not umd, or
  • do not export to everything

I agree with that with some qualifications. Some terms:

  • library - the library someone is authoring
  • dependency - a dependency of the library
  • app - an application that wants to use dependency

The qualifications:

  • The app can't use something like SystemJS.

  • The app can't include a Browserify "super-plugin". For example, I think browserify-config might be able to handle AMD? Not entirely sure. But there's probably browserify plugins or one can be made that works with AMD.

  • The app can't include a "commonjs" plugin for RequireJS (probably an installable dependency of library) that would allow RequireJS to process commonjs like

    define(["commonjs!querystring","underscore"] ...)`.

This is how library would export it's AMD build.

  • library wants existing package installers (npm / bower) to be able to do the install of LIB dependencies without post-install transpiling/building.

  • library does want to package those dependencies inside themselves. I think this is probably ok for node environments (it's common that two dependencies might install the same dependency that is not shared). And with RequireJS's bundle config, one could point the "bundles" config at lib like:

    ```js
    RequireJS.config({
      bundles: {lib: ["querystring"]}
    })
    ```
    

Conclusion

Now that I've written all that out, it's probably doable by making RequireJS or Bower understand the other format, or being ok packaging your dependency internally. I can see how "making RequireJS or Bower understand the other format" is a cheat.

Thanks for talking through this with me.

@justinbmeyer
Copy link
Author

After thinking about it more, "packaging your dependency internally" is not a solution for RequireJS. If any other project also packages, you are loading it 2x.

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