diff --git a/README.md b/README.md index 6177c76..aea5c82 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # aurelia-webpack-plugin [![npm Version](https://img.shields.io/npm/v/aurelia-webpack-plugin.svg)](https://www.npmjs.com/package/aurelia-webpack-plugin) -[![ZenHub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) [![Join the chat at https://gitter.im/aurelia/discuss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aurelia/discuss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains a Webpack plugin designed to enable proper Webpack bundling. -> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards. +> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs). ## Installation diff --git a/dist/AureliaPlugin.js b/dist/AureliaPlugin.js index 7be74b7..9ab906e 100644 --- a/dist/AureliaPlugin.js +++ b/dist/AureliaPlugin.js @@ -170,16 +170,32 @@ class AureliaPlugin { addEntry(options, modules) { let webpackEntry = options.entry; let entries = Array.isArray(modules) ? modules : [modules]; - if (typeof webpackEntry == "object" && !Array.isArray(webpackEntry)) { - // There are multiple entries defined in the config - // Unless there was a particular configuration, we modify the first one - // (note that JS enumerates props in the same order they were declared) - // Modifying the first one only plays nice with the common pattern - // `entry: { main, vendor }` some people use. - let ks = this.options.entry || Object.keys(webpackEntry)[0]; - if (!Array.isArray(ks)) - ks = [ks]; - ks.forEach(k => webpackEntry[k] = entries.concat(webpackEntry[k])); + if (typeof webpackEntry === "object" && !Array.isArray(webpackEntry)) { + if (this.options.entry) { + // Add runtime only to the entries defined on this plugin + let ks = this.options.entry; + if (!Array.isArray(ks)) + ks = [ks]; + ks.forEach(k => { + if (webpackEntry[k] === undefined) { + throw new Error('entry key "' + k + '" is not defined in Webpack build, cannot apply runtime.'); + } + webpackEntry[k] = entries.concat(webpackEntry[k]); + }); + } + else { + // Add runtime to each entry + for (let k in webpackEntry) { + if (!webpackEntry.hasOwnProperty(k)) { + continue; + } + let entry = webpackEntry[k]; + if (!Array.isArray(entry)) { + entry = [entry]; + } + webpackEntry[k] = entries.concat(entry); + } + } } else options.entry = entries.concat(webpackEntry); diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index a23f0f3..52fb45a 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.0.0 + +Remove the runtime insertion hack from the Webpack 3 and below era, wherein only the first "entry" item had the runtime appended to it. This was originally implemented to avoid adding the runtime to the secondary "vendor" entry. Using "vendor" entry points which is no longer recommended for Webpack 4 and up. + ## 3.0.0 * Promote the RC to release. diff --git a/package.json b/package.json index 437435b..8f90652 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-webpack-plugin", - "version": "3.0.0", + "version": "4.0.0", "description": "A plugin for webpack that enables bundling Aurelia applications.", "keywords": [ "aurelia",