Skip to content

Commit f89634b

Browse files
committed
Require Node.js 8
1 parent e749f17 commit f89634b

File tree

6 files changed

+47
-64
lines changed

6 files changed

+47
-64
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
3+
- '10'
34
- '8'
4-
- '6'

index.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,16 @@ module.exports = class AddAssetPlugin {
66
this.source = source;
77
}
88

9-
// TODO: For when we target Node.js 8
10-
// apply(compiler) {
11-
// compiler.plugin('emit', async (compilation, cb) => {
12-
// const source = typeof this.source === 'string' ? this.source : await this.source(compilation);
13-
14-
// compilation.assets[this.filePath] = {
15-
// source: () => source,
16-
// size: () => source.length
17-
// };
18-
19-
// cb();
20-
// });
21-
// }
22-
239
apply(compiler) {
24-
compiler.plugin('emit', (compilation, cb) => {
25-
const rawSource = typeof this.source === 'string' ? this.source : this.source(compilation);
10+
compiler.plugin('emit', async (compilation, callback) => {
11+
const source = typeof this.source === 'string' ? this.source : await this.source(compilation);
2612

27-
Promise.resolve(rawSource).then(source => {
28-
compilation.assets[this.filePath] = {
29-
source: () => source,
30-
size: () => source.length
31-
};
13+
compilation.assets[this.filePath] = {
14+
source: () => source,
15+
size: () => source.length
16+
};
3217

33-
cb();
34-
});
18+
callback();
3519
});
3620
}
3721
};

package.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
{
2-
"name": "add-asset-webpack-plugin",
3-
"version": "0.1.0",
4-
"description": "Dynamically add an asset to the webpack graph",
5-
"license": "MIT",
6-
"repository": "sindresorhus/add-asset-webpack-plugin",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=6"
14-
},
15-
"scripts": {
16-
"test": "xo && ava"
17-
},
18-
"files": [
19-
"index.js"
20-
],
21-
"keywords": [
22-
"webpack-plugin",
23-
"webpack",
24-
"add",
25-
"generate",
26-
"create",
27-
"make",
28-
"asset",
29-
"file"
30-
],
31-
"devDependencies": {
32-
"ava": "*",
33-
"pify": "^3.0.0",
34-
"tempy": "^0.2.1",
35-
"webpack": "^3.10.0",
36-
"xo": "*"
37-
}
2+
"name": "add-asset-webpack-plugin",
3+
"version": "0.1.0",
4+
"description": "Dynamically add an asset to the webpack graph",
5+
"license": "MIT",
6+
"repository": "sindresorhus/add-asset-webpack-plugin",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "[email protected]",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=8"
14+
},
15+
"scripts": {
16+
"test": "xo && ava"
17+
},
18+
"files": [
19+
"index.js"
20+
],
21+
"keywords": [
22+
"webpack-plugin",
23+
"webpack",
24+
"add",
25+
"generate",
26+
"create",
27+
"make",
28+
"asset",
29+
"file"
30+
],
31+
"devDependencies": {
32+
"ava": "^1.3.1",
33+
"pify": "^4.0.1",
34+
"tempy": "^0.2.1",
35+
"webpack": "^4.29.6",
36+
"xo": "^0.24.0"
37+
}
3838
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Relative file path for the asset.
3838

3939
#### source
4040

41-
Type: `string` `Function<string|Promise>`
41+
Type: `string` `Function => string | Promise<string>`
4242

4343
Asset source or a function that returns the asset source.
4444

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import webpack from 'webpack';
55
import tempy from 'tempy';
66
import pify from 'pify';
77

8-
test(async t => {
8+
test('main', async t => {
99
const config = require('./fixture/webpack.config');
1010
const cwd = tempy.directory();
1111
config.output.path = cwd;

0 commit comments

Comments
 (0)