Skip to content

Commit

Permalink
webpack 3, remove lodash, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdesjardins committed Jul 16, 2017
1 parent 297de78 commit adf9c8e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

'use strict';

var _ = require('lodash');
var fileLoaderPath = require.resolve('file-loader');

function InertEntryPlugin() {}
Expand Down Expand Up @@ -36,7 +35,14 @@ InertEntryPlugin.prototype.apply = function(compiler) {

params.normalModuleFactory.plugin('after-resolve', function(data, callback) {
// match the raw request to one of the entry files
var name = _.findKey(entries, _.matches(data.rawRequest));
var name;
for (var key in entries) {
if (!entries.hasOwnProperty(key)) continue;
if (entries[key] === data.rawRequest) {
name = key;
break;
}
}
if (name) {
// interpolate `[chunkname]` ahead-of-time, so entry chunk names are used correctly
var interpolatedName = originalName.replace(/\[chunkname\]/g, name);
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
},
"homepage": "https://github.com/erikdesjardins/inert-entry-webpack-plugin#readme",
"dependencies": {
"file-loader": "^0.10.0",
"lodash": "^4.6.1"
"file-loader": "^0.11.2"
},
"peerDependencies": {
"webpack": ">=2.2.0"
"webpack": ">=3.0.0"
},
"devDependencies": {
"ava": "^0.18.1",
"extricate-loader": "0.0.2",
"html-loader": "^0.4.3",
"rimraf": "^2.5.2",
"spawn-loader": "0.1.0",
"webpack": "^2.2.1"
"ava": "^0.21.0",
"extricate-loader": "2.0.0",
"html-loader": "^0.4.5",
"rimraf": "^2.6.1",
"spawn-loader": "3.0.0",
"webpack": "^3.3.0"
}
}
12 changes: 6 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ test('single entry chunk', async t => {
});
});

const mainDistHtml = readFileSync(join(out, 'main-dist.html'));
const appDistJs = readFileSync(join(out, 'app-dist.js'));
const mainDistHtml = readFileSync(join(out, 'main-dist.html'), 'utf8');
const appDistJs = readFileSync(join(out, 'app-dist.js'), 'utf8');

t.regex(mainDistHtml, /^<!DOCTYPE html>/, 'no prelude');
t.regex(mainDistHtml, /<script src="app-dist\.js"><\/script>/, 'references app-dist.js');
Expand Down Expand Up @@ -75,10 +75,10 @@ test('multiple entry chunks', async t => {
});
});

const oneDistHtml = readFileSync(join(out, 'one-dist.html'));
const twoDistHtml = readFileSync(join(out, 'two-dist.html'));
const oneDistHtml = readFileSync(join(out, 'one-dist.html'), 'utf8');
const twoDistHtml = readFileSync(join(out, 'two-dist.html'), 'utf8');
const hiDistJpg = readFileSync(join(out, 'hi-dist.jpg'));
const appDistJs = readFileSync(join(out, 'app-dist.js'));
const appDistJs = readFileSync(join(out, 'app-dist.js'), 'utf8');

t.regex(oneDistHtml, /^<!DOCTYPE html>/, 'no prelude');
t.regex(oneDistHtml, /<script src="app-dist\.js"><\/script>/, 'references app-dist.js');
Expand Down Expand Up @@ -117,7 +117,7 @@ test('substituting [name] instead of [chunkname]', async t => {
});
});

const otherDistHtml = readFileSync(join(out, 'other-dist.html'));
const otherDistHtml = readFileSync(join(out, 'other-dist.html'), 'utf8');

t.regex(otherDistHtml, /^<!DOCTYPE html>/, 'no prelude');
t.regex(otherDistHtml, /<img src="hi-dist\.jpg"\/>/, 'references hi-dist.jpg');
Expand Down

0 comments on commit adf9c8e

Please sign in to comment.