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

Commit a1b7b20

Browse files
Merge pull request #739 from NativeScript/release-0.18.4
release: cut the 0.18.4 release
2 parents 6ca74d0 + ab2b638 commit a1b7b20

File tree

4 files changed

+96
-74
lines changed

4 files changed

+96
-74
lines changed

Diff for: CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="0.18.4"></a>
2+
## [0.18.4](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.18.3...0.18.4) (2018-12-14)
3+
4+
5+
### Bug Fixes
6+
7+
* **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))
8+
9+
10+
111
<a name="0.18.3"></a>
212
## [0.18.3](https://github.com/NativeScript/nativescript-dev-webpack/compare/0.18.2...0.18.3) (2018-12-10)
313

Diff for: dependencyManager.js

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function removeObsoleteDeps(packageJson) {
5454
"raw-loader",
5555
"css-loader",
5656
"nativescript-worker-loader",
57-
"extract-text-webpack-plugin",
5857
"uglifyjs-webpack-plugin",
5958
"@angular-devkit/core",
6059
"resolve-url-loader",

Diff for: package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-webpack",
3-
"version": "0.18.3",
3+
"version": "0.18.4",
44
"main": "index",
55
"description": "",
66
"homepage": "http://www.telerik.com",
@@ -74,6 +74,11 @@
7474
"generate-android-snapshot": "./bin/generate-android-snapshot"
7575
},
7676
"dependencies": {
77+
"@angular-devkit/core": "~7.1.0",
78+
"awesome-typescript-loader": "~5.2.1",
79+
"clean-webpack-plugin": "~1.0.0",
80+
"copy-webpack-plugin": "~4.6.0",
81+
"css-loader": "~1.0.0",
7782
"global-modules-path": "2.0.0",
7883
"minimatch": "3.0.4",
7984
"nativescript-hook": "0.2.4",
@@ -87,16 +92,11 @@
8792
"webpack-cli": "~3.1.1",
8893
"webpack-bundle-analyzer": "~3.0.2",
8994
"webpack-sources": "~1.3.0",
90-
"clean-webpack-plugin": "~1.0.0",
91-
"copy-webpack-plugin": "~4.6.0",
9295
"raw-loader": "~0.5.1",
93-
"css-loader": "~1.0.0",
9496
"nativescript-worker-loader": "~0.9.0",
9597
"extract-text-webpack-plugin": "~3.0.2",
9698
"uglifyjs-webpack-plugin": "~1.2.5",
97-
"@angular-devkit/core": "~7.1.0",
9899
"resolve-url-loader": "~3.0.0",
99-
"awesome-typescript-loader": "~5.2.1",
100100
"sass-loader": "~7.1.0"
101101
},
102102
"devDependencies": {

Diff for: xml-namespace-loader.js

+80-67
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
const { parse, relative, join, basename, extname } = require("path");
2+
const { promisify } = require('util');
23
const { convertSlashesInPath } = require("./projectHelpers");
34

45
module.exports = function (source) {
56
this.value = source;
67
const { ignore } = this.query;
8+
const callback = this.async();
79

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

10-
let namespaces = [];
12+
const resolvePromise = promisify(this.resolve);
13+
const promises = [];
14+
15+
const namespaces = [];
1116
const parser = new XmlParser((event) => {
1217
const { namespace, elementName } = event;
1318
const moduleName = `${namespace}/${elementName}`;
@@ -20,83 +25,91 @@ module.exports = function (source) {
2025
) {
2126
const localNamespacePath = join(this.rootContext, namespace);
2227
const localModulePath = join(localNamespacePath, elementName);
23-
const resolvedPath = tryResolve(localNamespacePath) ||
24-
tryResolve(localModulePath);
25-
26-
if (!resolvedPath) {
27-
const xml = tryResolve(`${localModulePath}.xml`);
28-
if (!xml) {
29-
namespaces.push({ name: namespace, path: namespace });
30-
namespaces.push({ name: moduleName, path: namespace });
31-
32-
return;
33-
} else {
34-
namespaces.push({ name: `${moduleName}.xml`, path: xml });
35-
namespaces.push({ name: moduleName, path: xml });
36-
this.addDependency(xml);
37-
}
38-
39-
const css = tryResolve(`${localModulePath}.css`);
40-
if (css) {
41-
namespaces.push({ name: `${moduleName}.css`, path: css });
42-
this.addDependency(css);
43-
}
44-
45-
return;
46-
}
47-
48-
this.addDependency(resolvedPath);
49-
50-
namespaces.push({ name: namespace, path: resolvedPath });
51-
namespaces.push({ name: moduleName, path: resolvedPath });
52-
53-
const { dir, name } = parse(resolvedPath);
54-
const noExtFilename = join(dir, name);
55-
56-
const xml = tryResolve(`${noExtFilename}.xml`);
57-
if (xml) {
58-
this.addDependency(xml);
59-
namespaces.push({ name: `${moduleName}.xml`, path: xml });
60-
}
61-
62-
const css = tryResolve(`${noExtFilename}.css`);
63-
if (css) {
64-
this.addDependency(css);
65-
namespaces.push({ name: `${moduleName}.css`, path: css });
66-
}
28+
29+
const pathResolved = (resolvedPath) => {
30+
this.addDependency(resolvedPath);
31+
32+
namespaces.push({ name: namespace, path: resolvedPath });
33+
namespaces.push({ name: moduleName, path: resolvedPath });
34+
35+
const { dir, name } = parse(resolvedPath);
36+
const noExtFilename = join(dir, name);
37+
38+
return Promise.all([
39+
resolvePromise(this.context, `${noExtFilename}.xml`)
40+
.then((xml) => {
41+
this.addDependency(xml);
42+
namespaces.push({ name: `${moduleName}.xml`, path: xml });
43+
})
44+
.catch((err) => {}),
45+
46+
resolvePromise(this.context, `${noExtFilename}.css`)
47+
.then((xml) => {
48+
this.addDependency(xml);
49+
namespaces.push({ name: `${moduleName}.css`, path: css });
50+
})
51+
.catch((err) => {})
52+
]);
53+
};
54+
55+
promises.push(resolvePromise(this.context, localNamespacePath)
56+
.then(path => pathResolved(path))
57+
.catch(() => {
58+
return promise = resolvePromise(this.context, localModulePath)
59+
.then(path => pathResolved(path))
60+
.catch(() => {
61+
return Promise.all([
62+
resolvePromise(this.context, `${localModulePath}.xml`)
63+
.then((xml) => {
64+
namespaces.push({ name: `${moduleName}.xml`, path: xml });
65+
namespaces.push({ name: moduleName, path: xml });
66+
this.addDependency(xml);
67+
})
68+
.catch(() => {
69+
namespaces.push({ name: namespace, path: namespace });
70+
namespaces.push({ name: moduleName, path: namespace });
71+
}),
72+
73+
resolvePromise(this.context, `${localModulePath}.css`)
74+
.then((css) => {
75+
namespaces.push({ name: `${moduleName}.css`, path: css });
76+
this.addDependency(css);
77+
})
78+
.catch(() => {})
79+
]);
80+
81+
});
82+
})
83+
);
6784
}
6885
}, undefined, true);
6986

7087
parser.parse(source);
7188

72-
const moduleRegisters = namespaces
73-
.map(convertPath)
74-
.map(n =>
75-
`global.registerModule("${n.name}", function() { return require("${n.path}"); });`
76-
)
77-
.join("");
89+
Promise.all(promises).then(() => {
90+
const moduleRegisters = namespaces
91+
.map(convertPath)
92+
.map(n =>
93+
`global.registerModule("${n.name}", function() { return require("${n.path}"); });`
94+
)
95+
.join("");
96+
97+
// escape special whitespace characters
98+
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Issue_with_plain_JSON.stringify_for_use_as_JavaScript
99+
const json = JSON.stringify(source)
100+
.replace(/\u2028/g, '\\u2028')
101+
.replace(/\u2029/g, '\\u2029');
78102

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

85-
const wrapped = `${moduleRegisters}\nmodule.exports = ${json};`;
105+
callback(null, wrapped);
106+
}).catch((err) => {
107+
callback(err);
108+
})
86109

87-
this.callback(null, wrapped);
88110
}
89111

90112
function convertPath(obj) {
91113
obj.path = convertSlashesInPath(obj.path);
92114
return obj;
93115
}
94-
95-
function tryResolve(path) {
96-
try {
97-
return require.resolve(path);
98-
} catch (e) {
99-
// The path couldn't be resolved
100-
return;
101-
}
102-
}

0 commit comments

Comments
 (0)