Skip to content

Commit

Permalink
Update WebpackManifestPlugin to v3.0.0 and vue-loader to v16.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrkan committed Dec 3, 2020
1 parent 9af90ee commit 4f6171b
Show file tree
Hide file tree
Showing 6 changed files with 1,150 additions and 2,752 deletions.
10 changes: 7 additions & 3 deletions lib/plugins/manifest.js
Expand Up @@ -10,7 +10,7 @@
'use strict';

const WebpackConfig = require('../WebpackConfig'); //eslint-disable-line no-unused-vars
const ManifestPlugin = require('webpack-manifest-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const PluginPriorities = require('./plugin-priorities');
const applyOptionsCallback = require('../utils/apply-options-callback');
const copyEntryTmpName = require('../utils/copyEntryTmpName');
Expand All @@ -28,12 +28,16 @@ module.exports = function(plugins, webpackConfig) {
// always write a manifest.json file, even with webpack-dev-server
writeToFileEmit: true,
filter: (file) => {
return (!file.isChunk || copyEntryTmpName !== file.chunk.id);
const isCopyEntry = file.isChunk && copyEntryTmpName === file.chunk.id;
const isStyleEntry = file.isChunk && webpackConfig.styleEntries.has(file.chunk.name);
const isJsOrJsMapFile = /\.js(\.map)?$/.test(file.name);

return !isCopyEntry && !(isStyleEntry && isJsOrJsMapFile);
}
};

plugins.push({
plugin: new ManifestPlugin(
plugin: new WebpackManifestPlugin(
applyOptionsCallback(webpackConfig.manifestPluginOptionsCallback, manifestPluginOptions)
),
priority: PluginPriorities.WebpackManifestPlugin
Expand Down
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/symfony/webpack-encore/issues"
},
"engines": {
"node": "^10.13.0 || >=12.0.0"
"node": "^10.22.1 || >=12.0.0"
},
"homepage": "https://github.com/symfony/webpack-encore",
"dependencies": {
Expand Down Expand Up @@ -49,7 +49,7 @@
"webpack": "^5",
"webpack-cli": "^4",
"webpack-dev-server": "^3.1.14",
"webpack-manifest-plugin": "^3.0.0-rc",
"webpack-manifest-plugin": "^3",
"webpack-sources": "^1.3.0",
"webpack-virtual-modules": "^0.2.2",
"yargs-parser": "^18.1.3"
Expand All @@ -59,9 +59,9 @@
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@symfony/mock-module": "file:fixtures/stimulus/mock-module",
"@symfony/controllers": "file:fixtures/stimulus/controllers",
"@symfony/autoimport": "file:fixtures/stimulus/autoimport",
"@symfony/controllers": "file:fixtures/stimulus/controllers",
"@symfony/mock-module": "file:fixtures/stimulus/mock-module",
"@symfony/stimulus-bridge": "^1.0.0",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
"@vue/babel-preset-jsx": "^1.0.0-beta.3",
Expand Down Expand Up @@ -100,7 +100,7 @@
"typescript": ">=3.6.3",
"url-loader": "^4.1.0",
"vue": "^3.0.2",
"vue-loader": "^16.0.0-rc.2",
"vue-loader": "^16.1.0",
"vue-template-compiler": "^2.5",
"webpack-notifier": "^1.6.0",
"zombie": "^6.1.4"
Expand Down
14 changes: 7 additions & 7 deletions test/config-generator.js
Expand Up @@ -14,7 +14,7 @@ const WebpackConfig = require('../lib/WebpackConfig');
const RuntimeConfig = require('../lib/config/RuntimeConfig');
const configGenerator = require('../lib/config-generator');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
Expand Down Expand Up @@ -157,10 +157,10 @@ describe('The config-generator function', () => {
const actualConfig = configGenerator(config);

expect(actualConfig.output.publicPath).to.equal('/build/');
const manifestPlugin = findPlugin(ManifestPlugin, actualConfig.plugins);
const manifestPlugin = findPlugin(WebpackManifestPlugin, actualConfig.plugins);
// basePath matches publicPath, *without* the opening slash
// we do that by convention: keys do not start with /
expect(manifestPlugin.opts.basePath).to.equal('build/');
expect(manifestPlugin.options.basePath).to.equal('build/');
});

it('when manifestKeyPrefix is set, that is used instead', () => {
Expand All @@ -174,10 +174,10 @@ describe('The config-generator function', () => {
const actualConfig = configGenerator(config);

expect(actualConfig.output.publicPath).to.equal('/subdirectory/build/');
const manifestPlugin = findPlugin(ManifestPlugin, actualConfig.plugins);
const manifestPlugin = findPlugin(WebpackManifestPlugin, actualConfig.plugins);
// base path matches manifestKeyPrefix + trailing slash
// the opening slash is kept, since the user is overriding this setting
expect(manifestPlugin.opts.basePath).to.equal('/build/');
expect(manifestPlugin.options.basePath).to.equal('/build/');
});

it('manifestKeyPrefix can be empty', () => {
Expand All @@ -189,8 +189,8 @@ describe('The config-generator function', () => {

const actualConfig = configGenerator(config);

const manifestPlugin = findPlugin(ManifestPlugin, actualConfig.plugins);
expect(manifestPlugin.opts.basePath).to.equal('');
const manifestPlugin = findPlugin(WebpackManifestPlugin, actualConfig.plugins);
expect(manifestPlugin.options.basePath).to.equal('');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/functional.js
Expand Up @@ -478,7 +478,7 @@ describe('Functional tests using webpack', function() {

it('With source maps in production mode', (done) => {
const config = createWebpackConfig('web', 'production');
config.addEntry('main', './js/no_require');
config.addEntry('main', './js/arrow_function');
config.setPublicPath('/');
config.addStyleEntry('styles', './css/h1_style.css');
config.enableSourceMaps(true);
Expand Down
16 changes: 8 additions & 8 deletions test/plugins/manifest.js
Expand Up @@ -10,7 +10,7 @@
'use strict';

const expect = require('chai').expect;
const ManifestPlugin = require('webpack-manifest-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const WebpackConfig = require('../../lib/WebpackConfig');
const RuntimeConfig = require('../../lib/config/RuntimeConfig');
const manifestPluginUtil = require('../../lib/plugins/manifest');
Expand All @@ -32,8 +32,8 @@ describe('plugins/manifest', () => {

manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(ManifestPlugin);
expect(plugins[0].plugin.opts.fileName).to.equal('manifest.json');
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);
expect(plugins[0].plugin.options.fileName).to.equal('manifest.json');
});

it('with options callback', () => {
Expand All @@ -46,10 +46,10 @@ describe('plugins/manifest', () => {

manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(ManifestPlugin);
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);

// Allows to override default options
expect(plugins[0].plugin.opts.fileName).to.equal('bar');
expect(plugins[0].plugin.options.fileName).to.equal('bar');
});

it('with options callback that returns an object', () => {
Expand All @@ -65,8 +65,8 @@ describe('plugins/manifest', () => {

manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(ManifestPlugin);
expect(plugins[0].plugin.opts.fileName).to.equal('manifest.json');
expect(plugins[0].plugin.opts.foo).to.equal(true);
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);
expect(plugins[0].plugin.options.fileName).to.equal('manifest.json');
expect(plugins[0].plugin.options.foo).to.equal(true);
});
});

0 comments on commit 4f6171b

Please sign in to comment.