Skip to content

Commit 2cbaf6b

Browse files
committed
deprecate old versions of node and webpack
Deprecated: node@6 webpack@2 webpack@3
1 parent 0ae7105 commit 2cbaf6b

File tree

5 files changed

+47
-94
lines changed

5 files changed

+47
-94
lines changed

.travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
language: node_js
22
node_js:
3-
- '9'
4-
- '8'
5-
- '6'
3+
- 'node'
4+
- '10'
5+
- '8.3.0'
66

77
env:
8-
- WEBPACK_VERSION=2 EXTRACT_PLUGIN_VERSION=2
9-
- WEBPACK_VERSION=3 EXTRACT_PLUGIN_VERSION=3.0.2
108
- WEBPACK_VERSION=4 EXTRACT_PLUGIN_VERSION=next
119

1210
install:

lib/plugin.js

+14-33
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,11 @@ ManifestPlugin.prototype.apply = function(compiler) {
7676
name = path;
7777
}
7878

79-
// Webpack 4: .isOnlyInitial()
80-
// Webpack 3: .isInitial()
81-
// Webpack 1/2: .initial
8279
return files.concat({
8380
path: path,
8481
chunk: chunk,
8582
name: name,
86-
isInitial: chunk.isOnlyInitial ? chunk.isOnlyInitial() : (chunk.isInitial ? chunk.isInitial() : chunk.initial),
83+
isInitial: chunk.isOnlyInitial(),
8784
isChunk: true,
8885
isAsset: false,
8986
isModuleAsset: false
@@ -169,13 +166,7 @@ ManifestPlugin.prototype.apply = function(compiler) {
169166

170167
var manifest;
171168
if (this.opts.generate) {
172-
const entrypointsArray = Array.from(
173-
compilation.entrypoints instanceof Map ?
174-
// Webpack 4+
175-
compilation.entrypoints.entries() :
176-
// Webpack 3
177-
entries(compilation.entrypoints)
178-
);
169+
const entrypointsArray = Array.from(compilation.entrypoints.entries());
179170
const entrypoints = entrypointsArray.reduce(
180171
(e, [name, entrypoint]) => Object.assign(e, { [name]: entrypoint.getFiles() }),
181172
{}
@@ -222,30 +213,20 @@ ManifestPlugin.prototype.apply = function(compiler) {
222213
}
223214
}
224215

225-
if (compiler.hooks) {
226-
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
227-
const pluginOptions = {
228-
name: 'ManifestPlugin',
229-
stage: Infinity
230-
};
231-
compiler.hooks.webpackManifestPluginAfterEmit = new SyncWaterfallHook(['manifest']);
232-
233-
compiler.hooks.compilation.tap(pluginOptions, function (compilation) {
234-
compilation.hooks.moduleAsset.tap(pluginOptions, moduleAsset);
235-
});
236-
compiler.hooks.emit.tap(pluginOptions, emit);
216+
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
217+
const pluginOptions = {
218+
name: 'ManifestPlugin',
219+
stage: Infinity
220+
};
221+
compiler.hooks.webpackManifestPluginAfterEmit = new SyncWaterfallHook(['manifest']);
237222

238-
compiler.hooks.run.tap(pluginOptions, beforeRun);
239-
compiler.hooks.watchRun.tap(pluginOptions, beforeRun);
240-
} else {
241-
compiler.plugin('compilation', function (compilation) {
242-
compilation.plugin('module-asset', moduleAsset);
243-
});
244-
compiler.plugin('emit', emit);
223+
compiler.hooks.compilation.tap(pluginOptions, function (compilation) {
224+
compilation.hooks.moduleAsset.tap(pluginOptions, moduleAsset);
225+
});
226+
compiler.hooks.emit.tap(pluginOptions, emit);
245227

246-
compiler.plugin('before-run', beforeRun);
247-
compiler.plugin('watch-run', beforeRun);
248-
}
228+
compiler.hooks.run.tap(pluginOptions, beforeRun);
229+
compiler.hooks.watchRun.tap(pluginOptions, beforeRun);
249230
};
250231

251232
module.exports = ManifestPlugin;

package.json

+18-15
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
"node": ">=6.11.5"
1414
},
1515
"peerDependencies": {
16-
"webpack": "2 || 3 || 4"
16+
"webpack": "4"
1717
},
1818
"devDependencies": {
19-
"codecov": "^3.1.0",
20-
"css-loader": "^1.0.0",
21-
"extract-text-webpack-plugin": "^3.0.2",
22-
"file-loader": "^2.0.0",
23-
"jest": "^23.5.0",
19+
"@svgr/webpack": "^4.3.3",
20+
"codecov": "^3.6.1",
21+
"css-loader": "^3.2.0",
22+
"extract-text-webpack-plugin": "4.0.0-beta.0",
23+
"file-loader": "^4.2.0",
24+
"jest": "^24.9.0",
2425
"memory-fs": "^0.4.1",
25-
"react": "^16.3.2",
26-
"rimraf": "^2.6.1",
27-
"style-loader": "^0.23.0",
28-
"svgr": "^1.9.2",
29-
"webpack": "^3.12.0"
26+
"react": "^16.9.0",
27+
"rimraf": "^3.0.0",
28+
"style-loader": "^1.0.0",
29+
"webpack": "^4.41.0"
3030
},
3131
"files": [
3232
"index.js",
@@ -41,14 +41,17 @@
4141
},
4242
"homepage": "https://github.com/danethurber/webpack-manifest-plugin",
4343
"dependencies": {
44-
"fs-extra": "^7.0.0",
45-
"lodash": ">=3.5 <5",
44+
"fs-extra": "^8.1.0",
45+
"lodash": "^4",
4646
"object.entries": "^1.1.0",
47-
"tapable": "^1.0.0"
47+
"tapable": "^1.1.3"
4848
},
4949
"jest": {
5050
"testEnvironment": "node",
5151
"coverageDirectory": "./coverage/",
52-
"collectCoverage": true
52+
"collectCoverage": true,
53+
"coveragePathIgnorePatterns": [
54+
"<rootDir>/spec/helpers/"
55+
]
5356
}
5457
}

spec/plugin.integration.spec.js

+5-16
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ var rimraf = require('rimraf');
88

99
var ManifestPlugin = require('../index.js');
1010

11-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5 * 60 * 1000;
12-
13-
const isWebpack4 = (yes, no) => webpack.version && webpack.version.slice(0, 1) === '4' ? yes : no;
14-
1511
function webpackConfig(webpackOpts, opts) {
1612
return _.merge({
1713
plugins: [
@@ -221,26 +217,19 @@ describe('ManifestPlugin using real fs', function() {
221217
expect(manifest).toBeDefined();
222218

223219
if (isFirstRun) {
224-
expect(manifest).toEqual(isWebpack4({
220+
expect(manifest).toEqual({
225221
'main.js': 'main.js',
226222
'1.js': '1.js',
227223
'2.js': '2.js'
228-
}, {
229-
'main.js': 'main.js',
230-
'0.js': '0.js',
231-
'1.js': '1.js'
232-
}));
224+
});
233225

234226
isFirstRun = false;
235227
fse.outputFileSync(path.join(__dirname, 'output/watch-import-chunk/index.js'), 'import(\'./chunk1\')');
236228
} else {
237-
expect(manifest).toEqual(isWebpack4({
229+
expect(manifest).toEqual({
238230
'main.js': 'main.js',
239231
'1.js': '1.js',
240-
}, {
241-
'main.js': 'main.js',
242-
'3.js': '3.js',
243-
}));
232+
});
244233

245234
done();
246235
}
@@ -467,7 +456,7 @@ describe('scoped hoisting', function() {
467456
rules: [
468457
{
469458
test: /\.svg$/,
470-
use: ['svgr/webpack', 'file-loader']
459+
use: ['@svgr/webpack', 'file-loader']
471460
},
472461
],
473462
},

spec/plugin.spec.js

+7-25
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ var plugin = require('../index.js');
1010
var OUTPUT_DIR = path.join(__dirname, './webpack-out');
1111
var manifestPath = path.join(OUTPUT_DIR, 'manifest.json');
1212

13-
const isWebpack4 = (yes, no) => webpack.version && webpack.version.slice(0, 1) === '4' ? yes : no;
14-
1513
function webpackConfig (webpackOpts, opts) {
1614
return _.merge({
1715
output: {
@@ -39,7 +37,7 @@ function webpackCompile(webpackOpts, opts, cb) {
3937

4038
var fs = compiler.outputFileSystem = new MemoryFileSystem();
4139

42-
compiler.run(function(err, stats){
40+
compiler.run(function(err, stats) {
4341
var manifestFile
4442
try {
4543
manifestFile = JSON.parse( fs.readFileSync(manifestPath).toString() );
@@ -342,7 +340,7 @@ describe('ManifestPlugin', function() {
342340
webpackCompile({
343341
context: __dirname,
344342
entry: './fixtures/file.txt',
345-
module: isWebpack4({
343+
module: {
346344
rules: [{
347345
test: /\.(txt)/,
348346
use: [{
@@ -352,11 +350,7 @@ describe('ManifestPlugin', function() {
352350
}
353351
}]
354352
}]
355-
}, {
356-
loaders: [
357-
{ test: /\.(txt)/, loader: 'file-loader?name=file.[ext]' },
358-
]
359-
})
353+
}
360354
}, {}, function(manifest, stats) {
361355
expect(manifest).toBeDefined();
362356
expect(manifest).toEqual({
@@ -372,7 +366,7 @@ describe('ManifestPlugin', function() {
372366
webpackCompile({
373367
context: __dirname,
374368
entry: './fixtures/file.txt',
375-
module: isWebpack4({
369+
module: {
376370
rules: [{
377371
test: /\.(txt)/,
378372
use: [{
@@ -382,11 +376,7 @@ describe('ManifestPlugin', function() {
382376
}
383377
}]
384378
}]
385-
}, {
386-
loaders: [
387-
{ test: /\.(txt)/, loader: 'file-loader?name=outputfile.[ext]' },
388-
]
389-
})
379+
}
390380
}, {}, function(manifest, stats) {
391381
expect(manifest).toBeDefined();
392382
expect(manifest).toEqual({
@@ -447,23 +437,15 @@ describe('ManifestPlugin', function() {
447437
output: {
448438
filename: '[name].js'
449439
},
450-
module: isWebpack4({
440+
module: {
451441
rules: [{
452442
test: /\.css$/,
453443
use: ExtractTextPlugin.extract({
454444
fallback: 'style-loader',
455445
use: 'css-loader'
456446
})
457447
}]
458-
}, {
459-
loaders: [{
460-
test: /\.css$/,
461-
loader: ExtractTextPlugin.extract({
462-
fallback: 'style-loader',
463-
use: 'css-loader'
464-
})
465-
}]
466-
}),
448+
},
467449
plugins: [
468450
new plugin(),
469451
new ExtractTextPlugin({

0 commit comments

Comments
 (0)