Skip to content

Commit

Permalink
feature #540 Update various dependencies and remove the LoaderOptions…
Browse files Browse the repository at this point in the history
…Plugin (Lyrkan)

This PR was merged into the master branch.

Discussion
----------

Update various dependencies and remove the LoaderOptionsPlugin

This PR updates various dependencies that were either really outdated or subject to security issues.

Since most of those packages are listed in our dev dependencies it shouldn't have a big impact on most users, but the following changes could be an issue for some of them:

* The `css-loader` was updated from `^1.0.0` to `^2.1.1` ([breaking changes](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#200-2018-12-07))
* The `resolve-url-loader` was updated from `^2.3.0` to `^3.0.1` ([breaking changes](https://github.com/bholloway/resolve-url-loader/tree/master/packages/resolve-url-loader#version-3), closes #428 and closes #534)
* The minimum version of NodeJS was bumped from 6 to 8 (needed to update `zombie`, and v6's end-of-life happening in less than a month anyway)
* The [`LoaderOptionsPlugin`](https://webpack.js.org/plugins/loader-options-plugin/) was removed since it should not be needed anymore and caused a *really annoying* bug when used with the latest version of the `resolve-url-loader` (see #428 (comment))

Commits
-------

aeea89b Update various dependencies and remove the LoaderOptionsPlugin
  • Loading branch information
weaverryan committed Mar 25, 2019
2 parents b91f16a + aeea89b commit d2622d0
Show file tree
Hide file tree
Showing 14 changed files with 1,306 additions and 1,921 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Expand Up @@ -3,7 +3,7 @@ cache:
- "%LOCALAPPDATA%\\Yarn"

environment:
nodejs_version: "6"
nodejs_version: "8"

platform:
- x86
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -30,6 +30,9 @@ matrix:
- os: linux
node_js: "10"
env: JOB_PART=travis:lint
- os: linux
node_js: "11"
env: JOB_PART=test
- os: linux
node_js: "10"
env: JOB_PART=test
Expand All @@ -39,8 +42,5 @@ matrix:
- os: linux
node_js: "8"
env: JOB_PART=test
- os: linux
node_js: "6"
env: JOB_PART=test

script: npm run $JOB_PART
27 changes: 8 additions & 19 deletions index.js
Expand Up @@ -164,25 +164,6 @@ class Encore {
return this;
}

/**
* Allows you to configure the options passed to the LoaderOptionsPlugins.
* A list of available options can be found at https://webpack.js.org/plugins/loader-options-plugin/
*
* For example:
*
* Encore.configureLoaderOptionsPlugin((options) => {
* options.minimize = true;
* })
*
* @param {function} loaderOptionsPluginOptionsCallback
* @returns {Encore}
*/
configureLoaderOptionsPlugin(loaderOptionsPluginOptionsCallback = () => {}) {
webpackConfig.configureLoaderOptionsPlugin(loaderOptionsPluginOptionsCallback);

return this;
}

/**
* Allows you to configure the options passed to webpack-manifest-plugin.
* A list of available options can be found at https://github.com/danethurber/webpack-manifest-plugin
Expand Down Expand Up @@ -1297,6 +1278,14 @@ class Encore {
configureUglifyJsPlugin() {
throw new Error('The configureUglifyJsPlugin() method was removed from Encore due to uglify-js dropping ES6+ support in its latest version. Please use configureTerserPlugin() instead.');
}

/**
* @deprecated
* @return {void}
*/
configureLoaderOptionsPlugin() {
throw new Error('The configureLoaderOptionsPlugin() method was removed from Encore. The underlying plugin should not be needed anymore unless you are using outdated loaders. If that\'s the case you can still add it using addPlugin().');
}
}

// Proxy the API in order to prevent calls to most of its methods
Expand Down
9 changes: 0 additions & 9 deletions lib/WebpackConfig.js
Expand Up @@ -123,7 +123,6 @@ class WebpackConfig {
this.definePluginOptionsCallback = () => {};
this.forkedTypeScriptTypesCheckOptionsCallback = () => {};
this.friendlyErrorsPluginOptionsCallback = () => {};
this.loaderOptionsPluginOptionsCallback = () => {};
this.manifestPluginOptionsCallback = () => {};
this.terserPluginOptionsCallback = () => {};
this.optimizeCssPluginOptionsCallback = () => {};
Expand Down Expand Up @@ -222,14 +221,6 @@ class WebpackConfig {
this.friendlyErrorsPluginOptionsCallback = friendlyErrorsPluginOptionsCallback;
}

configureLoaderOptionsPlugin(loaderOptionsPluginOptionsCallback = () => {}) {
if (typeof loaderOptionsPluginOptionsCallback !== 'function') {
throw new Error('Argument 1 to configureLoaderOptionsPlugin() must be a callback function');
}

this.loaderOptionsPluginOptionsCallback = loaderOptionsPluginOptionsCallback;
}

configureManifestPlugin(manifestPluginOptionsCallback = () => {}) {
if (typeof manifestPluginOptionsCallback !== 'function') {
throw new Error('Argument 1 to configureManifestPlugin() must be a callback function');
Expand Down
3 changes: 0 additions & 3 deletions lib/config-generator.js
Expand Up @@ -27,7 +27,6 @@ const miniCssExtractPluginUtil = require('./plugins/mini-css-extract');
const deleteUnusedEntriesPluginUtil = require('./plugins/delete-unused-entries');
const entryFilesManifestPlugin = require('./plugins/entry-files-manifest');
const manifestPluginUtil = require('./plugins/manifest');
const loaderOptionsPluginUtil = require('./plugins/loader-options');
const versioningPluginUtil = require('./plugins/versioning');
const variableProviderPluginUtil = require('./plugins/variable-provider');
const cleanPluginUtil = require('./plugins/clean');
Expand Down Expand Up @@ -409,8 +408,6 @@ class ConfigGenerator {
// Dump the manifest.json file
manifestPluginUtil(plugins, this.webpackConfig);

loaderOptionsPluginUtil(plugins, this.webpackConfig);

versioningPluginUtil(plugins, this.webpackConfig);

variableProviderPluginUtil(plugins, this.webpackConfig);
Expand Down
1 change: 0 additions & 1 deletion lib/loaders/css.js
Expand Up @@ -22,7 +22,6 @@ module.exports = {
const usePostCssLoader = webpackConfig.usePostCssLoader;

const options = {
minimize: webpackConfig.isProduction(),
sourceMap: webpackConfig.useSourceMaps,
// when using @import, how many loaders *before* css-loader should
// be applied to those imports? This defaults to 0. When postcss-loader
Expand Down
45 changes: 0 additions & 45 deletions lib/plugins/loader-options.js

This file was deleted.

20 changes: 10 additions & 10 deletions package.json
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/symfony/webpack-encore/issues"
},
"engines": {
"node": ">=6.0.0"
"node": ">=8.0.0"
},
"homepage": "https://github.com/symfony/webpack-encore",
"dependencies": {
Expand All @@ -32,7 +32,7 @@
"babel-loader": "^8.0.0",
"chalk": "^2.4.1",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^1.0.0",
"css-loader": "^2.1.1",
"fast-levenshtein": "^2.0.6",
"file-loader": "^1.1.10",
"friendly-errors-webpack-plugin": "^1.7.0",
Expand All @@ -43,7 +43,7 @@
"optimize-css-assets-webpack-plugin": "^5.0.1",
"pkg-up": "^1.0.0",
"pretty-error": "^2.1.1",
"resolve-url-loader": "^2.3.0",
"resolve-url-loader": "^3.0.1",
"semver": "^5.5.0",
"style-loader": "^0.21.0",
"terser-webpack-plugin": "^1.1.0",
Expand All @@ -61,21 +61,21 @@
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"autoprefixer": "^8.5.0",
"babel-eslint": "^8.2.1",
"babel-eslint": "^10.0.1",
"chai": "^3.5.0",
"chai-fs": "^1.0.0",
"eslint": "^4.15.0",
"eslint-loader": "^1.9.0",
"eslint": "^5.15.2",
"eslint-loader": "^2.1.2",
"eslint-plugin-header": "^1.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^4.2.2",
"fork-ts-checker-webpack-plugin": "^0.4.1",
"handlebars": "^4.0.11",
"handlebars-loader": "^1.7.0",
"http-server": "^0.9.0",
"less": "^2.7.2",
"http-server": "^0.11.1",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"mocha": "^3.2.0",
"mocha": "^6.0.2",
"node-sass": "^4.5.3",
"postcss-loader": "^3.0.0",
"preact": "^8.2.1",
Expand All @@ -93,7 +93,7 @@
"vue-loader": "^15.0.11",
"vue-template-compiler": "^2.3.4",
"webpack-notifier": "^1.6.0",
"zombie": "^5.0.5"
"zombie": "^6.1.4"
},
"files": [
"lib/",
Expand Down
18 changes: 0 additions & 18 deletions test/WebpackConfig.js
Expand Up @@ -283,24 +283,6 @@ describe('WebpackConfig object', () => {
});
});

describe('configureLoaderOptionsPlugin', () => {
it('Setting callback', () => {
const config = createConfig();
const callback = () => {};
config.configureLoaderOptionsPlugin(callback);

expect(config.loaderOptionsPluginOptionsCallback).to.equal(callback);
});

it('Setting invalid callback argument', () => {
const config = createConfig();

expect(() => {
config.configureLoaderOptionsPlugin('foo');
}).to.throw('Argument 1 to configureLoaderOptionsPlugin() must be a callback function');
});
});

describe('configureManifestPlugin', () => {
it('Setting callback', () => {
const config = createConfig();
Expand Down
9 changes: 0 additions & 9 deletions test/config-generator.js
Expand Up @@ -220,12 +220,6 @@ describe('The config-generator function', () => {
config.enableVersioning(true);

const actualConfig = configGenerator(config);

const loaderOptionsPlugin = findPlugin(webpack.LoaderOptionsPlugin, actualConfig.plugins);
expect(loaderOptionsPlugin.options.debug).to.equal(true);
expect(loaderOptionsPlugin.options.options.context).to.equal('/tmp/context');
expect(loaderOptionsPlugin.options.options.output.path).to.equal('/tmp/output/public-path');

expect(actualConfig.optimization.namedModules).to.be.true;
});

Expand All @@ -239,9 +233,6 @@ describe('The config-generator function', () => {

const actualConfig = configGenerator(config);

const loaderOptionsPlugin = findPlugin(webpack.LoaderOptionsPlugin, actualConfig.plugins);
expect(loaderOptionsPlugin.options.debug).to.equal(false);

const moduleHashedIdsPlugin = findPlugin(webpack.HashedModuleIdsPlugin, actualConfig.plugins);
expect(moduleHashedIdsPlugin).to.not.be.undefined;
expect(actualConfig.optimization.namedModules).to.be.undefined;
Expand Down
9 changes: 0 additions & 9 deletions test/index.js
Expand Up @@ -387,15 +387,6 @@ describe('Public API', () => {

});

describe('configureLoaderOptionsPlugin', () => {

it('should return the API object', () => {
const returnedValue = api.configureLoaderOptionsPlugin(() => {});
expect(returnedValue).to.equal(api);
});

});

describe('configureManifestPlugin', () => {

it('should return the API object', () => {
Expand Down
10 changes: 4 additions & 6 deletions test/loaders/css.js
Expand Up @@ -30,7 +30,6 @@ describe('loaders/css', () => {
const actualLoaders = cssLoader.getLoaders(config);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.sourceMap).to.be.true;
expect(actualLoaders[0].options.minimize).to.be.false;
expect(actualLoaders[0].options.modules).to.be.false;
});

Expand All @@ -42,21 +41,20 @@ describe('loaders/css', () => {
const actualLoaders = cssLoader.getLoaders(config);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.sourceMap).to.be.false;
expect(actualLoaders[0].options.minimize).to.be.true;
expect(actualLoaders[0].options.modules).to.be.false;
});

it('getLoaders() with options callback', () => {
const config = createConfig();

config.configureCssLoader(function(options) {
options.minimize = true;
options.foo = true;
options.url = false;
});

const actualLoaders = cssLoader.getLoaders(config);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.minimize).to.be.true;
expect(actualLoaders[0].options.foo).to.be.true;
expect(actualLoaders[0].options.url).to.be.false;
expect(actualLoaders[0].options.modules).to.be.false;
});
Expand All @@ -65,13 +63,13 @@ describe('loaders/css', () => {
const config = createConfig();

config.configureCssLoader(function(options) {
options.minimize = true;
options.foo = true;
options.url = false;
});

const actualLoaders = cssLoader.getLoaders(config, true);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.minimize).to.be.true;
expect(actualLoaders[0].options.foo).to.be.true;
expect(actualLoaders[0].options.url).to.be.false;
expect(actualLoaders[0].options.modules).to.be.true;
});
Expand Down

0 comments on commit d2622d0

Please sign in to comment.