diff --git a/bin/ns-bundle b/bin/ns-bundle index e2973b2c..72008625 100644 --- a/bin/ns-bundle +++ b/bin/ns-bundle @@ -102,7 +102,7 @@ function getCommand(flags) { function spawnChildProcess(command, ...args) { return new Promise((resolve, reject) => { - const childProcess = spawn(command, args, { stdio: "inherit", pwd: PROJECT_DIR }); + const childProcess = spawn(command, args, { stdio: "inherit", pwd: PROJECT_DIR, shell: true }); childProcess.on("close", (code) => { if (code === 0) { diff --git a/index.js b/index.js index 900e88fb..e8946ee8 100644 --- a/index.js +++ b/index.js @@ -40,41 +40,6 @@ exports.NativeScriptJsonpPlugin.prototype.apply = function (compiler) { }); }; -exports.ExcludeUnusedElementsPlugin = function () { -}; - -exports.ExcludeUnusedElementsPlugin.prototype.apply = function (compiler) { - compiler.plugin("normal-module-factory", function (nmf) { - nmf.plugin("before-resolve", function (result, callback) { - if (!result) { - return callback(); - } - - if (result.request === "globals" || result.request === "ui/core/view") { - return callback(null, result); - } - - 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]) { - return callback(); - - } else { - return callback(null, result); - } - } - - if (result.contextInfo.issuer.indexOf("bundle-entry-points") !== -1 && global.ELEMENT_REGISTRY && - !global.ELEMENT_REGISTRY[result.request]) { - return callback(); - } - - return callback(null, result); - }); - }); -}; - exports.GenerateBundleStarterPlugin = function (bundles) { this.bundles = bundles; }; diff --git a/installer.js b/installer.js index 912b427d..ef745d5e 100644 --- a/installer.js +++ b/installer.js @@ -131,9 +131,8 @@ function getProjectDependencies() { if (isAngular) { dependencies["@angular/compiler-cli"] = "~2.4.3"; - dependencies["@ngtools/webpack"] = "1.2.4"; + dependencies["@ngtools/webpack"] = "1.2.10"; dependencies["typescript"] = "^2.0.10"; - dependencies["htmlparser2"] = "~3.9.2"; } else { dependencies["awesome-typescript-loader"] = "~3.0.0-beta.9"; } diff --git a/package.json b/package.json index a48482e8..8b1858ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "0.3.4", + "version": "0.3.5", "main": "index", "description": "", "homepage": "http://www.telerik.com", diff --git a/resource-resolver-plugins/StyleUrlResolvePlugin.js b/resource-resolver-plugins/StyleUrlResolvePlugin.js index fefbf109..0d13d9d7 100644 --- a/resource-resolver-plugins/StyleUrlResolvePlugin.js +++ b/resource-resolver-plugins/StyleUrlResolvePlugin.js @@ -50,7 +50,7 @@ const StyleUrlResolvePlugin = (function() { } StyleUrlResolvePlugin.prototype.traverseDecoratorArguments = function(args) { - args.forEach(arg => this.traverseProperties(arg.properties)); + args.forEach(arg => arg.properties && this.traverseProperties(arg.properties)); } StyleUrlResolvePlugin.prototype.traverseProperties = function(properties) { diff --git a/tns-xml-loader.js b/tns-xml-loader.js deleted file mode 100644 index a580a395..00000000 --- a/tns-xml-loader.js +++ /dev/null @@ -1,81 +0,0 @@ -var htmlparser = require("htmlparser2"); - -var UI_PATH = "ui/"; - -var MODULES = { - "TabViewItem": "ui/tab-view", - "FormattedString": "text/formatted-string", - "Span": "text/span", - "ActionItem": "ui/action-bar", - "NavigationButton": "ui/action-bar", - "SegmentedBarItem": "ui/segmented-bar", -}; - -var ELEMENT_REGISTRY = "ELEMENT_REGISTRY"; - -if (!global[ELEMENT_REGISTRY]) { - global[ELEMENT_REGISTRY] = { - "ui/proxy-view-container": "ProxyViewContainer", - "ui/placeholder": "Placeholder" - }; -} - -function parseResource(source, map) { - this.cacheable(); - - 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(templateSource); - parser.end(); - - 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/; - let match = templateMatcher.exec(source); - - return match ? match[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 266bcc3e..b05c860e 100644 --- a/webpack.common.js.angular.template +++ b/webpack.common.js.angular.template @@ -44,10 +44,6 @@ module.exports = function (platform, destinationApp) { "./bundle", ]), - // Exclude explicitly required but never declared in XML elements. - // Loader nativescript-dev-webpack/tns-xml-loader should be added for *.xml/html and *.ts files. - new nsWebpack.ExcludeUnusedElementsPlugin(), - //Angular AOT compiler new AotPlugin({ tsConfigPath: "tsconfig.aot.json", @@ -104,6 +100,7 @@ module.exports = function (platform, destinationApp) { "http": false, "timers": false, "setImmediate": false, + "fs": "empty", }, module: { loaders: [ @@ -111,7 +108,6 @@ module.exports = function (platform, destinationApp) { test: /\.html$|\.xml$/, loaders: [ "raw-loader", - "nativescript-dev-webpack/tns-xml-loader", ] }, // Root app.css file gets extracted with bundled dependencies @@ -137,7 +133,6 @@ module.exports = function (platform, destinationApp) { loaders: [ "nativescript-dev-webpack/tns-aot-loader", "@ngtools/webpack", - "nativescript-dev-webpack/tns-xml-loader", ] }, // SASS support diff --git a/webpack.common.js.nativescript.template b/webpack.common.js.nativescript.template index 5f331941..531f7327 100644 --- a/webpack.common.js.nativescript.template +++ b/webpack.common.js.nativescript.template @@ -90,6 +90,7 @@ module.exports = function (platform, destinationApp) { "http": false, "timers": false, "setImmediate": false, + "fs": "empty", }, module: { loaders: [