diff --git a/index.js b/index.js index 9036ae0c..05b13ab1 100644 --- a/index.js +++ b/index.js @@ -11,18 +11,42 @@ Object.assign(exports, require("./plugins")); Object.assign(exports, require("./host/resolver")); exports.processTsPathsForScopedModules = function ({ compilerOptions }) { - return replacePathInCompilerOptions({ + const tnsModulesOldPackage = "tns-core-modules"; + const tnsModulesNewPackage = "@nativescript/core"; + replacePathInCompilerOptions({ compilerOptions, - targetPath: "tns-core-modules", - replacementPath: "@nativescript/core" + targetPath: tnsModulesOldPackage, + replacementPath: tnsModulesNewPackage + }); + ensurePathInCompilerOptions({ + compilerOptions, + sourcePath: tnsModulesOldPackage, + destinationPath: `./node_modules/${tnsModulesNewPackage}` + }); + ensurePathInCompilerOptions({ + compilerOptions, + sourcePath: `${tnsModulesOldPackage}/*`, + destinationPath: `./node_modules/${tnsModulesNewPackage}/*` }); } exports.processTsPathsForScopedAngular = function ({ compilerOptions }) { - return replacePathInCompilerOptions({ + const nsAngularOldPackage = "nativescript-angular"; + const nsAngularNewPackage = "@nativescript/angular"; + replacePathInCompilerOptions({ + compilerOptions, + targetPath: nsAngularOldPackage, + replacementPath: nsAngularNewPackage + }); + ensurePathInCompilerOptions({ + compilerOptions, + sourcePath: nsAngularOldPackage, + destinationPath: `./node_modules/${nsAngularNewPackage}` + }); + ensurePathInCompilerOptions({ compilerOptions, - targetPath: "nativescript-angular", - replacementPath: "@nativescript/angular" + sourcePath: `${nsAngularOldPackage}/*`, + destinationPath: `./node_modules/${nsAngularNewPackage}/*` }); } @@ -215,4 +239,15 @@ function replacePathInCompilerOptions({ compilerOptions, targetPath, replacement } } } +} + +function ensurePathInCompilerOptions({ compilerOptions, sourcePath, destinationPath }) { + const paths = (compilerOptions && compilerOptions.paths) || {}; + if (paths[sourcePath]) { + if (Array.isArray(paths[sourcePath]) && paths[sourcePath].indexOf(destinationPath) === -1) { + paths[sourcePath].push(destinationPath); + } + } else { + paths[sourcePath] = [destinationPath]; + } } \ No newline at end of file diff --git a/package.json b/package.json index 1046ba2a..c4491a95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-dev-webpack", - "version": "1.4.0", + "version": "1.4.1", "main": "index", "description": "", "homepage": "http://www.telerik.com",