Skip to content

Commit

Permalink
deprecate old versions of node and webpack
Browse files Browse the repository at this point in the history
Deprecated:
node@6
webpack@2
webpack@3
  • Loading branch information
mastilver committed Sep 25, 2019
1 parent 485e37c commit a60e731
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 94 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
language: node_js
node_js:
- '9'
- '8'
- '6'
- 'node'
- '10'
- '8.3.0'

env:
- WEBPACK_VERSION=2 EXTRACT_PLUGIN_VERSION=2
- WEBPACK_VERSION=3 EXTRACT_PLUGIN_VERSION=3.0.2
- WEBPACK_VERSION=4 EXTRACT_PLUGIN_VERSION=next

install:
Expand Down
47 changes: 14 additions & 33 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ ManifestPlugin.prototype.apply = function(compiler) {
name = path;
}

// Webpack 4: .isOnlyInitial()
// Webpack 3: .isInitial()
// Webpack 1/2: .initial
return files.concat({
path: path,
chunk: chunk,
name: name,
isInitial: chunk.isOnlyInitial ? chunk.isOnlyInitial() : (chunk.isInitial ? chunk.isInitial() : chunk.initial),
isInitial: chunk.isOnlyInitial(),
isChunk: true,
isAsset: false,
isModuleAsset: false
Expand Down Expand Up @@ -162,13 +159,7 @@ ManifestPlugin.prototype.apply = function(compiler) {

var manifest;
if (this.opts.generate) {
const entrypointsArray = Array.from(
compilation.entrypoints instanceof Map ?
// Webpack 4+
compilation.entrypoints.entries() :
// Webpack 3
entries(compilation.entrypoints)
);
const entrypointsArray = Array.from(compilation.entrypoints.entries());
const entrypoints = entrypointsArray.reduce(
(e, [name, entrypoint]) => Object.assign(e, { [name]: entrypoint.getFiles() }),
{}
Expand Down Expand Up @@ -215,30 +206,20 @@ ManifestPlugin.prototype.apply = function(compiler) {
}
}

if (compiler.hooks) {
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
const pluginOptions = {
name: 'ManifestPlugin',
stage: Infinity
};
compiler.hooks.webpackManifestPluginAfterEmit = new SyncWaterfallHook(['manifest']);

compiler.hooks.compilation.tap(pluginOptions, function (compilation) {
compilation.hooks.moduleAsset.tap(pluginOptions, moduleAsset);
});
compiler.hooks.emit.tap(pluginOptions, emit);
const SyncWaterfallHook = require('tapable').SyncWaterfallHook;
const pluginOptions = {
name: 'ManifestPlugin',
stage: Infinity
};
compiler.hooks.webpackManifestPluginAfterEmit = new SyncWaterfallHook(['manifest']);

compiler.hooks.run.tap(pluginOptions, beforeRun);
compiler.hooks.watchRun.tap(pluginOptions, beforeRun);
} else {
compiler.plugin('compilation', function (compilation) {
compilation.plugin('module-asset', moduleAsset);
});
compiler.plugin('emit', emit);
compiler.hooks.compilation.tap(pluginOptions, function (compilation) {
compilation.hooks.moduleAsset.tap(pluginOptions, moduleAsset);
});
compiler.hooks.emit.tap(pluginOptions, emit);

compiler.plugin('before-run', beforeRun);
compiler.plugin('watch-run', beforeRun);
}
compiler.hooks.run.tap(pluginOptions, beforeRun);
compiler.hooks.watchRun.tap(pluginOptions, beforeRun);
};

module.exports = ManifestPlugin;
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
"node": ">=6.11.5"
},
"peerDependencies": {
"webpack": "2 || 3 || 4"
"webpack": "4"
},
"devDependencies": {
"codecov": "^3.1.0",
"css-loader": "^1.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^2.0.0",
"jest": "^23.5.0",
"@svgr/webpack": "^4.3.3",
"codecov": "^3.6.1",
"css-loader": "^3.2.0",
"extract-text-webpack-plugin": "4.0.0-beta.0",
"file-loader": "^4.2.0",
"jest": "^24.9.0",
"memory-fs": "^0.4.1",
"react": "^16.3.2",
"rimraf": "^2.6.1",
"style-loader": "^0.23.0",
"svgr": "^1.9.2",
"webpack": "^3.12.0"
"react": "^16.9.0",
"rimraf": "^3.0.0",
"style-loader": "^1.0.0",
"webpack": "^4.41.0"
},
"files": [
"index.js",
Expand All @@ -41,14 +41,17 @@
},
"homepage": "https://github.com/danethurber/webpack-manifest-plugin",
"dependencies": {
"fs-extra": "^7.0.0",
"lodash": ">=3.5 <5",
"fs-extra": "^8.1.0",
"lodash": "^4",
"object.entries": "^1.1.0",
"tapable": "^1.0.0"
"tapable": "^1.1.3"
},
"jest": {
"testEnvironment": "node",
"coverageDirectory": "./coverage/",
"collectCoverage": true
"collectCoverage": true,
"coveragePathIgnorePatterns": [
"<rootDir>/spec/helpers/"
]
}
}
21 changes: 5 additions & 16 deletions spec/plugin.integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ var rimraf = require('rimraf');

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

jasmine.DEFAULT_TIMEOUT_INTERVAL = 5 * 60 * 1000;

const isWebpack4 = (yes, no) => webpack.version && webpack.version.slice(0, 1) === '4' ? yes : no;

function webpackConfig(webpackOpts, opts) {
return _.merge({
plugins: [
Expand Down Expand Up @@ -221,26 +217,19 @@ describe('ManifestPlugin using real fs', function() {
expect(manifest).toBeDefined();

if (isFirstRun) {
expect(manifest).toEqual(isWebpack4({
expect(manifest).toEqual({
'main.js': 'main.js',
'1.js': '1.js',
'2.js': '2.js'
}, {
'main.js': 'main.js',
'0.js': '0.js',
'1.js': '1.js'
}));
});

isFirstRun = false;
fse.outputFileSync(path.join(__dirname, 'output/watch-import-chunk/index.js'), 'import(\'./chunk1\')');
} else {
expect(manifest).toEqual(isWebpack4({
expect(manifest).toEqual({
'main.js': 'main.js',
'1.js': '1.js',
}, {
'main.js': 'main.js',
'3.js': '3.js',
}));
});

done();
}
Expand Down Expand Up @@ -467,7 +456,7 @@ describe('scoped hoisting', function() {
rules: [
{
test: /\.svg$/,
use: ['svgr/webpack', 'file-loader']
use: ['@svgr/webpack', 'file-loader']
},
],
},
Expand Down
32 changes: 7 additions & 25 deletions spec/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var plugin = require('../index.js');
var OUTPUT_DIR = path.join(__dirname, './webpack-out');
var manifestPath = path.join(OUTPUT_DIR, 'manifest.json');

const isWebpack4 = (yes, no) => webpack.version && webpack.version.slice(0, 1) === '4' ? yes : no;

function webpackConfig (webpackOpts, opts) {
return _.merge({
output: {
Expand Down Expand Up @@ -39,7 +37,7 @@ function webpackCompile(webpackOpts, opts, cb) {

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

compiler.run(function(err, stats){
compiler.run(function(err, stats) {
var manifestFile
try {
manifestFile = JSON.parse( fs.readFileSync(manifestPath).toString() );
Expand Down Expand Up @@ -342,7 +340,7 @@ describe('ManifestPlugin', function() {
webpackCompile({
context: __dirname,
entry: './fixtures/file.txt',
module: isWebpack4({
module: {
rules: [{
test: /\.(txt)/,
use: [{
Expand All @@ -352,11 +350,7 @@ describe('ManifestPlugin', function() {
}
}]
}]
}, {
loaders: [
{ test: /\.(txt)/, loader: 'file-loader?name=file.[ext]' },
]
})
}
}, {}, function(manifest, stats) {
expect(manifest).toBeDefined();
expect(manifest).toEqual({
Expand All @@ -372,7 +366,7 @@ describe('ManifestPlugin', function() {
webpackCompile({
context: __dirname,
entry: './fixtures/file.txt',
module: isWebpack4({
module: {
rules: [{
test: /\.(txt)/,
use: [{
Expand All @@ -382,11 +376,7 @@ describe('ManifestPlugin', function() {
}
}]
}]
}, {
loaders: [
{ test: /\.(txt)/, loader: 'file-loader?name=outputfile.[ext]' },
]
})
}
}, {}, function(manifest, stats) {
expect(manifest).toBeDefined();
expect(manifest).toEqual({
Expand Down Expand Up @@ -447,23 +437,15 @@ describe('ManifestPlugin', function() {
output: {
filename: '[name].js'
},
module: isWebpack4({
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
}]
}, {
loaders: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
}]
}),
},
plugins: [
new plugin(),
new ExtractTextPlugin({
Expand Down

0 comments on commit a60e731

Please sign in to comment.