Skip to content
This repository was archived by the owner on Mar 1, 2020. It is now read-only.

Commit 141ad8d

Browse files
authoredApr 30, 2018
Merge pull request #4 from mehyaa/patch-1
Fix internal module requring
2 parents f70e263 + 9517818 commit 141ad8d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

Diff for: ‎index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ module.exports = (context, request, callback) => {
44

55
if (context.indexOf('tns-core-modules') !== -1
66
|| context.indexOf('nativescript-') !== -1
7-
|| /^(tns-core-modules)/i.test(request)
7+
|| /^tns-core-modules/i.test(request)
88
|| /^(ui|application)/i.test(request)) {
99

10-
// Support plugins requiring sibling files by rewriting './' into 'context/'
11-
if (request.indexOf('./') === 0) {
12-
request = path.join(path.basename(context), request.substring(2));
10+
if (request.indexOf('../') === 0 || request.indexOf('./') === 0) {
11+
let index = context.indexOf('node_modules') + 'node_modules'.length + 1;
12+
13+
request = path.normalize(path.join(context.substring(index).replace(/\\/g, '/'), request)).replace(/\\/g, '/');
14+
}
15+
else if (/^(ui|application)/i.test(request)) {
16+
request = `tns-core-modules/${request}`.replace(/\\/g, '/');
1317
}
1418

1519
return callback(null, 'commonjs ' + request);

0 commit comments

Comments
 (0)