Skip to content

Commit

Permalink
Merge pull request #9 from homer0/homer0_updatePlugin
Browse files Browse the repository at this point in the history
Update the plugin
  • Loading branch information
Leonardo Apiwan committed Jun 28, 2018
2 parents 58958f1 + 23aba86 commit 3499f77
Show file tree
Hide file tree
Showing 8 changed files with 1,659 additions and 1,445 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"import/no-extraneous-dependencies": "off",
"function-paren-newline": "off",
"arrow-parens": ["error", "always"],
"no-plusplus": "off"
"no-plusplus": "off",
"lines-between-class-members": "off",
"operator-linebreak": ["error", "after"]
}
}
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# projext plugin for AngularJS on webpack

[![Travis](https://img.shields.io/travis/homer0/projext-plugin-webpack-angularjs.svg?style=flat-square)](https://travis-ci.org/homer0/projext-plugin-webpack-angularjs)
[![Coveralls github](https://img.shields.io/coveralls/github/homer0/projext-plugin-webpack-angularjs.svg?style=flat-square)](https://coveralls.io/github/homer0/projext-plugin-webpack-angularjs?branch=master)
[![David](https://img.shields.io/david/homer0/projext-plugin-webpack-angularjs.svg?style=flat-square)](https://david-dm.org/homer0/projext-plugin-webpack-angularjs)
[![David](https://img.shields.io/david/dev/homer0/projext-plugin-webpack-angularjs.svg?style=flat-square)](https://david-dm.org/homer0/projext-plugin-webpack-angularjs)

Allows you to bundle an [AngularJS](https://angularjs.org) project with [projext](https://yarnpkg.com/en/package/projext) using the [webpack](https://webpack.js.org) [build engine](https://yarnpkg.com/en/package/projext-plugin-webpack).

## Introduction

[projext](https://yarnpkg.com/en/package/projext) allows you to configure a project without adding specific settings for a module bundler, then you can decide which build engine to use. This plugin is meant to be used when you are bundling an [AngularJS](https://angularjs.org) and you are using the [webpack](https://webpack.js.org) [build engine](https://yarnpkg.com/en/package/projext-plugin-webpack).

It adds the [`ng-annotate-loader`](https://yarnpkg.com/en/package/ng-annotate-loader) package to your target configuration and takes care of updating the [`babel-loader`](https://yarnpkg.com/en/package/babel-loader) so the make the target transpilation compatible with the annotations loader.
It adds the [`angularjs-annotate`](https://yarnpkg.com/en/package/babel-plugin-angularjs-annotate) plugin to the [Babel](https://babeljs.io) configuration in order to support AngularJS annotations.

Now you can use the `ngInject` directive on your code to inject your dependencies

Expand Down Expand Up @@ -34,15 +39,14 @@ class MyService {
## Usage

1. You first need the build engine, so install [`projext-plugin-webpack`](https://yarnpkg.com/en/package/projext-plugin-webpack).
2. If you changed it, set your target `engine` setting to `webpack`.
3. Add a new setting to your target named `framework` and set its value to `angularjs`.
4. Done
2. Add a new setting to your target named `framework` and set its value to `angularjs`.
3. Done

Now, when your target gets builded, the plugin will check if the target is using webpack and if the framework is AngularJS, then it will add the required loader and configure the transpilation options.

### Babel

The [`ng-annotate-loader`](https://yarnpkg.com/en/package/ng-annotate-loader) package only works on `function` statements, that's why it needs to update the configuration of the [`babel-loader`](https://yarnpkg.com/en/package/babel-loader) in order to work.
The [`babel-plugin-angularjs-annotate`](https://yarnpkg.com/en/package/babel-plugin-angularjs-annotate) package only works on `function` statements, that's why it needs to update the configuration of the [`babel-preset-env`](https://yarnpkg.com/en/package/babel-preset-env) in order to work.

Let's say you are only supporting the last version of major browsers, well, most of them already support arrow functions and by default they wouldn't be transpiled.

Expand All @@ -52,6 +56,10 @@ If for some reason you are overwriting the [Babel](https://babeljs.io) configura
- `transform-es2015-classes`
- `transform-es2015-parameters`

### External dependencies

When bundling your targets, the plugin will check if the target is for Node or if it is a browser library and automatically exclude the AngularJS package so it doesn't end up on your build.

### Default HTML

If you didn't create an HTML file for your AngularJS app, projext will create one for you and this plugin will take care of updating the contents of that HTML so you can run your app right away.
Expand Down Expand Up @@ -84,18 +92,18 @@ Before doing anything, install the repository hooks:

```bash
# You can either use npm or yarn, it doesn't matter
npm run install-hooks
yarn run hooks
```

### NPM/Yarn Tasks
### Yarn/NPM Tasks

| Task | Description |
|-------------------------|-------------------------------------|
| `npm run install-hooks` | Install the GIT repository hooks. |
| `npm test` | Run the project unit tests. |
| `npm run lint` | Lint the modified files. |
| `npm run lint:full` | Lint the project code. |
| `npm run docs` | Generate the project documentation. |
| `yarn run hooks` | Install the GIT repository hooks. |
| `yarn test` | Run the project unit tests. |
| `yarn run lint` | Lint the modified files. |
| `yarn run lint:full` | Lint the project code. |
| `yarn run docs` | Generate the project documentation. |

### Testing

Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"dependencies": {
"ng-annotate-loader": "0.6.1"
},
"peerDependencies": {

"babel-plugin-angularjs-annotate": "0.9.0"
},
"devDependencies": {
"wootils": "^1.1.1",
"eslint": "4.16.0",
"eslint-config-airbnb-base": "12.1.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-node": "5.2.1",
"babel-preset-env": "1.6.1",
"jest-ex": "4.0.0",
"jest-cli": "22.1.4",
"wootils": "^1.3.2",
"eslint": "4.19.1",
"eslint-config-airbnb-base": "13.0.0",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-node": "6.0.1",
"babel-preset-env": "1.7.0",
"jest-ex": "5.0.0",
"jest-cli": "23.1.0",
"jasmine-expect": "3.8.3",
"esdoc": "1.0.4",
"esdoc": "1.1.0",
"esdoc-standard-plugin": "1.0.0",
"esdoc-node": "1.0.3",
"coveralls": "3.0.0"
"coveralls": "3.0.1"
},
"engine-strict": true,
"engines": {
Expand All @@ -34,7 +31,7 @@
},
"main": "src/index.js",
"scripts": {
"install-hooks": "./utils/hooks/install",
"hooks": "./utils/hooks/install",
"test": "./utils/scripts/test",
"lint": "./utils/scripts/lint",
"lint:full": "./utils/scripts/lint-full",
Expand Down
Loading

0 comments on commit 3499f77

Please sign in to comment.