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

Support for CommonJS/AMD/UMD #4919

Closed
Closed
@pluma

Description

@pluma

This is not another "Angular modules should be real modules" ticket.

Currently AngularJS directly pollutes the global namespace. This means using angularjs in an environment that uses a module loader (e.g. require.js or browserify) requires developers to use shims or just give up and use AngularJS from the window object directly.

Instead, AngularJS should only attach itself to the window object if AMD is not present and there is no CommonJS/node-style module/exports object available. The UMD repository has plenty of examples for this.

The only implementation issue I can see is that AngularJS is becoming more modularized with "plugins" like the ngRoute module, which depend on AngularJS and potentially modify the angular object directly.

Ideally AngularJS should also provide an npm package (for browserify primarily, but with some modifications it could also work with server-side implementations of the browser DOM).

I realize the whole "modularity" concept is a problem with the different interpretations of how modules ought to work between AngularJS on the one side and AMD/CommonJS on the other, but I think it would be beneficial to the community if it were possible to load the files that are currently intended to be loaded via script tags with a real module loader like require.js/curl.js or browserify instead.

EDIT: Another problem I could imagine would be the optional dependency on jQuery (and potentially Q) as neither AMD nor CommonJS currently provide a mechanism for optional dependencies. If that's the only thing keeping AngularJS back, I would recommend creating a mechanism to configure AngularJS after it has been loaded (though before it has been applied to the document).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions