@@ -16,6 +16,7 @@ MainTemplate.prototype = Object.create(Template.prototype);
1616MainTemplate . prototype . requireFn = "require" ;
1717MainTemplate . prototype . render = function ( hash , chunk , moduleTemplate , dependencyTemplates ) {
1818 var buf = [ ] ;
19+ buf . push ( this . asString ( this . renderAdditions ( hash , chunk , moduleTemplate , dependencyTemplates ) ) ) ;
1920 buf . push ( this . asString ( this . renderLocalVars ( hash , chunk ) ) ) ;
2021 buf . push ( "" ) ;
2122 buf . push ( "// The require function" ) ;
@@ -43,17 +44,7 @@ MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependency
4344} ;
4445
4546MainTemplate . prototype . renderModules = function renderModules ( hash , chunk , moduleTemplate , dependencyTemplates ) {
46- var source = new ConcatSource ( ) ;
47- source . add ( "{\n" ) ;
48- source . add ( this . asString ( this . renderInitModules ( hash , chunk , moduleTemplate , dependencyTemplates ) ) ) ;
49- source . add ( "\n" ) ;
50- chunk . modules . forEach ( function ( module , idx ) {
51- if ( idx != 0 ) source . add ( ",\n" ) ;
52- source . add ( "\n/***/ " + module . id + ":\n" ) ;
53- source . add ( moduleTemplate . render ( module , dependencyTemplates , chunk ) ) ;
54- } ) ;
55- source . add ( "\n/******/ }" ) ;
56- return source ;
47+ return this . renderChunkModules ( chunk , moduleTemplate , dependencyTemplates , "/******/ " ) ;
5748} ;
5849
5950MainTemplate . prototype . indent = function indent ( str ) {
@@ -138,22 +129,25 @@ MainTemplate.prototype.renderRequireExtensions = function(hash, chunk) {
138129 buf . push ( "" ) ;
139130 buf . push ( "// expose the modules object (__webpack_modules__)" ) ;
140131 buf . push ( this . requireFn + ".modules = modules;" ) ;
132+
141133 buf . push ( "" ) ;
142134 buf . push ( "// expose the module cache" ) ;
143135 buf . push ( this . requireFn + ".cache = installedModules;" ) ;
136+
137+ var publicPath = this . outputOptions . publicPath || "" ;
138+ publicPath = publicPath . replace ( Template . REGEXP_HASH , hash ) ;
139+ buf . push ( "" ) ;
140+ buf . push ( "// __webpack_public_path__" ) ;
141+ buf . push ( this . requireFn + ".p = " + JSON . stringify ( publicPath ) + ";" ) ;
144142 return buf ;
145143} ;
146144
147145MainTemplate . prototype . renderInit = function ( hash , chunk ) {
148146 return [ ] ;
149147} ;
150148
151- MainTemplate . prototype . renderInitModules = function ( hash , chunk , moduleTemplate , dependencyTemplates ) {
152- var publicPath = this . outputOptions . publicPath || "" ;
153- return [
154- "/******/ // __webpack_public_path__" ,
155- "/******/ c: " + JSON . stringify ( publicPath . replace ( Template . REGEXP_HASH , hash ) ) + ","
156- ] ;
149+ MainTemplate . prototype . renderAdditions = function ( hash , chunk , moduleTemplate , dependencyTemplates ) {
150+ return [ ] ;
157151} ;
158152
159153MainTemplate . prototype . renderAddModule = function ( hash , chunk , varModuleId , varModule ) {
@@ -162,6 +156,6 @@ MainTemplate.prototype.renderAddModule = function(hash, chunk, varModuleId, varM
162156
163157MainTemplate . prototype . updateHash = function ( hash ) {
164158 hash . update ( "maintemplate" ) ;
165- hash . update ( "1 " ) ;
159+ hash . update ( "2 " ) ;
166160 hash . update ( this . outputOptions . publicPath + "" ) ;
167161} ;
0 commit comments