Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Improve support for CommonJS usage #21

Closed
wants to merge 1 commit into from

Conversation

linclark
Copy link
Contributor

As folks brought up in angular/material#1655, people using tools like Browserify will expect that angular-animate and angular-aria will be required in index.js. Since they are listed as dependencies, they will have already been downloaded and will be available to the module system.

You don't actually need to use the path, so the possible path variations won't be a problem. When Browserify is processing the file, it uses Node's module resolution to figure out that require('angular-animate') should use path/to/angular-animate. This is one of the advantages of Browserify and CommonJS support. It means that apps which use angular-material don't need to hardcode paths for angular-material's dependencies.

@linclark
Copy link
Contributor Author

I created a demo to show this working. It's currently using my fork (which has this change in it) as the npm dependency.

@jgoux
Copy link

jgoux commented Mar 13, 2015

👍 for this as well !
I won't need browserify-shim anymore :

"browser": {
    "angular-animate": "./node_modules/angular-animate/angular-animate.js",
    "angular-aria": "./node_modules/angular-aria/angular-aria.js",
    "angular-material": "./node_modules/angular-material/angular-material.js",
  },
  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
  "browserify-shim": {
    "angular-material": {
      "depends": [
        "angular-animate",
        "angular-aria"
      ]
    },

@ThomasBurleson ThomasBurleson self-assigned this Apr 7, 2015
@@ -1,2 +1,4 @@
require('angular-animate');
require('angular-aria');
require('./angular-material');
module.exports = 'ngMaterial';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linclark - would we not also want to do the same Angular?

// Load Angular and dependent libs
require('angular');
require('angular-animate');
require('angular-aria');

// Now load Angular Material
 require('./angular-material');

// Export namespace
 module.exports = 'ngMaterial';

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.

3 participants