Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NativeScript/nativescript-dev-webpack
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.7.1
Choose a base ref
...
head repository: NativeScript/nativescript-dev-webpack
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.7.2
Choose a head ref
  • 8 commits
  • 9 files changed
  • 5 contributors

Commits on Jun 29, 2017

  1. Copy the full SHA
    3fb865d View commit details
  2. Copy the full SHA
    4921321 View commit details

Commits on Jul 3, 2017

  1. chore(travis): delete config (#208)

    Vasil Chimev authored Jul 3, 2017
    Copy the full SHA
    b2aec11 View commit details

Commits on Jul 4, 2017

  1. Copy the full SHA
    c3e7376 View commit details
  2. Copy the full SHA
    efea463 View commit details
  3. docs(README): fix broken link (#211)

    pablocid authored and sis0k0 committed Jul 4, 2017
    Copy the full SHA
    7e90ef4 View commit details

Commits on Jul 5, 2017

  1. Copy the full SHA
    a458efa View commit details
  2. docs: add changelog for 0.7.2

    sis0k0 committed Jul 5, 2017
    Copy the full SHA
    ff069e3 View commit details
Showing with 73 additions and 48 deletions.
  1. +0 −21 .travis.yml
  2. +19 −0 CHANGELOG.md
  3. +1 −1 README.md
  4. +32 −21 bin/ns-bundle
  5. +1 −1 package.json
  6. +5 −1 prepublish/common/exports.js
  7. +5 −1 templates/webpack.angular.js
  8. +5 −1 templates/webpack.javascript.js
  9. +5 −1 templates/webpack.typescript.js
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

53 changes: 32 additions & 21 deletions bin/ns-bundle
Original file line number Diff line number Diff line change
@@ -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,13 +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);

@@ -34,7 +37,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);
@@ -50,8 +53,8 @@ function execute(options) {
...commands,
() => cleanApp(platform),
() => cleanSnapshotArtefacts(),
() => cleanBuildArtifacts(platform),
() => webpack(platform),
() => cleanBuildArtefacts(platform),
() => webpack(platform, options.env),
];
}

@@ -67,16 +70,16 @@ 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()) {
if (!isVersionGte(version, "3.0.1") || shouldUglify()) {
gradlewClean().then(resolve).catch(throwError);
} else {
return resolve();
@@ -95,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();
@@ -133,13 +136,14 @@ 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)
});
}

function webpack(platform) {
function webpack(platform, env) {
return new Promise(function (resolve, reject) {
console.log(`Running webpack for ${platform}...`);

@@ -148,9 +152,10 @@ function webpack(platform) {
`--config=webpack.config.js`,
`--progress`,
`--env.${platform}`,
...env.map(item => `--${item}`),
shouldUglify() && `--env.uglify`,
shouldSnapshot(platform) && `--env.snapshot`
];
].filter(a => !!a);

spawnChildProcess(...args)
.then(resolve)
@@ -169,14 +174,15 @@ function runTns(command, platform) {
}

function getOptions(flags) {
let options = {};
options.platform = getPlatform(flags);
options.command = getCommand(flags);
options.bundle = !flags.includes("nobundle");

return options;
return {
platform: getPlatform(flags),
command: getCommand(flags),
env: flags.filter(isEnvCommand),
bundle: !flags.includes("nobundle"),
};
}


function getPlatform(flags) {
if (flags.includes("android") && flags.includes("ios")) {
throwError({message: "You cannot use both --android and --ios flags!"});
@@ -187,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."});
}
}

@@ -202,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,
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-dev-webpack",
"version": "0.7.1",
"version": "0.7.2",
"main": "index",
"description": "",
"homepage": "http://www.telerik.com",
6 changes: 5 additions & 1 deletion prepublish/common/exports.js
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion templates/webpack.angular.js
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion templates/webpack.javascript.js
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion templates/webpack.typescript.js
Original file line number Diff line number Diff line change
@@ -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