From c55a7bed781b4cff132d18d778bf16268ce34f01 Mon Sep 17 00:00:00 2001
From: Paul Falgout <paul@otterball.com>
Date: Thu, 19 Sep 2019 16:19:09 +0900
Subject: [PATCH 1/5] fix: use cjs for browser fields

We should not be using pre-built files for the `browser`.  Resolves https://github.com/wycats/handlebars.js/issues/1553
---
 package.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 5a0e08475..607f4e169 100644
--- a/package.json
+++ b/package.json
@@ -64,8 +64,8 @@
   "main": "lib/index.js",
   "types": "types/index.d.ts",
   "browser": {
-    ".": "./dist/handlebars.min.js",
-    "./runtime": "./dist/handlebars.runtime.min.js"
+    ".": "./dist/cjs/handlebars.js",
+    "./runtime": "./dist/cjs/handlebars.runtime.js"
   },
   "bin": {
     "handlebars": "bin/handlebars"

From e47b5ec192392cee548c5c01dc85b72b0fc8419b Mon Sep 17 00:00:00 2001
From: Nils Knappmeier <github@knappi.org>
Date: Wed, 18 Sep 2019 22:53:35 +0200
Subject: [PATCH 2/5] integration-tests for various webpack-scenarios

related to #1553

- registering helpers on an instance retrieved via
  `import`, compiling the template on an instance
   retrieved via `require`
- using `@roundingwellos/babel-plugin-handlebars-inline-precompile` to load plugins inline
---
 .../webpack-babel-test/.babelrc               | 11 +++++++
 .../webpack-babel-test/.gitignore             |  3 ++
 .../webpack-babel-test/package.json           | 24 ++++++++++++++
 .../src/handlebars-inline-precompile-test.js  | 12 +++++++
 .../webpack-babel-test/src/lib/assert.js      |  5 +++
 .../webpack-babel-test/test.sh                | 16 ++++++++++
 .../webpack-babel-test/webpack.config.js      | 32 +++++++++++++++++++
 .../src/handlebars-require-vs-import-test.js  | 10 ++++++
 8 files changed, 113 insertions(+)
 create mode 100644 integration-testing/webpack-babel-test/.babelrc
 create mode 100644 integration-testing/webpack-babel-test/.gitignore
 create mode 100644 integration-testing/webpack-babel-test/package.json
 create mode 100644 integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js
 create mode 100644 integration-testing/webpack-babel-test/src/lib/assert.js
 create mode 100755 integration-testing/webpack-babel-test/test.sh
 create mode 100644 integration-testing/webpack-babel-test/webpack.config.js
 create mode 100644 integration-testing/webpack-test/src/handlebars-require-vs-import-test.js

diff --git a/integration-testing/webpack-babel-test/.babelrc b/integration-testing/webpack-babel-test/.babelrc
new file mode 100644
index 000000000..6c1ec732b
--- /dev/null
+++ b/integration-testing/webpack-babel-test/.babelrc
@@ -0,0 +1,11 @@
+{
+  "plugins": [
+    "@roundingwellos/babel-plugin-handlebars-inline-precompile"
+   // "istanbul"
+  ],
+  "presets": [
+    [
+      "@babel/preset-env"
+    ]
+  ]
+}
\ No newline at end of file
diff --git a/integration-testing/webpack-babel-test/.gitignore b/integration-testing/webpack-babel-test/.gitignore
new file mode 100644
index 000000000..3a8ec2b3f
--- /dev/null
+++ b/integration-testing/webpack-babel-test/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+dist
+package-lock.json
\ No newline at end of file
diff --git a/integration-testing/webpack-babel-test/package.json b/integration-testing/webpack-babel-test/package.json
new file mode 100644
index 000000000..dd21ae0af
--- /dev/null
+++ b/integration-testing/webpack-babel-test/package.json
@@ -0,0 +1,24 @@
+{
+  "name": "webpack-babel-test",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "@babel/core": "^7.5.5",
+    "@babel/preset-env": "^7.5.5",
+    "@roundingwellos/babel-plugin-handlebars-inline-precompile": "^3.0.1",
+    "babel-loader": "^8.0.6",
+    "babel-plugin-istanbul": "^5.2.0",
+    "handlebars": "file:../..",
+    "handlebars-loader": "^1.7.1",
+    "nyc": "^14.1.1",
+    "webpack": "^4.39.3",
+    "webpack-cli": "^3.3.7"
+  },
+  "scripts": {
+    "build": "webpack --config webpack.config.js"
+  }
+}
diff --git a/integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js b/integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js
new file mode 100644
index 000000000..7f764e328
--- /dev/null
+++ b/integration-testing/webpack-babel-test/src/handlebars-inline-precompile-test.js
@@ -0,0 +1,12 @@
+import * as Handlebars from 'handlebars/runtime'
+import hbs from 'handlebars-inline-precompile';
+import {assertEquals} from "../../webpack-test/src/lib/assert";
+
+Handlebars.registerHelper('loud', function(text) {
+    return text.toUpperCase();
+});
+
+const template = hbs`{{loud name}}`;
+const output = template({name: 'yehuda'})
+
+assertEquals(output, 'YEHUDA')
\ No newline at end of file
diff --git a/integration-testing/webpack-babel-test/src/lib/assert.js b/integration-testing/webpack-babel-test/src/lib/assert.js
new file mode 100644
index 000000000..9f33188db
--- /dev/null
+++ b/integration-testing/webpack-babel-test/src/lib/assert.js
@@ -0,0 +1,5 @@
+export function assertEquals(actual, expected) {
+    if (actual !== expected) {
+        throw new Error(`Expected "${actual}" to equal "${expected}"`);
+    }
+}
diff --git a/integration-testing/webpack-babel-test/test.sh b/integration-testing/webpack-babel-test/test.sh
new file mode 100755
index 000000000..a45d5625f
--- /dev/null
+++ b/integration-testing/webpack-babel-test/test.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+
+# Cleanup: package-lock and "npm ci" is not working with local dependencies
+rm dist package-lock.json -rf
+npm install
+npm run build
+
+for i in dist/*-test.js ; do
+  echo "----------------------"
+  echo "-- Running $i"
+  echo "----------------------"
+  node "$i"
+  echo "Success"
+done
\ No newline at end of file
diff --git a/integration-testing/webpack-babel-test/webpack.config.js b/integration-testing/webpack-babel-test/webpack.config.js
new file mode 100644
index 000000000..9ad0a09b2
--- /dev/null
+++ b/integration-testing/webpack-babel-test/webpack.config.js
@@ -0,0 +1,32 @@
+const fs = require('fs');
+
+const testFiles = fs.readdirSync('src');
+const entryPoints = {};
+testFiles
+    .filter(file => file.match(/-test.js$/))
+    .forEach(file => {
+        entryPoints[file] = `./src/${file}`;
+    });
+
+module.exports = {
+    entry: entryPoints,
+    output: {
+        filename: '[name]',
+        path: __dirname + '/dist'
+    },
+    module: {
+        rules: [
+            {
+                test: /\.js?$/,
+                exclude: /node_modules/,
+                use: {
+                    loader: 'babel-loader',
+                    options: { cacheDirectory: false },
+                }
+            }
+        ]
+    },
+    optimization: {
+        minimize: false
+    }
+};
diff --git a/integration-testing/webpack-test/src/handlebars-require-vs-import-test.js b/integration-testing/webpack-test/src/handlebars-require-vs-import-test.js
new file mode 100644
index 000000000..13e2c97d7
--- /dev/null
+++ b/integration-testing/webpack-test/src/handlebars-require-vs-import-test.js
@@ -0,0 +1,10 @@
+import * as HandlebarsViaImport from 'handlebars';
+const HandlebarsViaRequire = require('handlebars');
+import {assertEquals} from './lib/assert';
+
+HandlebarsViaImport.registerHelper('loud', function(text) {
+    return text.toUpperCase();
+});
+
+const template = HandlebarsViaRequire.compile('Author: {{loud author}}');
+assertEquals(template({author: 'Yehuda'}), 'Author: YEHUDA');

From 00b4f2ff98bf6285cc551f090166a92a70196124 Mon Sep 17 00:00:00 2001
From: Caleb Mazalevskis <maikuolan@gmail.com>
Date: Fri, 12 Apr 2019 14:02:48 +0800
Subject: [PATCH 3/5] Fix some small typos.

---
 lib/handlebars/compiler/whitespace-control.js | 2 +-
 lib/handlebars/runtime.js                     | 2 +-
 release-notes.md                              | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/handlebars/compiler/whitespace-control.js b/lib/handlebars/compiler/whitespace-control.js
index e11483c91..8ebfbef57 100644
--- a/lib/handlebars/compiler/whitespace-control.js
+++ b/lib/handlebars/compiler/whitespace-control.js
@@ -206,7 +206,7 @@ function omitLeft(body, i, multiple) {
     return;
   }
 
-  // We omit the last node if it's whitespace only and not preceeded by a non-content node.
+  // We omit the last node if it's whitespace only and not preceded by a non-content node.
   let original = current.value;
   current.value = current.value.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
   current.leftStripped = current.value !== original;
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index a73ebd280..a00f71e06 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -32,7 +32,7 @@ export function template(templateSpec, env) {
   templateSpec.main.decorator = templateSpec.main_d;
 
   // Note: Using env.VM references rather than local var references throughout this section to allow
-  // for external users to override these as psuedo-supported APIs.
+  // for external users to override these as pseudo-supported APIs.
   env.VM.checkRevision(templateSpec.compiler);
 
   function invokePartialWrapper(partial, context, options) {
diff --git a/release-notes.md b/release-notes.md
index ffdb176d0..6a93164b1 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -406,7 +406,7 @@ Compatibility notes:
 - Lines containing only block statements and whitespace are now removed. This matches the Mustache spec but may cause issues with code that expects whitespace to exist but would not otherwise.
 - Partials that are standalone will now indent their rendered content
 - `AST.ProgramNode`'s signature has changed. 
-- Numerious methods/features removed from psuedo-API classes
+- Numerious methods/features removed from pseudo-API classes
   - `JavaScriptCompiler.register`
   - `JavaScriptCompiler.replaceStack` no longer supports non-inline replace
   - `Compiler.disassemble`
@@ -597,7 +597,7 @@ Compatibility notes:
 ## v1.0.11 / 1.0.0-rc4 - May 13 2013
 
 - [#458](https://github.com/wycats/handlebars.js/issues/458) - Fix `./foo` syntax ([@jpfiset](https://github.com/jpfiset))
-- [#460](https://github.com/wycats/handlebars.js/issues/460) - Allow `:` in unescaped identifers ([@jpfiset](https://github.com/jpfiset))
+- [#460](https://github.com/wycats/handlebars.js/issues/460) - Allow `:` in unescaped identifiers ([@jpfiset](https://github.com/jpfiset))
 - [#471](https://github.com/wycats/handlebars.js/issues/471) - Create release notes (These!)
 - [#456](https://github.com/wycats/handlebars.js/issues/456) - Allow escaping of `\\`
 - [#211](https://github.com/wycats/handlebars.js/issues/211) - Fix exception in `escapeExpression`

From 35bcd4405fad758520308754f05b88c97c7b380c Mon Sep 17 00:00:00 2001
From: Nils Knappmeier <github@knappi.org>
Date: Fri, 20 Sep 2019 19:40:10 +0200
Subject: [PATCH 4/5] Update release notes

---
 release-notes.md | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/release-notes.md b/release-notes.md
index 6a93164b1..48fc00146 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -2,7 +2,17 @@
 
 ## Development
 
-[Commits](https://github.com/wycats/handlebars.js/compare/v4.2.0...master)
+[Commits](https://github.com/wycats/handlebars.js/compare/v4.2.1...master)
+
+## v4.2.1 - September 20th, 2019
+Bugfixes: 
+
+- The "browser" property in the package.json has been updated to use the common-js builds instead of the minified UMD - c55a7be, #1553
+
+Compatibility notes:
+- No compatibility issues should arise
+
+[Commits](https://github.com/wycats/handlebars.js/compare/v4.2.0...v4.2.1)
 
 ## v4.2.0 - September 3rd, 2019
 Chore/Test:

From fff3e40402c9f9cd790984560658646a26e1c930 Mon Sep 17 00:00:00 2001
From: Nils Knappmeier <github@knappi.org>
Date: Fri, 20 Sep 2019 19:40:48 +0200
Subject: [PATCH 5/5] v4.2.1

---
 components/bower.json           | 2 +-
 components/handlebars.js.nuspec | 2 +-
 components/package.json         | 2 +-
 lib/handlebars/base.js          | 2 +-
 package.json                    | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/components/bower.json b/components/bower.json
index e80ca3ed7..f590c5669 100644
--- a/components/bower.json
+++ b/components/bower.json
@@ -1,6 +1,6 @@
 {
   "name": "handlebars",
-  "version": "4.2.0",
+  "version": "4.2.1",
   "main": "handlebars.js",
   "license": "MIT",
   "dependencies": {}
diff --git a/components/handlebars.js.nuspec b/components/handlebars.js.nuspec
index c99b588b8..04c194afd 100644
--- a/components/handlebars.js.nuspec
+++ b/components/handlebars.js.nuspec
@@ -2,7 +2,7 @@
 <package>
 	<metadata>
 		<id>handlebars.js</id>
-		<version>4.2.0</version>
+		<version>4.2.1</version>
 		<authors>handlebars.js Authors</authors>
 		<licenseUrl>https://github.com/wycats/handlebars.js/blob/master/LICENSE</licenseUrl>
 		<projectUrl>https://github.com/wycats/handlebars.js/</projectUrl>
diff --git a/components/package.json b/components/package.json
index 6641b0f52..8f1e063fb 100644
--- a/components/package.json
+++ b/components/package.json
@@ -1,6 +1,6 @@
 {
   "name": "handlebars",
-  "version": "4.2.0",
+  "version": "4.2.1",
   "license": "MIT",
   "jspm": {
     "main": "handlebars",
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js
index 6cbdcb48c..b0df08e0c 100644
--- a/lib/handlebars/base.js
+++ b/lib/handlebars/base.js
@@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers';
 import {registerDefaultDecorators} from './decorators';
 import logger from './logger';
 
-export const VERSION = '4.2.0';
+export const VERSION = '4.2.1';
 export const COMPILER_REVISION = 7;
 
 export const REVISION_CHANGES = {
diff --git a/package.json b/package.json
index 607f4e169..def528265 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "handlebars",
   "barename": "handlebars",
-  "version": "4.2.0",
+  "version": "4.2.1",
   "description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration",
   "homepage": "http://www.handlebarsjs.com/",
   "keywords": [
