Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If there is only one file for named entry, pass it directly #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -90,7 +90,13 @@ module.exports = function (options, wp, done) {
config.watch = !!options.watch;

// Determine pipe'd in entry
if (Object.keys(entries).length > 0) {
var entriesNames = Object.keys(entries);
if (entriesNames.length > 0) {
entriesNames.forEach(function (entryName) {
if (entries[entryName].length === 1) {
entries[entryName] = entries[entryName][0];
}
});
entry = entries;
if (!config.output.filename) {
// Better output default for multiple chunks
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/subdirectory/entry.js
@@ -0,0 +1 @@
var subDirectoryEntry = true;
22 changes: 22 additions & 0 deletions test/test.js
Expand Up @@ -86,6 +86,28 @@ test('stream multiple entry points', function (t) {
entries.pipe(named()).pipe(stream);
});

test('stream multiple entry points, one with two files', function (t) {
t.plan(2);
var entries = fs.src(['test/fixtures/entry.js', 'test/fixtures/anotherentrypoint.js', 'test/fixtures/subdirectory/entry.js']);
var stream = webpack({
config: {},
quiet: true
});
stream.on('data', function (file) {
var basename = path.basename(file.path);
var contents = file.contents.toString();
switch (basename) {
case 'entry.js':
t.ok(/module\.exports = __webpack_require__/i.test(contents), 'should contain "module.exports = __webpack_require__"');
break;
case 'anotherentrypoint.js':
t.notOk(/module\.exports = __webpack_require__/i.test(contents), 'should not contain "module.exports = __webpack_require__"');
break;
}
});
entries.pipe(named()).pipe(stream);
});

test('empty input stream', function (t) {
t.plan(1);

Expand Down