Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #290 from TrueCar/toddw/remove-commons
Browse files Browse the repository at this point in the history
nothing is going into the commons file, let's remove it
  • Loading branch information
christinebrass authored Sep 13, 2016
2 parents 514324c + 822c7ad commit 9d191b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/config/getWebpackClientConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export default function (appRoot, appConfigFilePath, isProduction) {
new webpack.NormalModuleReplacementPlugin(/\.server(\.js)?$/, () => {}),

new webpack.optimize.CommonsChunkPlugin("vendor", `vendor${isProduction ? "-[hash]" : ""}.bundle.js`),
new webpack.optimize.CommonsChunkPlugin("commons", `commons${isProduction ? "-[hash]" : ""}.bundle.js`)
].concat(getEnvironmentPlugins(isProduction), webpackSharedConfig.plugins, plugins),
resolve: {
...webpackSharedConfig.resolve
Expand Down
12 changes: 4 additions & 8 deletions src/lib/server/getHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default (config, entryPoint, assets) => {
);

const scriptPaths = {
commons: getAssetPathForFile("commons", "javascript"),
vendor: getAssetPathForFile("vendor", "javascript"),
entryPoint: getAssetPathForFile(entryPoint, "javascript")
};
Expand All @@ -32,7 +31,7 @@ export default (config, entryPoint, assets) => {
return tags.concat(getScriptSubresources(scriptPaths));
};

function getScriptLoader ({commons, vendor, entryPoint}:Object) {
function getScriptLoader ({vendor, entryPoint}:Object) {
// eslint-disable-next-line quotes
const scriptLoader = `
/*!
Expand All @@ -41,20 +40,17 @@ function getScriptLoader ({commons, vendor, entryPoint}:Object) {
* (c) Dustin Diaz 2014 | License MIT
*/
(function(e,t){typeof module!="undefined"&&module.exports?module.exports=t():typeof define=="function"&&define.amd?define(t):this[e]=t()})("$script",function(){function p(e,t){for(var n=0,i=e.length;n<i;++n)if(!t(e[n]))return r;return 1}function d(e,t){p(e,function(e){return t(e),1})}function v(e,t,n){function g(e){return e.call?e():u[e]}function y(){if(!--h){u[o]=1,s&&s();for(var e in f)p(e.split("|"),g)&&!d(f[e],g)&&(f[e]=[])}}e=e[i]?e:[e];var r=t&&t.call,s=r?t:n,o=r?e.join(""):t,h=e.length;return setTimeout(function(){d(e,function t(e,n){if(e===null)return y();!n&&!/^https?:\\\/\\\//.test(e)&&c&&(e=e.indexOf(".js")===-1?c+e+".js":c+e);if(l[e])return o&&(a[o]=1),l[e]==2?y():setTimeout(function(){t(e,!0)},0);l[e]=1,o&&(a[o]=1),m(e,y)})},0),v}function m(n,r){var i=e.createElement("script"),u;i.onload=i.onerror=i[o]=function(){if(i[s]&&!/^c|loade/.test(i[s])||u)return;i.onload=i[o]=null,u=1,l[n]=2,r()},i.async=1,i.src=h?n+(n.indexOf("?")===-1?"?":"&")+h:n,t.insertBefore(i,t.lastChild)}var e=document,t=e.getElementsByTagName("head")[0],n="string",r=!1,i="push",s="readyState",o="onreadystatechange",u={},a={},f={},l={},c,h;return v.get=m,v.order=function(e,t,n){(function r(i){i=e.shift(),e.length?v(i,r):v(i,t,n)})()},v.path=function(e){c=e},v.urlArgs=function(e){h=e},v.ready=function(e,t,n){e=e[i]?e:[e];var r=[];return!d(e,function(e){u[e]||r[i](e)})&&p(e,function(e){return u[e]})?t():!function(e){f[e]=f[e]||[],f[e][i](t),n&&n(r)}(e.join("|")),v},v.done=function(e){v([null],e)},v})
$script("${commons}", function () {
$script("${vendor}", function () {
$script("${entryPoint}");
});
$script("${vendor}", function () {
$script("${entryPoint}");
});
`;

return <script key="script-loader" type="text/javascript" dangerouslySetInnerHTML={{__html: scriptLoader}} />;
}

// Sub resources give browsers a clue to assets they can preload and cache
function getScriptSubresources ({commons, vendor, entryPoint}) {
function getScriptSubresources ({vendor, entryPoint}) {
return [
commons,
vendor,
entryPoint
].map((src, i) => {
Expand Down

0 comments on commit 9d191b0

Please sign in to comment.