From 3fb865d1adf0299f537609926680de79211dabf4 Mon Sep 17 00:00:00 2001
From: Panayot Cankov <Panayot.Cankov@telerik.com>
Date: Thu, 29 Jun 2017 10:23:27 +0300
Subject: [PATCH 1/8] feat: alias tilde to point to the app root (#201)

---
 prepublish/common/exports.js    | 6 +++++-
 templates/webpack.angular.js    | 6 +++++-
 templates/webpack.javascript.js | 6 +++++-
 templates/webpack.typescript.js | 6 +++++-
 4 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/prepublish/common/exports.js b/prepublish/common/exports.js
index db268300..5d225e30 100644
--- a/prepublish/common/exports.js
+++ b/prepublish/common/exports.js
@@ -39,7 +39,11 @@ module.exports = env => {
             modules: [
                 "node_modules/tns-core-modules",
                 "node_modules",
-            ]
+            ],
+
+            alias: {
+                '~': resolve("./app")
+            },
         },
         node: {
             // Disable node shims that conflict with NativeScript
diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js
index 9ee25264..165cfb88 100644
--- a/templates/webpack.angular.js
+++ b/templates/webpack.angular.js
@@ -49,7 +49,11 @@ module.exports = env => {
             modules: [
                 "node_modules/tns-core-modules",
                 "node_modules",
-            ]
+            ],
+
+            alias: {
+                '~': resolve("./app")
+            },
         },
         node: {
             // Disable node shims that conflict with NativeScript
diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js
index 2d1b1e8b..2d934356 100644
--- a/templates/webpack.javascript.js
+++ b/templates/webpack.javascript.js
@@ -48,7 +48,11 @@ module.exports = env => {
             modules: [
                 "node_modules/tns-core-modules",
                 "node_modules",
-            ]
+            ],
+
+            alias: {
+                '~': resolve("./app")
+            },
         },
         node: {
             // Disable node shims that conflict with NativeScript
diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js
index 9288e8fd..9d182107 100644
--- a/templates/webpack.typescript.js
+++ b/templates/webpack.typescript.js
@@ -48,7 +48,11 @@ module.exports = env => {
             modules: [
                 "node_modules/tns-core-modules",
                 "node_modules",
-            ]
+            ],
+
+            alias: {
+                '~': resolve("./app")
+            },
         },
         node: {
             // Disable node shims that conflict with NativeScript

From 49213211d9dafe97486db25ec4961bc8f4fb1444 Mon Sep 17 00:00:00 2001
From: Rowan de Haas <rowandh@users.noreply.github.com>
Date: Thu, 29 Jun 2017 18:34:12 +1000
Subject: [PATCH 2/8] feat: add support for passing params via --env to webpack
 (#204)

---
 bin/ns-bundle | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bin/ns-bundle b/bin/ns-bundle
index afc00541..3304ffb7 100644
--- a/bin/ns-bundle
+++ b/bin/ns-bundle
@@ -15,6 +15,7 @@ if (!process.env.npm_config_argv) {
 
 const escape = arg => `"${arg}"`;
 const isTnsCommand = flag => flag.endsWith("-app");
+const isEnvCommand = flag => flag.indexOf("env.") > -1;
 const shouldUglify = () => process.env.npm_config_uglify;
 const shouldSnapshot = (platform) => platform == "android" && require("os").type() != "Windows_NT" && process.env.npm_config_snapshot;
 
@@ -34,7 +35,7 @@ function getTnsArgs(args) {
         "--nobundle",
     ];
 
-    return args.filter(a => !other.includes(a) && !isTnsCommand(a));
+    return args.filter(a => !other.includes(a) && !isTnsCommand(a) && !isEnvCommand(a));
 }
 
 execute(options);
@@ -51,7 +52,7 @@ function execute(options) {
             () => cleanApp(platform),
             () => cleanSnapshotArtefacts(),
             () => cleanBuildArtifacts(platform),
-            () => webpack(platform),
+            () => webpack(platform, options.env),
         ];
     }
 
@@ -139,7 +140,7 @@ function cleanApp(platform) {
     });
 }
 
-function webpack(platform) {
+function webpack(platform, env) {
     return new Promise(function (resolve, reject) {
         console.log(`Running webpack for ${platform}...`);
 
@@ -148,6 +149,7 @@ function webpack(platform) {
             `--config=webpack.config.js`,
             `--progress`,
             `--env.${platform}`,
+            ...env.map(item => `--${item}`),
             shouldUglify() && `--env.uglify`,
             shouldSnapshot(platform) && `--env.snapshot`
         ];
@@ -172,11 +174,16 @@ function getOptions(flags) {
     let options = {};
     options.platform = getPlatform(flags);
     options.command = getCommand(flags);
+    options.env = getEnv(flags);
     options.bundle = !flags.includes("nobundle");
 
     return options;
 }
 
+function getEnv(flags) {
+    return flags.filter(item => isEnvCommand(item));    
+}
+
 function getPlatform(flags) {
     if (flags.includes("android") && flags.includes("ios")) {
         throwError({message: "You cannot use both --android and --ios flags!"});

From b2aec11b80c8d86bca23cb0358a93c19d5b010cf Mon Sep 17 00:00:00 2001
From: Vasil Chimev <Vasil.Chimev@telerik.com>
Date: Mon, 3 Jul 2017 16:28:19 +0300
Subject: [PATCH 3/8] chore(travis): delete config (#208)

---
 .travis.yml | 21 ---------------------
 1 file changed, 21 deletions(-)
 delete mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 127ddf06..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-env:
-  global:
-  - DATE=$(date +%Y-%m-%d)
-  - PACKAGE_VERSION=$DATE-$TRAVIS_BUILD_NUMBER
-language: node_js
-node_js:
-- '6'
-install:
-- npm install --ignore-scripts
-script:
-- npm --no-git-tag-version version minor
-- node ./build/prepublish-next.js $PACKAGE_VERSION
-- npm pack
-deploy:
-  provider: npm
-  email: nativescript@telerik.com
-  skip_cleanup: true
-  on:
-    branch: master
-  api_key:
-    secure: HYqLXOd6FqNrOO0KTseros1LTkQ+OdZIzL1lncg+3RAcb/pxViVSUHbXZ9ml3ubVFU/ZN6n4l2snmjzCCYlkQ3CeeI6qqLMsXN2ywUFFdDJyFkz7VD0jyxoilS7HXY2TqFWtF58OeBFG5woY2OdfL2dzxrM2hsbs8ODvuUhoA1g0Y4DgH9W/RQK/8Ml+jII16/bzpKNCCI45zxRzzTW80QyxFR1Q2ABXVUQDBQa0LJ38eo8WDl8Jh1RdUTFJwicQG14WZTC69b1Sr4BHpm5nFExp7XX8gbmu6fcMyItGvbIhTqDA02CmjL7MYm5349SiJh+y9wLkxbBIH8rmY3pL3NIL9pBkPoYbWU/ZoG5e1iqc+2RoZjw7VW969IokeFiQV4QiNLEbFC9PnlXQJDmeKQXSh+aRKST6CKxDZxisp4gmt7h+4Rp7gU8BTVGbN0by15S7ab+CL8ZGa8gUqtGHwEjmFEpE0fQvcaZYVQHWO4kw4cwmwqXiyvnF2o5LYjjY4gjGnOOiKS2qZmABjftdUvKc5N0vZ2Vyq1O657EP8RFUAcvIJlZ1dBKDYq/vGr0hQ4iReJXyTYdCWHSNgzq4boAsdes3kHK8I9VBMrlUWmA9Ba/lMAaBgW5qOEQhdtWYKjHwmFadWwHfQocGLqp5TBTqWZF1sCC0OFybsME7SdU=
\ No newline at end of file

From c3e7376b784294b390fe3e28e40013d728c53d3c Mon Sep 17 00:00:00 2001
From: sis0k0 <stanimira.vlaeva@gmail.com>
Date: Tue, 4 Jul 2017 11:57:58 +0300
Subject: [PATCH 4/8] fix(ns-bundle): escape command and args when spawning
 child process

fixes #209
---
 bin/ns-bundle | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/bin/ns-bundle b/bin/ns-bundle
index 3304ffb7..11527b06 100644
--- a/bin/ns-bundle
+++ b/bin/ns-bundle
@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 const { spawn } = require("child_process");
-const { resolve: pathResolve } = require("path");
+const { resolve: pathResolve, join } = require("path");
 const { existsSync } = require("fs");
 const { getPackageJson } = require("../projectHelpers");
 const { isVersionGte } = require("../utils");
@@ -13,14 +13,16 @@ if (!process.env.npm_config_argv) {
     throwError({message: "No flags provided."});
 }
 
-const escape = arg => `"${arg}"`;
+const escapeWithQuotes = arg => `"${arg}"`;
 const isTnsCommand = flag => flag.endsWith("-app");
 const isEnvCommand = flag => flag.indexOf("env.") > -1;
 const shouldUglify = () => process.env.npm_config_uglify;
-const shouldSnapshot = (platform) => platform == "android" && require("os").type() != "Windows_NT" && process.env.npm_config_snapshot;
+const shouldSnapshot = platform => platform == "android" &&
+    require("os").type() != "Windows_NT" &&
+    process.env.npm_config_snapshot;
 
 const npmArgs = JSON.parse(process.env.npm_config_argv).original;
-const tnsArgs = getTnsArgs(npmArgs).map(escape);
+const tnsArgs = getTnsArgs(npmArgs).map(escapeWithQuotes);
 const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
 const options = getOptions(flags);
 
@@ -51,7 +53,7 @@ function execute(options) {
             ...commands,
             () => cleanApp(platform),
             () => cleanSnapshotArtefacts(),
-            () => cleanBuildArtifacts(platform),
+            () => cleanBuildArtefacts(platform),
             () => webpack(platform, options.env),
         ];
     }
@@ -68,14 +70,14 @@ function execute(options) {
     return commands.reduce((current, next) => current.then(next), Promise.resolve());
 }
 
-function cleanBuildArtifacts(platform) {
+function cleanBuildArtefacts(platform) {
     return new Promise((resolve, reject) => {
         if (platform !== "android") {
             return resolve();
         }
 
         getTnsVersion().then(version => {
-            // the android build artifacts should be cleaned manually
+            // the android build artefacts should be cleaned manually
             // for nativescript-cli v3.0.1 and below or if using uglify
             if (isVersionGte(version, "3.0.1") || shouldUglify()) {
                 gradlewClean().then(resolve).catch(throwError);
@@ -96,7 +98,7 @@ function installSnapshotArtefacts() {
 
 function gradlewClean() {
     return new Promise((resolve, reject) => {
-        const platformsPath = pathResolve(PROJECT_DIR, "platforms", "android")
+        const platformsPath = join(PROJECT_DIR, "platforms", "android")
         const gradlew = pathResolve(platformsPath, "gradlew");
         if (!existsSync(gradlew)) {
             return resolve();
@@ -134,6 +136,7 @@ function versionToNumber(version) {
 // Clear platform/**/app folder contents
 function cleanApp(platform) {
     return new Promise((resolve, reject) => {
+
         spawnChildProcess("tns", "clean-app", platform)
             .then(resolve)
             .catch(throwError)
@@ -171,18 +174,14 @@ function runTns(command, platform) {
 }
 
 function getOptions(flags) {
-    let options = {};
-    options.platform = getPlatform(flags);
-    options.command = getCommand(flags);
-    options.env = getEnv(flags);
-    options.bundle = !flags.includes("nobundle");
-
-    return options;
+    return {
+        platform: getPlatform(flags),
+        command: getCommand(flags),
+        env: flags.filter(isEnvCommand),
+        bundle: !flags.includes("nobundle"),
+    };
 }
 
-function getEnv(flags) {
-    return flags.filter(item => isEnvCommand(item));    
-}
 
 function getPlatform(flags) {
     if (flags.includes("android") && flags.includes("ios")) {
@@ -194,7 +193,9 @@ function getPlatform(flags) {
     } else if (flags.includes("ios")) {
         return "ios";
     } else {
-        throwError({message: "You must provide a target platform! Use either --android, or --ios flag."});
+        throwError({message:
+            "You must provide a target platform! " +
+            "Use either --android, or --ios flag."});
     }
 }
 
@@ -209,7 +210,10 @@ function getCommand(flags) {
 
 function spawnChildProcess(command, ...args) {
     return new Promise((resolve, reject) => {
-        const childProcess = spawn(command, args, {
+        const escapedArgs = args.map(escapeWithQuotes)
+        const escapedCommand = escapeWithQuotes(command)
+
+        const childProcess = spawn(escapedCommand, escapedArgs, {
             stdio: "inherit",
             pwd: PROJECT_DIR,
             shell: true,

From efea463d2170a7ca2eb90c45897c972b995d181b Mon Sep 17 00:00:00 2001
From: sis0k0 <stanimira.vlaeva@gmail.com>
Date: Tue, 4 Jul 2017 11:59:16 +0300
Subject: [PATCH 5/8] fix: run gradlew clean only for tns <=3.0.1

---
 bin/ns-bundle | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/ns-bundle b/bin/ns-bundle
index 11527b06..98e72989 100644
--- a/bin/ns-bundle
+++ b/bin/ns-bundle
@@ -79,7 +79,7 @@ function cleanBuildArtefacts(platform) {
         getTnsVersion().then(version => {
             // the android build artefacts should be cleaned manually
             // for nativescript-cli v3.0.1 and below or if using uglify
-            if (isVersionGte(version, "3.0.1") || shouldUglify()) {
+            if (!isVersionGte(version, "3.0.1") || shouldUglify()) {
                 gradlewClean().then(resolve).catch(throwError);
             } else {
                 return resolve();
@@ -155,7 +155,7 @@ function webpack(platform, env) {
             ...env.map(item => `--${item}`),
             shouldUglify() && `--env.uglify`,
             shouldSnapshot(platform) && `--env.snapshot`
-        ];
+        ].filter(a => !!a);
 
         spawnChildProcess(...args)
             .then(resolve)

From 7e90ef4e7205758625f653ae75cae62431782029 Mon Sep 17 00:00:00 2001
From: Pablo Cid <pabloagronomo@gmail.com>
Date: Tue, 4 Jul 2017 16:29:51 -0400
Subject: [PATCH 6/8] docs(README): fix broken link (#211)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 13b4f9c9..db87e8e2 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ $ npm run start-ios-bundle
 
 # Documentation
 
-For details, see the [NativeScript docs](http://docs.nativescript.org/angular/tooling/bundling-with-webpack.html).
+For details, see the [NativeScript docs](http://docs.nativescript.org/angular/best-practices/bundling-with-webpack.html).
 
 # Note about dependencies.
 

From a458efa4d28df25f5686dcc8f288ae3f67d1ab2c Mon Sep 17 00:00:00 2001
From: sis0k0 <stanimira.vlaeva@gmail.com>
Date: Wed, 5 Jul 2017 14:34:36 +0300
Subject: [PATCH 7/8] release: cut the 0.7.2 release

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index 052ce012..73d3e19f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "nativescript-dev-webpack",
-  "version": "0.7.1",
+  "version": "0.7.2",
   "main": "index",
   "description": "",
   "homepage": "http://www.telerik.com",

From ff069e32418309d7736022becf5ef85d789b06df Mon Sep 17 00:00:00 2001
From: sis0k0 <stanimira.vlaeva@gmail.com>
Date: Wed, 5 Jul 2017 14:34:37 +0300
Subject: [PATCH 8/8] docs: add changelog for 0.7.2

---
 CHANGELOG.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53329ccd..2b8648cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,22 @@
+<a name="0.7.2"></a>
+## [0.7.2](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.6.3...0.7.2) (2017-07-05)
+
+
+### Bug Fixes
+
+* **mangle-excludes:** add Compat Query and Close listener classes ([#190](https://github.com/NativeScript/nativescript-dev-webpack/issues/190)) ([5791cfc](https://github.com/NativeScript/nativescript-dev-webpack/commit/5791cfc))
+* **ns-bundle:** escape command and args when spawning child process ([c3e7376](https://github.com/NativeScript/nativescript-dev-webpack/commit/c3e7376)), closes [#209](https://github.com/NativeScript/nativescript-dev-webpack/issues/209)
+* run gradlew clean only for tns <=3.0.1 ([efea463](https://github.com/NativeScript/nativescript-dev-webpack/commit/efea463))
+
+
+### Features
+
+* add BundleAnalyzerPlugin to webpack config ([ac32b14](https://github.com/NativeScript/nativescript-dev-webpack/commit/ac32b14))
+* add support for passing params via --env to webpack ([#204](https://github.com/NativeScript/nativescript-dev-webpack/issues/204)) ([4921321](https://github.com/NativeScript/nativescript-dev-webpack/commit/4921321))
+* alias tilde to point to the app root ([#201](https://github.com/NativeScript/nativescript-dev-webpack/issues/201)) ([3fb865d](https://github.com/NativeScript/nativescript-dev-webpack/commit/3fb865d))
+
+
+
 <a name="0.7.1"></a>
 ## [0.7.1](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.6.3...0.7.1) (2017-06-22)