Skip to content

Commit f5df528

Browse files
committed
Merge pull request #2 from akim-mcmath/next
v2.0.0
2 parents 6398db3 + 60e877a commit f5df528

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+315
-475
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
],
5+
"plugins": [
6+
"add-module-exports"
7+
]
8+
}

.eslintrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: eslint:recommended
2+
parserOptions:
3+
ecmaVersion: 6
4+
sourceType: module
5+
env:
6+
node: true
7+
mocha: true

.gitignore

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
.DS_Store
2-
logs
3-
*.log
4-
pids
5-
*.pid
6-
*.seed
7-
lib-cov
8-
coverage
9-
.lock-wscript
10-
npm-debug.log*
11-
node_modules
1+
/coverage/
2+
/lib/
3+
/node_modules/
4+
/npm-debug.log
5+
.tmp

.jscsrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/coverage/
2+
/src/
3+
/test/
4+
/.babelrc
5+
/.editorconfig
6+
/.eslintrc.yml
7+
/.gitignore
8+
/.travis.yml

.travis.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
language: node_js
22
node_js:
3-
- "stable"
4-
- "5.0"
5-
- "4.0"
3+
- "6"
4+
- "5"
5+
- "4"
66
- "0.12"
77
- "0.10"
8-
after_script:
8+
after_success:
99
- npm run coveralls
10-
branches:
11-
only:
12-
- master
10+
before_deploy:
11+
- npm run build
12+
deploy:
13+
provider: npm
14+
email:
15+
secure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VxTmXKs+gKynJuEf7T9xIgunIuzDOFZR/OflT1qySQoVGeYBJCjYeG2IA0hIVcnVHmYBybVuw6ut5A1N5fORxVS+yToJRfR8IrU6dmuhd61nffoAPJ81TzOvcGIldKuN0g6wfc40EaJQr+QZgUvBPp72jffajP0DviQ3RBx0y3ktikqvetm0TuXc9FzLEkjBKJY4r2BKahTcqv9YyPI4Ui9vNvjaD2VG4Qa7HtsUNi342/uaVnRMf24/VI/UOkhgI8e2DDKH35RucLK0sxrEEUfTwqNM2jhBuNQHA+BDpyAg=
18+
skip_cleanup: true
19+
on:
20+
repo: akim-mcmath/ejs-html-loader
21+
node: "4"
22+
tags: true
23+
after_deploy:
24+
- npm run unbuild

CHANGELOG.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

LICENSE.txt renamed to LICENSE

File renamed without changes.

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,38 @@
66
[![Coverage][coverage-badge]][coveralls]
77
[![Dependencies][dependencies-badge]][gemnasium]
88

9-
A [Webpack][webpack] loader for rendering plain HTML from [EJS][ejs]
10-
template files.
9+
[Webpack][webpack] loader for rendering plain HTML from [EJS][ejs]
10+
template files
1111

1212
## Install
1313

14-
Install via [npm][npm]:
14+
Install with [npm][npm]. And be sure to install [EJS][ejs] and
15+
[Webpack][webpack], which are peer dependencies.
1516

1617
```sh
17-
npm install --save-dev ejs-html-loader
18+
npm install --save-dev webpack ejs ejs-html-loader
1819
```
1920

2021
## Usage
2122

22-
Options and locals may be set via query string or query object:
23+
In your Webpack [configuration][webpack-configuration], options and locals can
24+
be passed to EJS in two ways. First, through a query string or query object:
2325

2426
```js
25-
// webpack.config.js
26-
2727
module.exports = {
2828
// ...
2929
module: {
30-
loaders: [
31-
{
32-
test: /\.ejs$/,
33-
loader: 'ejs-html?title=The%20Big%20Gatsby&production'
34-
}
35-
]
30+
loaders: [{
31+
test: /\.ejs$/,
32+
loader: 'ejs-html?title=The%20Big%20Gatsby&production'
33+
}]
3634
}
3735
};
3836
```
3937

40-
Or they may be set in the `ejsHtml` or `ejsHtmlLoader` property of your
41-
Webpack configuration:
38+
Or second, via an `'ejsHtml'` property:
4239

4340
```js
44-
// webpack.config.js
45-
4641
module.exports = {
4742
// ...
4843
ejsHtml: {
@@ -88,9 +83,10 @@ Copyright © 2016 Akim McMath. Licensed under the [MIT License][license].
8883
[dependencies-badge]: https://img.shields.io/gemnasium/akim-mcmath/ejs-html-loader.svg?style=flat-square
8984

9085
[npm]: https://www.npmjs.com/package/ejs-html-loader
91-
[license]: LICENSE.txt
86+
[license]: LICENSE
9287
[travis]: https://travis-ci.org/akim-mcmath/ejs-html-loader
9388
[coveralls]: https://coveralls.io/github/akim-mcmath/ejs-html-loader?branch=master
9489
[gemnasium]: https://gemnasium.com/akim-mcmath/ejs-html-loader
9590
[webpack]: https://webpack.github.io/
91+
[webpack-configuration]: https://webpack.github.io/docs/configuration.html
9692
[ejs]: http://ejs.co/

index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/dependencies.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/ejs-html-loader.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

package.json

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
{
22
"name": "ejs-html-loader",
3-
"version": "1.2.2",
3+
"version": "2.0.0",
44
"description": "Webpack loader for rendering HTML from EJS templates",
5-
"main": "index.js",
6-
"files": [
7-
"lib",
8-
"index.js",
9-
"README.md",
10-
"LICENSE.txt"
11-
],
5+
"main": "lib/index.js",
126
"scripts": {
13-
"test": "npm run jshint && npm run jscs && npm run mocha",
14-
"jshint": "jshint . --exclude-path .gitignore",
15-
"jscs": "jscs .",
16-
"mocha": "istanbul cover _mocha",
17-
"clean": "rm -rf ./node_modules ./coverage",
18-
"coverage": "npm test && open ./coverage/lcov-report/index.html",
19-
"coveralls": "cat ./coverage/lcov.info | coveralls",
20-
"preversion": "npm run test"
7+
"build": "npm run unbuild && babel src -d lib",
8+
"unbuild": "rimraf lib",
9+
"test:lint": "eslint lib test",
10+
"test:unit": "istanbul cover _mocha -- test/index.coffee",
11+
"test:report": "npm run test:unit && open coverage/lcov-report/index.html",
12+
"test": "npm run test:lint && npm run test:unit",
13+
"coveralls": "cat coverage/lcov.info | coveralls"
2114
},
2215
"engines": {
2316
"node": ">=0.10"
@@ -42,21 +35,27 @@
4235
},
4336
"homepage": "https://github.com/akim-mcmath/ejs-html-loader#readme",
4437
"peerDependencies": {
45-
"webpack": "1.x - 2.x"
38+
"webpack": "1.x - 2.x",
39+
"ejs": "2.x"
4640
},
4741
"dependencies": {
48-
"ejs": "^2.0.2",
49-
"loader-utils": "^0.2.0"
42+
"loader-utils": "^0.2.15"
5043
},
5144
"devDependencies": {
45+
"babel-plugin-add-module-exports": "^0.2.1",
46+
"babel-preset-es2015": "^6.9.0",
47+
"babel-register": "^6.9.0",
48+
"bluebird": "^3.4.0",
5249
"chai": "^3.5.0",
53-
"coveralls": "^2.11.6",
50+
"coffee-script": "^1.10.0",
51+
"coveralls": "^2.11.9",
52+
"ejs": "^2.4.2",
53+
"eslint": "^2.11.1",
5454
"file-loader": "^0.8.5",
55-
"istanbul": "^0.4.2",
56-
"jscs": "^2.9.0",
57-
"jshint": "^2.9.1",
58-
"mocha": "^2.4.5",
59-
"rimraf": "^2.5.1",
55+
"istanbul": "1.0.0-alpha.2",
56+
"mocha": "^2.5.3",
57+
"relative-path-map": "^1.0.1",
58+
"rimraf": "^2.5.2",
6059
"webpack": "^1.12.13"
6160
}
6261
}

src/cache.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const cache = {};
2+
3+
export function addDependencies(ctx) {
4+
add(ctx, get(ctx));
5+
}
6+
7+
export function saveDependencies(ctx, deps) {
8+
add(ctx, save(ctx, deps));
9+
}
10+
11+
function get(ctx) {
12+
return cache[ctx.resourcePath] || [];
13+
}
14+
15+
function save(ctx, deps=[]) {
16+
cache[ctx.resourcePath] = deps;
17+
return get(ctx);
18+
}
19+
20+
function add(ctx, deps) {
21+
deps.forEach(name => {
22+
ctx.addDependency(name);
23+
});
24+
}

0 commit comments

Comments
 (0)