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

release: cut the 0.18.4 release #739

Merged
merged 3 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="0.18.4"></a>
## [0.18.4](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.18.3...0.18.4) (2018-12-14)


### Bug Fixes

* **JS/TS:** use webpack resolver instead of Node.js resolver ([#681](https://github.com/NativeScript/nativescript-dev-webpack/issues/681)) ([9f1efff](https://github.com/NativeScript/nativescript-dev-webpack/commit/9f1efff))



<a name="0.18.3"></a>
## [0.18.3](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.18.2...0.18.3) (2018-12-10)

Expand Down
1 change: 0 additions & 1 deletion dependencyManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function removeObsoleteDeps(packageJson) {
"raw-loader",
"css-loader",
"nativescript-worker-loader",
"extract-text-webpack-plugin",
"uglifyjs-webpack-plugin",
"@angular-devkit/core",
"resolve-url-loader",
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-dev-webpack",
"version": "0.18.3",
"version": "0.18.4",
"main": "index",
"description": "",
"homepage": "http://www.telerik.com",
Expand Down Expand Up @@ -74,6 +74,11 @@
"generate-android-snapshot": "./bin/generate-android-snapshot"
},
"dependencies": {
"@angular-devkit/core": "~7.1.0",
"awesome-typescript-loader": "~5.2.1",
"clean-webpack-plugin": "~1.0.0",
"copy-webpack-plugin": "~4.6.0",
"css-loader": "~1.0.0",
"global-modules-path": "2.0.0",
"minimatch": "3.0.4",
"nativescript-hook": "0.2.4",
Expand All @@ -87,16 +92,11 @@
"webpack-cli": "~3.1.1",
"webpack-bundle-analyzer": "~3.0.2",
"webpack-sources": "~1.3.0",
"clean-webpack-plugin": "~1.0.0",
"copy-webpack-plugin": "~4.6.0",
"raw-loader": "~0.5.1",
"css-loader": "~1.0.0",
"nativescript-worker-loader": "~0.9.0",
"extract-text-webpack-plugin": "~3.0.2",
"uglifyjs-webpack-plugin": "~1.2.5",
"@angular-devkit/core": "~7.1.0",
"resolve-url-loader": "~3.0.0",
"awesome-typescript-loader": "~5.2.1",
"sass-loader": "~7.1.0"
},
"devDependencies": {
Expand Down
147 changes: 80 additions & 67 deletions xml-namespace-loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const { parse, relative, join, basename, extname } = require("path");
const { promisify } = require('util');
const { convertSlashesInPath } = require("./projectHelpers");

module.exports = function (source) {
this.value = source;
const { ignore } = this.query;
const callback = this.async();

const { XmlParser } = require("tns-core-modules/xml");

let namespaces = [];
const resolvePromise = promisify(this.resolve);
const promises = [];

const namespaces = [];
const parser = new XmlParser((event) => {
const { namespace, elementName } = event;
const moduleName = `${namespace}/${elementName}`;
Expand All @@ -20,83 +25,91 @@ module.exports = function (source) {
) {
const localNamespacePath = join(this.rootContext, namespace);
const localModulePath = join(localNamespacePath, elementName);
const resolvedPath = tryResolve(localNamespacePath) ||
tryResolve(localModulePath);

if (!resolvedPath) {
const xml = tryResolve(`${localModulePath}.xml`);
if (!xml) {
namespaces.push({ name: namespace, path: namespace });
namespaces.push({ name: moduleName, path: namespace });

return;
} else {
namespaces.push({ name: `${moduleName}.xml`, path: xml });
namespaces.push({ name: moduleName, path: xml });
this.addDependency(xml);
}

const css = tryResolve(`${localModulePath}.css`);
if (css) {
namespaces.push({ name: `${moduleName}.css`, path: css });
this.addDependency(css);
}

return;
}

this.addDependency(resolvedPath);

namespaces.push({ name: namespace, path: resolvedPath });
namespaces.push({ name: moduleName, path: resolvedPath });

const { dir, name } = parse(resolvedPath);
const noExtFilename = join(dir, name);

const xml = tryResolve(`${noExtFilename}.xml`);
if (xml) {
this.addDependency(xml);
namespaces.push({ name: `${moduleName}.xml`, path: xml });
}

const css = tryResolve(`${noExtFilename}.css`);
if (css) {
this.addDependency(css);
namespaces.push({ name: `${moduleName}.css`, path: css });
}

const pathResolved = (resolvedPath) => {
this.addDependency(resolvedPath);

namespaces.push({ name: namespace, path: resolvedPath });
namespaces.push({ name: moduleName, path: resolvedPath });

const { dir, name } = parse(resolvedPath);
const noExtFilename = join(dir, name);

return Promise.all([
resolvePromise(this.context, `${noExtFilename}.xml`)
.then((xml) => {
this.addDependency(xml);
namespaces.push({ name: `${moduleName}.xml`, path: xml });
})
.catch((err) => {}),

resolvePromise(this.context, `${noExtFilename}.css`)
.then((xml) => {
this.addDependency(xml);
namespaces.push({ name: `${moduleName}.css`, path: css });
})
.catch((err) => {})
]);
};

promises.push(resolvePromise(this.context, localNamespacePath)
.then(path => pathResolved(path))
.catch(() => {
return promise = resolvePromise(this.context, localModulePath)
.then(path => pathResolved(path))
.catch(() => {
return Promise.all([
resolvePromise(this.context, `${localModulePath}.xml`)
.then((xml) => {
namespaces.push({ name: `${moduleName}.xml`, path: xml });
namespaces.push({ name: moduleName, path: xml });
this.addDependency(xml);
})
.catch(() => {
namespaces.push({ name: namespace, path: namespace });
namespaces.push({ name: moduleName, path: namespace });
}),

resolvePromise(this.context, `${localModulePath}.css`)
.then((css) => {
namespaces.push({ name: `${moduleName}.css`, path: css });
this.addDependency(css);
})
.catch(() => {})
]);

});
})
);
}
}, undefined, true);

parser.parse(source);

const moduleRegisters = namespaces
.map(convertPath)
.map(n =>
`global.registerModule("${n.name}", function() { return require("${n.path}"); });`
)
.join("");
Promise.all(promises).then(() => {
const moduleRegisters = namespaces
.map(convertPath)
.map(n =>
`global.registerModule("${n.name}", function() { return require("${n.path}"); });`
)
.join("");

// escape special whitespace characters
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Issue_with_plain_JSON.stringify_for_use_as_JavaScript
const json = JSON.stringify(source)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');

// escape special whitespace characters
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Issue_with_plain_JSON.stringify_for_use_as_JavaScript
const json = JSON.stringify(source)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
const wrapped = `${moduleRegisters}\nmodule.exports = ${json}`;

const wrapped = `${moduleRegisters}\nmodule.exports = ${json};`;
callback(null, wrapped);
}).catch((err) => {
callback(err);
})

this.callback(null, wrapped);
}

function convertPath(obj) {
obj.path = convertSlashesInPath(obj.path);
return obj;
}

function tryResolve(path) {
try {
return require.resolve(path);
} catch (e) {
// The path couldn't be resolved
return;
}
}