From b286cea3d25caa6241e80955cc9c13d4192ab44b Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 18 Jan 2016 23:45:22 +0100 Subject: [PATCH 1/4] fixed windows issue (backslash is escape char) --- lib/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/loader.js b/lib/loader.js index 4613c397..beeb0c6b 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -22,5 +22,5 @@ module.exports = function (source) { // Use underscore for a minimalistic loader var options = loaderUtils.parseQuery(this.query); var template = _.template(source, options); - return 'var _ = require("' + require.resolve('lodash') + '");module.exports = ' + template; + return 'var _ = require(' + loaderUtils.stringifyRequest(this, require.resolve('lodash')) + ');module.exports = ' + template; }; From c4ee1738e78c32a29b17ad5b999960b65192b81c Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Tue, 19 Jan 2016 07:38:21 +0100 Subject: [PATCH 2/4] Add some documentation for the hmr fix --- lib/compiler.js | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index c4f0c1d1..ad388892 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -50,7 +50,11 @@ module.exports.compileTemplate = function compileTemplate(template, context, out new SingleEntryPlugin(this.context, template), new LoaderTargetPlugin('node') ); - childCompiler.plugin("compilation", function(compilation) { + + // Fix for "Uncaught TypeError: __webpack_require__(...) is not a function" + // Hot module replacement requires that every child compiler has its own + // cache. @see https://github.com/ampedandwired/html-webpack-plugin/pull/179 + childCompiler.plugin('compilation', function(compilation) { if(compilation.cache) { if(!compilation.cache[compilerName]) compilation.cache[compilerName] = {}; diff --git a/package.json b/package.json index cdf3cf48..b932873e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "2.6.3", + "version": "2.6.4", "description": "Simplifies creation of HTML files to serve your webpack bundles", "main": "index.js", "files": [ From d5c4e0845731389e7264b52df8fb8880ec5e651a Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Tue, 19 Jan 2016 14:52:25 +0100 Subject: [PATCH 3/4] Minor refactoring because of #179 Release 2.6.5 --- index.js | 40 ++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/index.js b/index.js index 8bd1c19d..ea831b3b 100644 --- a/index.js +++ b/index.js @@ -35,22 +35,20 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { compiler.plugin('make', function(compilation, callback) { // Compile the template (queued) - compilationPromise = getNextCompilationSlot(compiler, function() { - return childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation) - .catch(function(err) { - compilation.errors.push(prettyError(err, compiler.context).toString()); - return { - content: self.options.showErrors ? prettyError(err, compiler.context).toJsonHtml() : 'ERROR', - }; - }) - .then(function(compilationResult) { - // If the compilation change didnt change the cache is valid - isCompilationCached = compilationResult.hash && self.hash === compilationResult.hash; - self.hash = compilation.hash; - callback(); - return compilationResult.content; - }); - }); + compilationPromise = childCompiler.compileTemplate(self.options.template, compiler.context, self.options.filename, compilation) + .catch(function(err) { + compilation.errors.push(prettyError(err, compiler.context).toString()); + return { + content: self.options.showErrors ? prettyError(err, compiler.context).toJsonHtml() : 'ERROR' + }; + }) + .then(function(compilationResult) { + // If the compilation change didnt change the cache is valid + isCompilationCached = compilationResult.hash && self.hash === compilationResult.hash; + self.hash = compilation.hash; + callback(); + return compilationResult.content; + }); }); compiler.plugin('after-compile', function(compilation, callback) { @@ -498,14 +496,4 @@ HtmlWebpackPlugin.prototype.getFullTemplatePath = function(template, context) { }); }; -/** - * Helper to prevent html-plugin compilation in parallel - * Fixes "No source available" where incomplete cache modules were used - */ -function getNextCompilationSlot(compiler, newEntry) { - compiler.HtmlWebpackPluginQueue = (compiler.HtmlWebpackPluginQueue || Promise.resolve()) - .then(newEntry); - return compiler.HtmlWebpackPluginQueue; -} - module.exports = HtmlWebpackPlugin; diff --git a/package.json b/package.json index b932873e..e1711ad2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "2.6.4", + "version": "2.6.5", "description": "Simplifies creation of HTML files to serve your webpack bundles", "main": "index.js", "files": [ From a35e5e3b84b40bbdc22dedc5842e76195dc36f86 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Wed, 20 Jan 2016 16:24:16 +0100 Subject: [PATCH 4/4] Add appveyor file --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..5bc2d726 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml + +environment: + matrix: + - nodejs_version: 0.10 + - nodejs_version: 0.12 + - nodejs_version: 4 + +version: "{build}" +build: off +deploy: off +matrix: + fast_finish: true + +install: + - ps: Install-Product node $env:nodejs_version + - npm install + +test_script: + - node --version + - npm --version + - npm test \ No newline at end of file