Skip to content

Commit 18af83d

Browse files
committed
fix(tests): Upgrade webpack-recompilation-simulator
1 parent bbc07a3 commit 18af83d

File tree

6 files changed

+74
-7342
lines changed

6 files changed

+74
-7342
lines changed

lib/loader.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,24 @@ const _ = require('lodash');
55
const loaderUtils = require('loader-utils');
66

77
module.exports = function (source) {
8-
if (this.cacheable) {
9-
this.cacheable();
10-
}
8+
// Get templating options
9+
const options = this.query !== '' ? loaderUtils.getOptions(this) : {};
10+
const force = options.force || false;
11+
1112
const allLoadersButThisOne = this.loaders.filter(function (loader) {
12-
// Loader API changed from `loader.module` to `loader.normal` in Webpack 2.
13-
return (loader.module || loader.normal) !== module.exports;
13+
return loader.normal !== module.exports;
1414
});
15-
// This loader shouldn't kick in if there is any other loader
16-
if (allLoadersButThisOne.length > 0) {
15+
// This loader shouldn't kick in if there is any other loader (unless it's explicitly enforced)
16+
if (allLoadersButThisOne.length > 0 && !force) {
1717
return source;
1818
}
19-
// Skip .js files
20-
if (/\.js$/.test(this.resourcePath)) {
19+
// Skip .js files (unless it's explicitly enforced)
20+
if (/\.js$/.test(this.resourcePath) && !force) {
2121
return source;
2222
}
2323

2424
// The following part renders the template with lodash as aminimalistic loader
2525
//
26-
// Get templating options
27-
const options = this.query !== '' ? loaderUtils.getOptions(this) : {};
2826
const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' }));
2927
// Require !!lodash - using !! will disable all loaders (e.g. babel)
3028
return 'var _ = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('lodash')) + ');' +

0 commit comments

Comments
 (0)