From 05f33ed43a10af2a53dbaf65b97720ed18ec8c58 Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Wed, 18 Jan 2017 11:30:19 +0200 Subject: [PATCH 01/16] fix: register elements from embedded templates (#56) Make the tns-xml-loader parse Angular templates from TypeScript files. fixes #55 --- tns-xml-loader.js | 44 ++++++++++++++++++++++++++---- webpack.common.js.angular.template | 5 ++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tns-xml-loader.js b/tns-xml-loader.js index 4779aa3e..f3671760 100644 --- a/tns-xml-loader.js +++ b/tns-xml-loader.js @@ -20,25 +20,59 @@ if (!global[ELEMENT_REGISTRY]) { }; } -module.exports = function (source, map) { +function parseResource(source, map) { this.cacheable(); - var loader = this; + let templateSource; + try { + templateSource = getTemplateSource(this.resourcePath, source); + } catch(e) { + this.emitWarning(e.message); + return this.callback(null, source, map); + } + + if (templateSource === "") { + return this.callback(null, source, map); + } var parser = new htmlparser.Parser({ onopentag: function (name, attribs) { // kebab-case to CamelCase var elementName = name.split("-").map(function (s) { return s[0].toUpperCase() + s.substring(1); }).join(""); + // Module path from element name var modulePath = MODULES[elementName] || UI_PATH + (elementName.toLowerCase().indexOf("layout") !== -1 ? "layouts/" : "") + elementName.split(/(?=[A-Z])/).join("-").toLowerCase(); + // Update ELEMENT_REGISTRY global[ELEMENT_REGISTRY][modulePath] = elementName; } }, { decodeEntities: true, lowerCaseTags: false }); - parser.write(source); + + parser.write(templateSource); parser.end(); - this.callback(null, source, map); -}; \ No newline at end of file + return this.callback(null, source, map); +} + +function getTemplateSource(path, source) { + if (isTemplate(path)) { + return source; + } else if (isComponent(path)) { + const templateMatcher = /template\s*:\s*([`'"])((.|\n)*?)\1/; + return templateMatcher.test(source) ? source.replace(templateMatcher, "$2") : ""; + } else { + throw new Error(`The NativeScript XML loader must be used with HTML, XML or TypeScript files`); + } +} + +function isComponent(resource) { + return /\.ts$/i.test(resource); +} + +function isTemplate(resource) { + return /\.html$|\.xml$/i.test(resource); +} + +module.exports = parseResource; diff --git a/webpack.common.js.angular.template b/webpack.common.js.angular.template index 61850fa7..725c4c1f 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -47,7 +47,7 @@ module.exports = function (platform, destinationApp) { ]), // Exclude explicitly required but never declared in XML elements. - // Loader nativescript-dev-webpack/tns-xml-loader should be added for *.xml/html files. + // Loader nativescript-dev-webpack/tns-xml-loader should be added for *.xml/html and *.ts files. new nsWebpack.ExcludeUnusedElementsPlugin(), //Angular AOT compiler @@ -109,7 +109,7 @@ module.exports = function (platform, destinationApp) { test: /\.html$|\.xml$/, loaders: [ "raw-loader", - 'nativescript-dev-webpack/tns-xml-loader' + "nativescript-dev-webpack/tns-xml-loader", ] }, // Root app.css file gets extracted with bundled dependencies @@ -133,6 +133,7 @@ module.exports = function (platform, destinationApp) { { test: /\.ts$/, loaders: [ + "nativescript-dev-webpack/tns-xml-loader", "nativescript-dev-webpack/tns-aot-loader", "@ngtools/webpack", ] From 473c080931a4fff1c9b461198ac6620505262e47 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 10:29:24 +0200 Subject: [PATCH 02/16] Exclude from mangling classes inheriting from Android native types. --- index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.js b/index.js index 1253ddc5..c3d2272a 100644 --- a/index.js +++ b/index.js @@ -135,6 +135,7 @@ exports.getAppPath = function (platform) { }; exports.uglifyMangleExcludes = [ + //Control names "ActionBar", "ActivityIndicator", "Button", @@ -155,6 +156,24 @@ exports.uglifyMangleExcludes = [ "TextView", "TimePicker", "View", + + //Android native class extenders + "TapAndDoubleTapGestureListener" + "SwipeGestureListener", + "PinchGestureListener", + "SwipeGestureListener", + "CustomTypefaceSpan", + "BroadcastReceiver", + "LruBitmapCache", + "DialogFragmentClassInner", + "SegmentedBarColorDrawable", + "OurTabHost", + "PagerAdapterClassInner", + "PageChangedListener", + "ListViewAdapter", + "WebViewClientClassInner", + "NativeScriptActivity", + "FragmentClass", ]; function getPackageJsonEntry() { From 5a803bb52bab4036b1194147563993f35ee77077 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 13:24:24 +0200 Subject: [PATCH 03/16] Fix a forgotten comma, and delete unused vars. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c3d2272a..7874ceb0 100644 --- a/index.js +++ b/index.js @@ -17,11 +17,11 @@ if (isAngular) { //HACK: changes the JSONP chunk eval function to `global["nativescriptJsonp"]` // applied to tns-java-classes.js only -exports.NativeScriptJsonpPlugin = function (options) { +exports.NativeScriptJsonpPlugin = function () { }; exports.NativeScriptJsonpPlugin.prototype.apply = function (compiler) { - compiler.plugin("compilation", function (compilation, params) { + compiler.plugin("compilation", function (compilation) { compilation.plugin("optimize-chunk-assets", function (chunks, callback) { chunks.forEach(function (chunk) { chunk.files.forEach(function (file) { @@ -158,7 +158,7 @@ exports.uglifyMangleExcludes = [ "View", //Android native class extenders - "TapAndDoubleTapGestureListener" + "TapAndDoubleTapGestureListener", "SwipeGestureListener", "PinchGestureListener", "SwipeGestureListener", From 0ad2ffa8df36cad99872ef8e71c1674e6a33254a Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 14:13:09 +0200 Subject: [PATCH 04/16] Remove a console.log from GenerateBundleStarterPlugin. --- index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.js b/index.js index 7874ceb0..b99e8884 100644 --- a/index.js +++ b/index.js @@ -85,8 +85,6 @@ exports.GenerateBundleStarterPlugin.prototype = { plugin.webpackContext = compiler.options.context; compiler.plugin("emit", function (compilation, cb) { - console.log(" GenerateBundleStarterPlugin: " + plugin.webpackContext); - compilation.assets["package.json"] = plugin.generatePackageJson(); compilation.assets["starter.js"] = plugin.generateStarterModule(); From 99581919a9f9bb35651fac152d332ed0994e4445 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 15:13:06 +0200 Subject: [PATCH 05/16] Add iOS native extenders to mangle exclude list. --- index.js | 67 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index b99e8884..60f1fb47 100644 --- a/index.js +++ b/index.js @@ -156,22 +156,67 @@ exports.uglifyMangleExcludes = [ "View", //Android native class extenders - "TapAndDoubleTapGestureListener", - "SwipeGestureListener", - "PinchGestureListener", - "SwipeGestureListener", - "CustomTypefaceSpan", "BroadcastReceiver", - "LruBitmapCache", + "CustomTypefaceSpan", "DialogFragmentClassInner", - "SegmentedBarColorDrawable", + "FragmentClass", + "ListViewAdapter", + "LruBitmapCache", + "NativeScriptActivity", "OurTabHost", - "PagerAdapterClassInner", "PageChangedListener", - "ListViewAdapter", + "PagerAdapterClassInner", + "PinchGestureListener", + "SegmentedBarColorDrawable", + "SwipeGestureListener", + "SwipeGestureListener", + "TapAndDoubleTapGestureListener", "WebViewClientClassInner", - "NativeScriptActivity", - "FragmentClass", + + //iOS native class extenders + "AnimatedTransitioning", + "AnimationDelegateImpl", + "DataSource", + "FrameHandlerImpl", + "ListPickerDataSource", + "ListPickerDelegateImpl", + "ListViewCell", + "LocationListenerImpl", + "NSURLSessionTaskDelegateImpl", + "NotificationObserver", + "ObserverClass", + "Responder", + "SelectionHandlerImpl", + "SliderChangeHandlerImpl", + "SwitchChangeHandlerImpl", + "TapBarItemHandlerImpl", + "TapHandlerImpl", + "TimerTargetImpl", + "TouchGestureRecognizer", + "TransitionDelegate", + "UIActionSheetDelegateImpl", + "UIAlertViewDelegateImpl", + "UIDatePickerChangeHandlerImpl", + "UIDocumentInteractionControllerDelegateImpl", + "UIGestureRecognizerDelegateImpl", + "UIGestureRecognizerImpl", + "UIImagePickerControllerDelegateImpl", + "UINavigationControllerAnimatedDelegate", + "UINavigationControllerDelegateImpl", + "UINavigationControllerImpl", + "UIScrollViewDelegateImpl", + "UISearchBarDelegateImpl", + "UITabBarControllerDelegateImpl", + "UITabBarControllerImpl", + "UITableViewDelegateImpl", + "UITableViewRowHeightDelegateImpl", + "UITextFieldDelegateImpl", + "UITextFieldImpl", + "UITextViewDelegateImpl", + "UITimePickerChangeHandlerImpl", + "UIViewControllerImpl", + "UIWebViewDelegateImpl", + "Window", ]; function getPackageJsonEntry() { From 47142bc5488f1441648d5324212de9dfbd5d5e7c Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 15:14:30 +0200 Subject: [PATCH 06/16] Fix a jshint warning about global.ELEMENT_REGISTRY --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 60f1fb47..b76690df 100644 --- a/index.js +++ b/index.js @@ -56,8 +56,8 @@ exports.ExcludeUnusedElementsPlugin.prototype.apply = function (compiler) { if (result.context.indexOf("tns-core-modules") === -1) { if (result.contextInfo.issuer && - result.contextInfo.issuer.indexOf("element-registry") !== -1 && global["ELEMENT_REGISTRY"] && - !global["ELEMENT_REGISTRY"][result.request]) { + result.contextInfo.issuer.indexOf("element-registry") !== -1 && global.ELEMENT_REGISTRY && + !global.ELEMENT_REGISTRY[result.request]) { return callback(); } else { @@ -65,8 +65,8 @@ exports.ExcludeUnusedElementsPlugin.prototype.apply = function (compiler) { } } - if (result.contextInfo.issuer.indexOf("bundle-entry-points") !== -1 && global["ELEMENT_REGISTRY"] && - !global["ELEMENT_REGISTRY"][result.request]) { + if (result.contextInfo.issuer.indexOf("bundle-entry-points") !== -1 && global.ELEMENT_REGISTRY && + !global.ELEMENT_REGISTRY[result.request]) { return callback(); } From f7455c964c49498f6aa1aea1e8ce151a25fc3091 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 19 Jan 2017 15:19:24 +0200 Subject: [PATCH 07/16] Set minimize=true to loader options when --uglify passed. --- webpack.common.js.angular.template | 4 ++++ webpack.common.js.nativescript.template | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/webpack.common.js.angular.template b/webpack.common.js.angular.template index 725c4c1f..c572205b 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -60,6 +60,10 @@ module.exports = function (platform, destinationApp) { ]; if (process.env.npm_config_uglify) { + plugins.push(new webpack.LoaderOptionsPlugin({ + minimize: true + })); + //Work around an Android issue by setting compress = false var compress = platform !== "android"; plugins.push(new webpack.optimize.UglifyJsPlugin({ diff --git a/webpack.common.js.nativescript.template b/webpack.common.js.nativescript.template index be887e3b..903bc004 100644 --- a/webpack.common.js.nativescript.template +++ b/webpack.common.js.nativescript.template @@ -47,6 +47,10 @@ module.exports = function (platform, destinationApp) { ]; if (process.env.npm_config_uglify) { + plugins.push(new webpack.LoaderOptionsPlugin({ + minimize: true + })); + //Work around an Android issue by setting compress = false var compress = platform !== "android"; plugins.push(new webpack.optimize.UglifyJsPlugin({ From af81fd7f357de134655f48ba234f2db0904831cd Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 20 Jan 2017 15:24:03 +0200 Subject: [PATCH 08/16] Extract installation code to the 'installer' module. Add an `install-ns-webpack` binary. --- bin/install-ns-webpack | 2 + bin/install-ns-webpack.cmd | 1 + installer.js | 155 +++++++++++++++++++++++++++++++++++++ package.json | 3 + postinstall.js | 147 +---------------------------------- 5 files changed, 165 insertions(+), 143 deletions(-) create mode 100644 bin/install-ns-webpack create mode 100644 bin/install-ns-webpack.cmd create mode 100644 installer.js diff --git a/bin/install-ns-webpack b/bin/install-ns-webpack new file mode 100644 index 00000000..5fe876f8 --- /dev/null +++ b/bin/install-ns-webpack @@ -0,0 +1,2 @@ +#!/usr/bin/env node +var installer = require("../installer"); diff --git a/bin/install-ns-webpack.cmd b/bin/install-ns-webpack.cmd new file mode 100644 index 00000000..5de779b8 --- /dev/null +++ b/bin/install-ns-webpack.cmd @@ -0,0 +1 @@ +@node %~dp0\install-ns-webpack %* diff --git a/installer.js b/installer.js new file mode 100644 index 00000000..20ed50ad --- /dev/null +++ b/installer.js @@ -0,0 +1,155 @@ +var path = require("path"); +var fs = require("fs"); +var childProcess = require("child_process"); + +var projectDir = path.dirname(path.dirname(__dirname)); +var appDir = path.join(projectDir, "app"); + +var packageJsonPath = path.join(projectDir, "package.json"); +var packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); + +var isAngular = Object.keys(packageJson.dependencies).filter(function (dependency) { + return /^@angular\b/.test(dependency); +}).length > 0; + +var isTypeScript = fs.existsSync(path.join(projectDir, "tsconfig.json")); +if (isAngular) { + isTypeScript = true; +} + +function addProjectFiles() { + copyProjectTemplate("webpack.android.js.template", "webpack.android.js"); + copyProjectTemplate("webpack.ios.js.template", "webpack.ios.js"); + + if (isAngular) { + copyProjectTemplate("webpack.common.js.angular.template", "webpack.common.js"); + copyProjectTemplate("tsconfig.aot.json.template", "tsconfig.aot.json"); + } else { + copyProjectTemplate("webpack.common.js.nativescript.template", "webpack.common.js"); + } + + copyAppTemplate("vendor-platform.android.ts.template", tsOrJs("vendor-platform.android")); + copyAppTemplate("vendor-platform.ios.ts.template", tsOrJs("vendor-platform.ios")); + if (isAngular) { + copyAppTemplate("vendor.ts.angular.template", tsOrJs("vendor")); + } else { + copyAppTemplate("vendor.ts.nativescript.template", tsOrJs("vendor")); + } +} +exports.addProjectFiles = addProjectFiles; + +function addNpmScripts() { + addPlatformScript(packageJson, "clean-[PLATFORM]", "tns clean-app [PLATFORM]"); + addPlatformScript(packageJson, "prewebpack-[PLATFORM]", "npm run clean-[PLATFORM]"); + addPlatformScript(packageJson, "webpack-[PLATFORM]", "webpack --config=webpack.[PLATFORM].js --progress"); + addPlatformScript(packageJson, "prestart-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); + addPlatformScript(packageJson, "start-[PLATFORM]-bundle", "tns run [PLATFORM] --bundle --disable-npm-install"); + addPlatformScript(packageJson, "prebuild-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); + addPlatformScript(packageJson, "build-[PLATFORM]-bundle", "tns build [PLATFORM] --bundle --disable-npm-install"); +} +exports.addNpmScripts = addNpmScripts; + +function addProjectDependencies() { + configureDevDependencies(packageJson, function (add) { + add("webpack", "~2.1.0-beta.27"); + add("webpack-sources", "~0.1.3"); + add("copy-webpack-plugin", "~3.0.1"); + add("raw-loader", "~0.5.1"); + add("nativescript-css-loader", "~0.26.0"); + add("resolve-url-loader", "~1.6.0"); + add("extract-text-webpack-plugin", "~2.0.0-beta.4"); + + if (isAngular) { + add("@angular/compiler-cli", "2.4.3"); + add("@ngtools/webpack", "1.2.1"); + add("typescript", "^2.0.10"); + add("htmlparser2", "~3.9.2"); + } else { + add("awesome-typescript-loader", "~3.0.0-beta.9"); + } + }); +} +exports.addProjectDependencies = addProjectDependencies; + + +function addPlatformScript(packageJson, nameTemplate, commandTemplate) { + if (!packageJson.scripts) { + packageJson.scripts = {}; + } + + var scripts = packageJson.scripts; + ["android", "ios"].forEach(function (platform) { + var name = nameTemplate.replace(/\[PLATFORM\]/g, platform); + var command = commandTemplate.replace(/\[PLATFORM\]/g, platform); + if (!scripts[name]) { + scripts[name] = command; + console.log("Registering script: " + name); + } + }); +} + +function configureDevDependencies(packageJson, adderCallback) { + var pendingNpmInstall = false; + if (!packageJson.devDependencies) { + packageJson.devDependencies = {}; + } + var dependencies = packageJson.devDependencies; + + adderCallback(function (name, version) { + if (!dependencies[name]) { + dependencies[name] = version; + console.info("Adding dev dependency: " + name + "@" + version); + pendingNpmInstall = true; + } else { + console.info("Dev dependency: '" + name + "' already added. Leaving version: " + dependencies[name]); + } + }); + + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); + + if (pendingNpmInstall) { + console.info("Installing new dependencies..."); + //Run `npm install` after everything else. + setTimeout(function () { + var spawnArgs = []; + if (/^win/.test(process.platform)) { + spawnArgs = ["cmd.exe", ["/c", "npm", "install"]]; + } else { + spawnArgs = ["npm", ["install"]]; + } + spawnArgs.push({ cwd: projectDir, stdio: "inherit" }); + var npm = childProcess.spawn.apply(null, spawnArgs); + npm.on("close", function (code) { + process.exit(code); + }); + }, 100); + } +} + +function tsOrJs(name) { + if (isTypeScript) { + return name + ".ts"; + } else { + return name + ".js"; + } +} + +function copyProjectTemplate(templateName, projectPath) { + var destinationPath = path.join(projectDir, projectPath); + copyTemplate(templateName, destinationPath); +} + +function copyAppTemplate(templateName, appPath) { + var destinationPath = path.join(appDir, appPath); + copyTemplate(templateName, destinationPath); +} + +function copyTemplate(templateName, destinationPath) { + var templatePath = path.join(__dirname, templateName); + // Create destination file, only if not present. + if (!fs.existsSync(destinationPath)) { + console.log("Creating: " + destinationPath); + var content = fs.readFileSync(templatePath, "utf8"); + fs.writeFileSync(destinationPath, content); + } +} diff --git a/package.json b/package.json index f1257e66..ef113b85 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "scripts": { "postinstall": "node postinstall.js" }, + "bin": { + "install-ns-webpack": "./bin/install-ns-webpack" + }, "dependencies": {}, "devDependencies": {} } diff --git a/postinstall.js b/postinstall.js index 1f4dfed0..d92ae7b4 100644 --- a/postinstall.js +++ b/postinstall.js @@ -1,144 +1,5 @@ -var path = require("path"); -var fs = require("fs"); -var childProcess = require("child_process"); +var installer = require("./installer"); -var projectDir = path.dirname(path.dirname(__dirname)); -var appDir = path.join(projectDir, "app"); - -var packageJsonPath = path.join(projectDir, "package.json"); -var packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); - -var isAngular = Object.keys(packageJson.dependencies).filter(function (dependency) { - return /^@angular\b/.test(dependency); -}).length > 0; - -var isTypeScript = fs.existsSync(path.join(projectDir, "tsconfig.json")); -if (isAngular) { - isTypeScript = true; -} - -copyProjectTemplate("webpack.android.js.template", "webpack.android.js"); -copyProjectTemplate("webpack.ios.js.template", "webpack.ios.js"); - -if (isAngular) { - copyProjectTemplate("webpack.common.js.angular.template", "webpack.common.js"); - copyProjectTemplate("tsconfig.aot.json.template", "tsconfig.aot.json"); -} else { - copyProjectTemplate("webpack.common.js.nativescript.template", "webpack.common.js"); -} - -copyAppTemplate("vendor-platform.android.ts.template", tsOrJs("vendor-platform.android")); -copyAppTemplate("vendor-platform.ios.ts.template", tsOrJs("vendor-platform.ios")); -if (isAngular) { - copyAppTemplate("vendor.ts.angular.template", tsOrJs("vendor")); -} else { - copyAppTemplate("vendor.ts.nativescript.template", tsOrJs("vendor")); -} - -addPlatformScript(packageJson, "clean-[PLATFORM]", "tns clean-app [PLATFORM]"); -addPlatformScript(packageJson, "prewebpack-[PLATFORM]", "npm run clean-[PLATFORM]"); -addPlatformScript(packageJson, "webpack-[PLATFORM]", "webpack --config=webpack.[PLATFORM].js --progress"); -addPlatformScript(packageJson, "prestart-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); -addPlatformScript(packageJson, "start-[PLATFORM]-bundle", "tns run [PLATFORM] --bundle --disable-npm-install"); -addPlatformScript(packageJson, "prebuild-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); -addPlatformScript(packageJson, "build-[PLATFORM]-bundle", "tns build [PLATFORM] --bundle --disable-npm-install"); - -configureDevDependencies(packageJson, function (add) { - add("webpack", "~2.1.0-beta.27"); - add("webpack-sources", "~0.1.3"); - add("copy-webpack-plugin", "~3.0.1"); - add("raw-loader", "~0.5.1"); - add("nativescript-css-loader", "~0.26.0"); - add("resolve-url-loader", "~1.6.0"); - add("extract-text-webpack-plugin", "~2.0.0-beta.4"); - - if (isAngular) { - add("@angular/compiler-cli", "2.4.3"); - add("@ngtools/webpack", "1.2.1"); - add("typescript", "^2.0.10"); - add("htmlparser2", "~3.9.2"); - } else { - add("awesome-typescript-loader", "~3.0.0-beta.9"); - } -}); - -fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4)); - -function addPlatformScript(packageJson, nameTemplate, commandTemplate) { - if (!packageJson.scripts) { - packageJson.scripts = {}; - } - - var scripts = packageJson.scripts; - ["android", "ios"].forEach(function (platform) { - var name = nameTemplate.replace(/\[PLATFORM\]/g, platform); - var command = commandTemplate.replace(/\[PLATFORM\]/g, platform); - if (!scripts[name]) { - scripts[name] = command; - console.log("Registering script: " + name); - } - }); -} - -function configureDevDependencies(packageJson, adderCallback) { - var pendingNpmInstall = false; - if (!packageJson.devDependencies) { - packageJson.devDependencies = {}; - } - var dependencies = packageJson.devDependencies; - - adderCallback(function (name, version) { - if (!dependencies[name]) { - dependencies[name] = version; - console.info("Adding dev dependency: " + name + "@" + version); - pendingNpmInstall = true; - } else { - console.info("Dev dependency: '" + name + "' already added. Leaving version: " + dependencies[name]); - } - }); - - if (pendingNpmInstall) { - console.info("Installing new dependencies..."); - //Run `npm install` after everything else. - setTimeout(function () { - var spawnArgs = []; - if (/^win/.test(process.platform)) { - spawnArgs = ["cmd.exe", ["/c", "npm", "install"]]; - } else { - spawnArgs = ["npm", ["install"]]; - } - spawnArgs.push({ cwd: projectDir, stdio: "inherit" }); - var npm = childProcess.spawn.apply(null, spawnArgs); - npm.on("close", function (code) { - process.exit(code); - }); - }, 100); - } -} - -function tsOrJs(name) { - if (isTypeScript) { - return name + ".ts"; - } else { - return name + ".js"; - } -} - -function copyProjectTemplate(templateName, projectPath) { - var destinationPath = path.join(projectDir, projectPath); - copyTemplate(templateName, destinationPath); -} - -function copyAppTemplate(templateName, appPath) { - var destinationPath = path.join(appDir, appPath); - copyTemplate(templateName, destinationPath); -} - -function copyTemplate(templateName, destinationPath) { - var templatePath = path.join(__dirname, templateName); - // Create destination file, only if not present. - if (!fs.existsSync(destinationPath)) { - var content = fs.readFileSync(templatePath, "utf8"); - fs.writeFileSync(destinationPath, content); - } -} +installer.addProjectFiles(); +installer.addNpmScripts(); +installer.addProjectDependencies(); From 226f354aee2770429006659a80cf1f75a33e0bd6 Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Fri, 20 Jan 2017 16:06:09 +0200 Subject: [PATCH 09/16] fix: exclude from mangling EditableTextBase (#60) Uglify shouldn't mangle EditableTextBase, because it breaks the hint formatting. fixes https://github.com/NativeScript/sample-Groceries/pull/202 --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index b76690df..73c0460b 100644 --- a/index.js +++ b/index.js @@ -138,6 +138,7 @@ exports.uglifyMangleExcludes = [ "ActivityIndicator", "Button", "DatePicker", + "EditableTextBase", "Image", "Label", "ListPicker", From e484d9e1cab0e6f79b71c518a5dae724a37f7309 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 20 Jan 2017 16:28:54 +0200 Subject: [PATCH 10/16] Add an uninstaller script (triggered manually). --- bin/install-ns-webpack | 4 + bin/remove-ns-webpack | 6 ++ bin/remove-ns-webpack.cmd | 1 + installer.js | 173 ++++++++++++++++++++++++++++++-------- package.json | 3 +- 5 files changed, 151 insertions(+), 36 deletions(-) create mode 100644 bin/remove-ns-webpack create mode 100644 bin/remove-ns-webpack.cmd diff --git a/bin/install-ns-webpack b/bin/install-ns-webpack index 5fe876f8..01adbf50 100644 --- a/bin/install-ns-webpack +++ b/bin/install-ns-webpack @@ -1,2 +1,6 @@ #!/usr/bin/env node var installer = require("../installer"); + +installer.addProjectFiles(); +installer.addNpmScripts(); +installer.addProjectDependencies(); diff --git a/bin/remove-ns-webpack b/bin/remove-ns-webpack new file mode 100644 index 00000000..d3daba03 --- /dev/null +++ b/bin/remove-ns-webpack @@ -0,0 +1,6 @@ +#!/usr/bin/env node +var installer = require("../installer"); + +installer.removeProjectFiles(); +installer.removeNpmScripts(); +installer.removeProjectDependencies(); diff --git a/bin/remove-ns-webpack.cmd b/bin/remove-ns-webpack.cmd new file mode 100644 index 00000000..5de779b8 --- /dev/null +++ b/bin/remove-ns-webpack.cmd @@ -0,0 +1 @@ +@node %~dp0\install-ns-webpack %* diff --git a/installer.js b/installer.js index 20ed50ad..7b2eefe9 100644 --- a/installer.js +++ b/installer.js @@ -17,60 +17,135 @@ if (isAngular) { isTypeScript = true; } -function addProjectFiles() { - copyProjectTemplate("webpack.android.js.template", "webpack.android.js"); - copyProjectTemplate("webpack.ios.js.template", "webpack.ios.js"); +function getProjectTemplates() { + var templates = { + "webpack.android.js.template": "webpack.android.js", + "webpack.ios.js.template": "webpack.ios.js", + }; if (isAngular) { - copyProjectTemplate("webpack.common.js.angular.template", "webpack.common.js"); - copyProjectTemplate("tsconfig.aot.json.template", "tsconfig.aot.json"); + templates["webpack.common.js.angular.template"] = "webpack.common.js"; + templates["tsconfig.aot.json.template"] = "tsconfig.aot.json"; } else { - copyProjectTemplate("webpack.common.js.nativescript.template", "webpack.common.js"); + templates["webpack.common.js.nativescript.template"] = "webpack.common.js"; } + return templates; +} + +function getAppTemplates() { + var templates = { + "vendor-platform.android.ts.template": tsOrJs("vendor-platform.android"), + "vendor-platform.ios.ts.template": tsOrJs("vendor-platform.ios"), + }; - copyAppTemplate("vendor-platform.android.ts.template", tsOrJs("vendor-platform.android")); - copyAppTemplate("vendor-platform.ios.ts.template", tsOrJs("vendor-platform.ios")); if (isAngular) { - copyAppTemplate("vendor.ts.angular.template", tsOrJs("vendor")); + templates["vendor.ts.angular.template"] = tsOrJs("vendor"); } else { - copyAppTemplate("vendor.ts.nativescript.template", tsOrJs("vendor")); + templates["vendor.ts.nativescript.template"] = tsOrJs("vendor"); } + return templates; +} + +function addProjectFiles() { + var projectTemplates = getProjectTemplates(); + Object.keys(projectTemplates).forEach(function(templateName) { + var templateDestination = projectTemplates[templateName]; + copyProjectTemplate(templateName, templateDestination); + }); + + var appTemplates = getAppTemplates(); + Object.keys(appTemplates).forEach(function(templateName) { + var templateDestination = appTemplates[templateName]; + copyAppTemplate(templateName, templateDestination); + }); } exports.addProjectFiles = addProjectFiles; +function removeProjectFiles() { + var projectTemplates = getProjectTemplates(); + Object.keys(projectTemplates).forEach(function(templateName) { + var templateDestination = projectTemplates[templateName]; + deleteProjectFile(templateDestination); + }); + + var appTemplates = getAppTemplates(); + Object.keys(appTemplates).forEach(function(templateName) { + var templateDestination = appTemplates[templateName]; + deleteAppFile(templateDestination); + }); +} +exports.removeProjectFiles = removeProjectFiles; + +function getScriptTemplates() { + return { + "clean-[PLATFORM]": "tns clean-app [PLATFORM]", + "prewebpack-[PLATFORM]": "npm run clean-[PLATFORM]", + "webpack-[PLATFORM]": "webpack --config=webpack.[PLATFORM].js --progress", + "prestart-[PLATFORM]-bundle": "npm run webpack-[PLATFORM]", + "start-[PLATFORM]-bundle": "tns run [PLATFORM] --bundle --disable-npm-install", + "prebuild-[PLATFORM]-bundle": "npm run webpack-[PLATFORM]", + "build-[PLATFORM]-bundle": "tns build [PLATFORM] --bundle --disable-npm-install", + }; +} + function addNpmScripts() { - addPlatformScript(packageJson, "clean-[PLATFORM]", "tns clean-app [PLATFORM]"); - addPlatformScript(packageJson, "prewebpack-[PLATFORM]", "npm run clean-[PLATFORM]"); - addPlatformScript(packageJson, "webpack-[PLATFORM]", "webpack --config=webpack.[PLATFORM].js --progress"); - addPlatformScript(packageJson, "prestart-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); - addPlatformScript(packageJson, "start-[PLATFORM]-bundle", "tns run [PLATFORM] --bundle --disable-npm-install"); - addPlatformScript(packageJson, "prebuild-[PLATFORM]-bundle", "npm run webpack-[PLATFORM]"); - addPlatformScript(packageJson, "build-[PLATFORM]-bundle", "tns build [PLATFORM] --bundle --disable-npm-install"); + var scriptTemplates = getScriptTemplates(); + Object.keys(scriptTemplates).forEach(function(templateName) { + addPlatformScript(packageJson, templateName, scriptTemplates[templateName]); + }); } exports.addNpmScripts = addNpmScripts; +function removeNpmScripts() { + var scriptTemplates = getScriptTemplates(); + Object.keys(scriptTemplates).forEach(function(templateName) { + removePlatformScripts(packageJson, templateName); + }); +} +exports.removeNpmScripts = removeNpmScripts; + +function getProjectDependencies() { + var dependencies = { + "webpack": "~2.1.0-beta.27", + "webpack-sources": "~0.1.3", + "copy-webpack-plugin": "~3.0.1", + "raw-loader": "~0.5.1", + "nativescript-css-loader": "~0.26.0", + "resolve-url-loader": "~1.6.0", + "extract-text-webpack-plugin": "~2.0.0-beta.4", + }; + + if (isAngular) { + dependencies["@angular/compiler-cli"] = "2.4.3"; + dependencies["@ngtools/webpack"] = "1.2.1"; + dependencies["typescript"] = "^2.0.10"; + dependencies["htmlparser2"] = "~3.9.2"; + } else { + dependencies["awesome-typescript-loader"] = "~3.0.0-beta.9"; + } + return dependencies; +} + function addProjectDependencies() { configureDevDependencies(packageJson, function (add) { - add("webpack", "~2.1.0-beta.27"); - add("webpack-sources", "~0.1.3"); - add("copy-webpack-plugin", "~3.0.1"); - add("raw-loader", "~0.5.1"); - add("nativescript-css-loader", "~0.26.0"); - add("resolve-url-loader", "~1.6.0"); - add("extract-text-webpack-plugin", "~2.0.0-beta.4"); - - if (isAngular) { - add("@angular/compiler-cli", "2.4.3"); - add("@ngtools/webpack", "1.2.1"); - add("typescript", "^2.0.10"); - add("htmlparser2", "~3.9.2"); - } else { - add("awesome-typescript-loader", "~3.0.0-beta.9"); - } + var dependencies = getProjectDependencies(); + Object.keys(dependencies).forEach(function(dependencyName) { + add(dependencyName, dependencies[dependencyName]); + }); }); } exports.addProjectDependencies = addProjectDependencies; +function removeProjectDependencies() { + configureDevDependencies(packageJson, function (add, remove) { + var dependencies = getProjectDependencies(); + Object.keys(dependencies).forEach(function(dependencyName) { + remove(dependencyName); + }); + }); +} +exports.removeProjectDependencies = removeProjectDependencies; + function addPlatformScript(packageJson, nameTemplate, commandTemplate) { if (!packageJson.scripts) { @@ -82,12 +157,25 @@ function addPlatformScript(packageJson, nameTemplate, commandTemplate) { var name = nameTemplate.replace(/\[PLATFORM\]/g, platform); var command = commandTemplate.replace(/\[PLATFORM\]/g, platform); if (!scripts[name]) { - scripts[name] = command; console.log("Registering script: " + name); + scripts[name] = command; } }); } +function removePlatformScripts(packageJson, nameTemplate) { + if (!packageJson.scripts) { + return; + } + + var scripts = packageJson.scripts; + ["android", "ios"].forEach(function (platform) { + var name = nameTemplate.replace(/\[PLATFORM\]/g, platform); + console.log("Removing script: " + name); + delete scripts[name]; + }); +} + function configureDevDependencies(packageJson, adderCallback) { var pendingNpmInstall = false; if (!packageJson.devDependencies) { @@ -103,6 +191,9 @@ function configureDevDependencies(packageJson, adderCallback) { } else { console.info("Dev dependency: '" + name + "' already added. Leaving version: " + dependencies[name]); } + }, function(name) { + console.info("Removing dev dependency: " + name); + delete dependencies[name]; }); fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); @@ -139,16 +230,28 @@ function copyProjectTemplate(templateName, projectPath) { copyTemplate(templateName, destinationPath); } +function deleteProjectFile(projectPath) { + var destinationPath = path.join(projectDir, projectPath); + console.log("Deleting file: " + destinationPath); + fs.unlink(destinationPath); +} + function copyAppTemplate(templateName, appPath) { var destinationPath = path.join(appDir, appPath); copyTemplate(templateName, destinationPath); } +function deleteAppFile(appPath) { + var destinationPath = path.join(appDir, appPath); + console.log("Deleting file: " + destinationPath); + fs.unlink(destinationPath); +} + function copyTemplate(templateName, destinationPath) { var templatePath = path.join(__dirname, templateName); // Create destination file, only if not present. if (!fs.existsSync(destinationPath)) { - console.log("Creating: " + destinationPath); + console.log("Creating file: " + destinationPath); var content = fs.readFileSync(templatePath, "utf8"); fs.writeFileSync(destinationPath, content); } diff --git a/package.json b/package.json index ef113b85..e2698d71 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "postinstall": "node postinstall.js" }, "bin": { - "install-ns-webpack": "./bin/install-ns-webpack" + "install-ns-webpack": "./bin/install-ns-webpack", + "remove-ns-webpack": "./bin/remove-ns-webpack" }, "dependencies": {}, "devDependencies": {} From 79286a6f53570844fc2a8fd28c073221c920e7db Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 20 Jan 2017 17:05:40 +0200 Subject: [PATCH 11/16] Fix a crash on uninstall if target file doesn't exist. --- installer.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/installer.js b/installer.js index 7b2eefe9..9ab22a77 100644 --- a/installer.js +++ b/installer.js @@ -232,8 +232,7 @@ function copyProjectTemplate(templateName, projectPath) { function deleteProjectFile(projectPath) { var destinationPath = path.join(projectDir, projectPath); - console.log("Deleting file: " + destinationPath); - fs.unlink(destinationPath); + deleteFile(destinationPath); } function copyAppTemplate(templateName, appPath) { @@ -243,8 +242,14 @@ function copyAppTemplate(templateName, appPath) { function deleteAppFile(appPath) { var destinationPath = path.join(appDir, appPath); - console.log("Deleting file: " + destinationPath); - fs.unlink(destinationPath); + deleteFile(destinationPath); +} + +function deleteFile(destinationPath) { + if (fs.existsSync(destinationPath)) { + console.log("Deleting file: " + destinationPath); + fs.unlink(destinationPath); + } } function copyTemplate(templateName, destinationPath) { From 5c00f2d536e7318e33d6d57049f19fa37ca49a6c Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Tue, 31 Jan 2017 13:38:05 +0200 Subject: [PATCH 12/16] feat(deps): add support for webpack 2.2+ Add NodeGlobalsPlugin to prevent webpack from overriding the global property. --- installer.js | 6 +++--- nativescript-target/NsNodeGlobalsPlugin.js | 20 ++++++++++++++++++++ nativescript-target/index.js | 2 ++ webpack.common.js.angular.template | 1 - webpack.common.js.nativescript.template | 1 - 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 nativescript-target/NsNodeGlobalsPlugin.js diff --git a/installer.js b/installer.js index 9ab22a77..ebf97ea6 100644 --- a/installer.js +++ b/installer.js @@ -106,7 +106,7 @@ exports.removeNpmScripts = removeNpmScripts; function getProjectDependencies() { var dependencies = { - "webpack": "~2.1.0-beta.27", + "webpack": "2.2.0", "webpack-sources": "~0.1.3", "copy-webpack-plugin": "~3.0.1", "raw-loader": "~0.5.1", @@ -116,8 +116,8 @@ function getProjectDependencies() { }; if (isAngular) { - dependencies["@angular/compiler-cli"] = "2.4.3"; - dependencies["@ngtools/webpack"] = "1.2.1"; + dependencies["@angular/compiler-cli"] = "~2.4.3"; + dependencies["@ngtools/webpack"] = "1.2.4"; dependencies["typescript"] = "^2.0.10"; dependencies["htmlparser2"] = "~3.9.2"; } else { diff --git a/nativescript-target/NsNodeGlobalsPlugin.js b/nativescript-target/NsNodeGlobalsPlugin.js new file mode 100644 index 00000000..8774ce86 --- /dev/null +++ b/nativescript-target/NsNodeGlobalsPlugin.js @@ -0,0 +1,20 @@ +// HACK: Prevent webpack from replacing "global" +// Fixes StackOverflow error caused by DefinePlugin with webpack 2.2+ + +var ConstDependency = require("webpack/lib/dependencies/ConstDependency"); + +function NsNodeGlobalsPlugin() {} +NsNodeGlobalsPlugin.prototype.apply = function(compiler) { + compiler.plugin("compilation", function(compilation, params) { + params.normalModuleFactory.plugin("parser", function(parser, parserOptions) { + parser.plugin("expression global", function(expr) { + var dep = new ConstDependency("global", expr.range); + dep.loc = expr.loc; + this.state.current.addDependency(dep); + return true; + }); + }); + }); +}; + +module.exports = NsNodeGlobalsPlugin; diff --git a/nativescript-target/index.js b/nativescript-target/index.js index 68a5b519..b426b223 100644 --- a/nativescript-target/index.js +++ b/nativescript-target/index.js @@ -2,6 +2,7 @@ module.exports = function nativescriptTarget(compiler) { var options = this; var webpackLib = "webpack/lib"; + var NsNodeGlobalsPlugin = require("./NsNodeGlobalsPlugin"); // Custom template plugin var NsJsonpTemplatePlugin = require("./NsJsonpTemplatePlugin"); @@ -10,6 +11,7 @@ module.exports = function nativescriptTarget(compiler) { var LoaderTargetPlugin = require(webpackLib + "/LoaderTargetPlugin"); compiler.apply( + new NsNodeGlobalsPlugin(), new NsJsonpTemplatePlugin(options.output), new FunctionModulePlugin(options.output), new NodeSourcePlugin(options.node), diff --git a/webpack.common.js.angular.template b/webpack.common.js.angular.template index c572205b..e44be7df 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -27,7 +27,6 @@ module.exports = function (platform, destinationApp) { }), //Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ - global: "global", __dirname: "__dirname", "global.TNS_WEBPACK": "true", }), diff --git a/webpack.common.js.nativescript.template b/webpack.common.js.nativescript.template index 903bc004..c99d1cb7 100644 --- a/webpack.common.js.nativescript.template +++ b/webpack.common.js.nativescript.template @@ -26,7 +26,6 @@ module.exports = function (platform, destinationApp) { }), //Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ - global: "global", __dirname: "__dirname", "global.TNS_WEBPACK": "true", }), From 9c281b8ee804dcfe4839dd1eb349026bb44f9e8e Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Wed, 1 Feb 2017 16:04:10 +0200 Subject: [PATCH 13/16] Avoid a stack overflow with webpack 2.2.0 by not using __dirname. Now set by the NsNodeGlobals plugin instead of DefinePlugin. --- nativescript-target/NsNodeGlobalsPlugin.js | 6 ++++++ webpack.common.js.angular.template | 1 - webpack.common.js.nativescript.template | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nativescript-target/NsNodeGlobalsPlugin.js b/nativescript-target/NsNodeGlobalsPlugin.js index 8774ce86..217c6ba0 100644 --- a/nativescript-target/NsNodeGlobalsPlugin.js +++ b/nativescript-target/NsNodeGlobalsPlugin.js @@ -13,6 +13,12 @@ NsNodeGlobalsPlugin.prototype.apply = function(compiler) { this.state.current.addDependency(dep); return true; }); + parser.plugin("expression __dirname", function(expr) { + var dep = new ConstDependency("__dirname", expr.range); + dep.loc = expr.loc; + this.state.current.addDependency(dep); + return true; + }); }); }); }; diff --git a/webpack.common.js.angular.template b/webpack.common.js.angular.template index e44be7df..550163c3 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -27,7 +27,6 @@ module.exports = function (platform, destinationApp) { }), //Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ - __dirname: "__dirname", "global.TNS_WEBPACK": "true", }), //Copy assets to out dir. Add your own globs as needed. diff --git a/webpack.common.js.nativescript.template b/webpack.common.js.nativescript.template index c99d1cb7..5f331941 100644 --- a/webpack.common.js.nativescript.template +++ b/webpack.common.js.nativescript.template @@ -26,7 +26,6 @@ module.exports = function (platform, destinationApp) { }), //Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ - __dirname: "__dirname", "global.TNS_WEBPACK": "true", }), //Copy assets to out dir. Add your own globs as needed. From 864a778feee1f2ab25849abd37555a0c78c910f0 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Wed, 1 Feb 2017 16:04:59 +0200 Subject: [PATCH 14/16] Use double quotes everywhere. --- vendor-platform.android.ts.template | 14 +++++++------- vendor.ts.angular.template | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/vendor-platform.android.ts.template b/vendor-platform.android.ts.template index e0679c8b..ba9742fd 100644 --- a/vendor-platform.android.ts.template +++ b/vendor-platform.android.ts.template @@ -1,12 +1,12 @@ -//Resolve JavaScript classes that extend a Java class, and need to resolve -//their JavaScript module from a bundled script. For example: -//NativeScriptApplication, NativeScriptActivity, etc. +// Resolve JavaScript classes that extend a Java class, and need to resolve +// their JavaScript module from a bundled script. For example: +// NativeScriptApplication, NativeScriptActivity, etc. // -//This module gets bundled together with the rest of the app code and the -//`require` calls get resolved to the correct bundling import call. +// This module gets bundled together with the rest of the app code and the +// `require` calls get resolved to the correct bundling import call. // -//At runtime the module gets loaded *before* the rest of the app code, so code -//placed here needs to be careful about its dependencies. +// At runtime the module gets loaded *before* the rest of the app code, so code +// placed here needs to be careful about its dependencies. require("application"); require("ui/frame"); diff --git a/vendor.ts.angular.template b/vendor.ts.angular.template index 6f23bd36..0d969654 100644 --- a/vendor.ts.angular.template +++ b/vendor.ts.angular.template @@ -1,13 +1,13 @@ require("./vendor-platform"); -require('reflect-metadata'); -require('@angular/platform-browser'); -require('@angular/core'); -require('@angular/common'); -require('@angular/forms'); -require('@angular/http'); -require('@angular/router'); +require("reflect-metadata"); +require("@angular/platform-browser"); +require("@angular/core"); +require("@angular/common"); +require("@angular/forms"); +require("@angular/http"); +require("@angular/router"); -require('nativescript-angular/platform-static'); -require('nativescript-angular/forms'); -require('nativescript-angular/router'); +require("nativescript-angular/platform-static"); +require("nativescript-angular/forms"); +require("nativescript-angular/router"); From 75bdeb1471f88c9b418683ae2b3a2833800510e9 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Wed, 1 Feb 2017 17:18:49 +0200 Subject: [PATCH 15/16] fix(uglify): Exclude layout classes from mangling. --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 73c0460b..92c44433 100644 --- a/index.js +++ b/index.js @@ -134,13 +134,19 @@ exports.getAppPath = function (platform) { exports.uglifyMangleExcludes = [ //Control names + "AbsoluteLayout", "ActionBar", "ActivityIndicator", "Button", "DatePicker", + "DockLayout", "EditableTextBase", + "FlexboxLayout", + "GridLayout", "Image", "Label", + "Layout", + "LayoutBase", "ListPicker", "ListView", "Page", @@ -148,6 +154,7 @@ exports.uglifyMangleExcludes = [ "SearchBar", "SegmentedBar", "Slider", + "StackLayout", "Switch", "TabView", "TextBase", @@ -155,6 +162,7 @@ exports.uglifyMangleExcludes = [ "TextView", "TimePicker", "View", + "WrapLayout", //Android native class extenders "BroadcastReceiver", From 8426b33914075a9d8aa506b9d85af8e180c588ab Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Wed, 1 Feb 2017 18:10:43 +0200 Subject: [PATCH 16/16] 0.3.3 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e2698d71..862e4bc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.3.2", + "version": "0.3.3", "main": "index", "description": "", "homepage": "http://www.telerik.com", @@ -17,8 +17,8 @@ "postinstall": "node postinstall.js" }, "bin": { - "install-ns-webpack": "./bin/install-ns-webpack", - "remove-ns-webpack": "./bin/remove-ns-webpack" + "install-ns-webpack": "./bin/install-ns-webpack", + "remove-ns-webpack": "./bin/remove-ns-webpack" }, "dependencies": {}, "devDependencies": {}