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

support umd #333

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ module.exports = function(grunt) {
flow: {
files: {
'dist/ng-flow.js': [
'src/provider.js',
'src/directives/init.js',
'src/directives/*.js',
'src/*.js'
],
'dist/ng-flow-standalone.js': [
'bower_components/flow.js/dist/flow.js',
'src/provider.js',
'src/directives/init.js',
'src/directives/*.js',
'src/*.js'
]
}
Expand Down
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ How can I install it?
============
1) Get the library:

**npm**

npm install angular @flowjs/ng-flow

**Direct Download**
Download a latest build from https://github.com/flowjs/ng-flow/releases
it contains development and minified production files in `dist/` directory,
they are also concatenated with core flow.js library.

**Using Bower**

bower install ng-flow#~2

**Git Clone**

git clone https://github.com/flowjs/ng-flow
Expand All @@ -28,11 +28,20 @@ they are also concatenated with core flow.js library.
bower install "ng-flow#~2" --save
grunt bower-install

2) Add the module to your app as a dependency:
2) Add the module to a module in your app as a dependency:

import angular from 'angular';
import ngFlow from '@flowjs/ng-flow';

const MODULE_NAME = 'appName.moduleName';
angular.module(MODULE_NAME, [ngFlow]);

angular.module('app', ['flow'])
export default MODULE_NAME;

3) Include the files in your project
See https://www.npmjs.com/package/webpack or https://www.npmjs.com/package/browserify

or for legacy applications:
```html
<!-- concatenated flow.js + ng-flow libraries -->
<script src="ng-flow/dist/ng-flow-standalone.min.js"></script>
Expand Down Expand Up @@ -253,6 +262,17 @@ var app = angular.module('app', ['flow'])
}]);
````

Bower
=====

Bower has been deprecated in favour of yarn/webpack, however it is still
supported by ng-flow for legacy applications.

**Using Bower**

bower install ng-flow#~2


Contribution
============
To ensure consistency throughout the source code, keep these rules in mind as you are working:
Expand Down
16 changes: 15 additions & 1 deletion dist/ng-flow-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,17 @@
}
})(window, document);

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['angular', '@flowjs/flow.js'], factory);
} else if (typeof exports === 'object') {
// Node, CommonJS-like
module.exports = factory(require('angular'), require('@flowjs/flow.js'));
} else {
// Browser globals (root is window)
root.ngFlow = factory(root.angular, root.Flow);
}
}(this, function (angular, Flow) {
/**
* @description
* var app = angular.module('App', ['flow.provider'], function(flowFactoryProvider){
Expand Down Expand Up @@ -1922,4 +1933,7 @@ angular.module('flow.transfers', ['flow.init'])
};
}]);
angular.module('flow', ['flow.provider', 'flow.init', 'flow.events', 'flow.btn',
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);

return 'flow';
}));
2 changes: 1 addition & 1 deletion dist/ng-flow-standalone.min.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion dist/ng-flow.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['angular', '@flowjs/flow.js'], factory);
} else if (typeof exports === 'object') {
// Node, CommonJS-like
module.exports = factory(require('angular'), require('@flowjs/flow.js'));
} else {
// Browser globals (root is window)
root.ngFlow = factory(root.angular, root.Flow);
}
}(this, function (angular, Flow) {
/**
* @description
* var app = angular.module('App', ['flow.provider'], function(flowFactoryProvider){
Expand Down Expand Up @@ -286,4 +297,7 @@ angular.module('flow.transfers', ['flow.init'])
};
}]);
angular.module('flow', ['flow.provider', 'flow.init', 'flow.events', 'flow.btn',
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);

return 'flow';
}));
2 changes: 1 addition & 1 deletion dist/ng-flow.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* for module loading using webpack or similar package bundlers */
window.Flow = require('./dist/ng-flow-standalone');
Copy link
Author

Choose a reason for hiding this comment

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

mutating window in a commonjs module is not acceptable.

module.exports = 'flow';
/* backwards compatable with deprecated index.js*/
Copy link
Author

Choose a reason for hiding this comment

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

this file is ignored by commonjs loaders because of the 'main' key in package.json so I log a warning.

try {
console.warn(new Error("use const ngFlow = require('@flowjs/ng-flow');"));
} catch (e) {
// do nothing
}

if (typeof window === 'object') {
window.Flow = require('@flowjs/flow.js');
Copy link
Author

Choose a reason for hiding this comment

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

mutating window in a commonjs module is not acceptable, but I do it here for require('@flowjs/ng-flow/index') for backwards compatibility reasons.

}
module.exports = require('./src/ng-flow');
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"test": "grunt test"
},
"main": "dist/ng-flow.js",
"main": "src/ng-flow.js",
"repository": {
"type": "git",
"url": "git://github.com/flowjs/ng-flow.git"
Expand Down Expand Up @@ -36,5 +36,11 @@
"karma-firefox-launcher": "0.1.7",
"karma-jasmine": "^0.3.6",
"karma-sauce-launcher": "0.3.1"
},
"dependencies": {
"@flowjs/flow.js": "^2.13.0"
},
"peerDependencies": {
"angular": "^1.2"
}
}
2 changes: 0 additions & 2 deletions src/angular-flow.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/directives/btn.js

This file was deleted.

57 changes: 0 additions & 57 deletions src/directives/drag-events.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/directives/drop.js

This file was deleted.

50 changes: 0 additions & 50 deletions src/directives/events.js

This file was deleted.

22 changes: 0 additions & 22 deletions src/directives/img.js

This file was deleted.

43 changes: 0 additions & 43 deletions src/directives/init.js

This file was deleted.

Loading