Skip to content

Commit 691d662

Browse files
committed
Fix runtime-usage detection logic
Refs #325
1 parent aa7b9b2 commit 691d662

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,15 @@ var OfflinePlugin = (function () {
288288

289289
compiler.plugin('emit', function (compilation, callback) {
290290
var runtimeTemplatePath = _path3['default'].resolve(__dirname, '../tpls/runtime-template.js');
291-
var runtimeFound = undefined;
291+
var hasRuntime = true;
292292

293293
if (compilation.fileDependencies.indexOf) {
294-
runtimeFound = compilation.fileDependencies.indexOf(runtimeTemplatePath) === -1;
294+
hasRuntime = compilation.fileDependencies.indexOf(runtimeTemplatePath) !== -1;
295295
} else if (compilation.fileDependencies.has) {
296-
runtimeFound = compilation.fileDependencies.has(runtimeTemplatePath);
296+
hasRuntime = compilation.fileDependencies.has(runtimeTemplatePath);
297297
}
298298

299-
if (runtimeFound && !_this2.__tests.ignoreRuntime) {
299+
if (!hasRuntime && !_this2.__tests.ignoreRuntime) {
300300
compilation.errors.push(new Error('OfflinePlugin: Plugin\'s runtime wasn\'t added to one of your bundle entries. See this https://goo.gl/YwewYp for details.'));
301301
callback();
302302
return;

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,16 @@ export default class OfflinePlugin {
278278
});
279279

280280
compiler.plugin('emit', (compilation, callback) => {
281-
const runtimeTemplatePath = path.resolve(__dirname, '../tpls/runtime-template.js')
282-
let runtimeFound;
281+
const runtimeTemplatePath = path.resolve(__dirname, '../tpls/runtime-template.js');
282+
let hasRuntime = true;
283283

284284
if (compilation.fileDependencies.indexOf) {
285-
runtimeFound = compilation.fileDependencies.indexOf(runtimeTemplatePath) === -1;
285+
hasRuntime = compilation.fileDependencies.indexOf(runtimeTemplatePath) !== -1;
286286
} else if (compilation.fileDependencies.has) {
287-
runtimeFound = compilation.fileDependencies.has(runtimeTemplatePath);
287+
hasRuntime = compilation.fileDependencies.has(runtimeTemplatePath);
288288
}
289289

290-
if (runtimeFound && !this.__tests.ignoreRuntime) {
290+
if (!hasRuntime && !this.__tests.ignoreRuntime) {
291291
compilation.errors.push(
292292
new Error(`OfflinePlugin: Plugin's runtime wasn't added to one of your bundle entries. See this https://goo.gl/YwewYp for details.`)
293293
);

0 commit comments

Comments
 (0)