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

Commit e7ee76e

Browse files
committed
fix: support platform specific entry modules
1 parent fea5b69 commit e7ee76e

6 files changed

+15
-8
lines changed

Diff for: index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ exports.getAotEntryModule = function (appDirectory) {
2525
return aotEntry;
2626
}
2727

28-
exports.getEntryModule = function (appDirectory) {
28+
exports.getEntryModule = function (appDirectory, platform) {
2929
verifyEntryModuleDirectory(appDirectory);
3030

3131
const entry = getPackageJsonEntry(appDirectory);
3232

3333
const tsEntryPath = path.resolve(appDirectory, `${entry}.ts`);
3434
const jsEntryPath = path.resolve(appDirectory, `${entry}.js`);
35-
if (!existsSync(tsEntryPath) && !existsSync(jsEntryPath)) {
35+
let entryExists = existsSync(tsEntryPath) || existsSync(jsEntryPath);
36+
if (!entryExists && platform) {
37+
const platformTsEntryPath = path.resolve(appDirectory, `${entry}.${platform}.ts`);
38+
const platformJsEntryPath = path.resolve(appDirectory, `${entry}.${platform}.js`);
39+
entryExists = existsSync(platformTsEntryPath) || existsSync(platformJsEntryPath);
40+
}
41+
42+
if (!entryExists) {
3643
throw new Error(`The entry module ${entry} specified in ` +
3744
`${appDirectory}/package.json doesn't exist!`)
3845
}

Diff for: plugins/NativeScriptAngularCompilerPlugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parse, sep } from "path";
1+
import { parse, join } from "path";
22
import { AngularCompilerPlugin } from "@ngtools/webpack";
33

44
export function getAngularCompilerPlugin(platform: string): any {
@@ -14,7 +14,7 @@ export function getAngularCompilerPlugin(platform: string): any {
1414
try {
1515
if (platform) {
1616
const parsed = parse(file);
17-
const platformFile = parsed.dir + sep + parsed.name + "." + platform + parsed.ext;
17+
const platformFile = join(parsed.dir, `${parsed.name}.${platform}${parsed.ext}`);
1818
return super.getCompiledFile(platformFile);;
1919
}
2020
}

Diff for: templates/webpack.angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = env => {
5454
const appFullPath = resolve(projectRoot, appPath);
5555
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
5656
const tsConfigName = "tsconfig.tns.json";
57-
const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`;
57+
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
5858
const entryPath = `.${sep}${entryModule}`;
5959
const entries = { bundle: entryPath };
6060
if (platform === "ios") {

Diff for: templates/webpack.javascript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = env => {
4949
const appFullPath = resolve(projectRoot, appPath);
5050
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
5151

52-
const entryModule = nsWebpack.getEntryModule(appFullPath);
52+
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
5353
const entryPath = `.${sep}${entryModule}.js`;
5454
const entries = { bundle: entryPath };
5555
if (platform === "ios") {

Diff for: templates/webpack.typescript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = env => {
4949
const appFullPath = resolve(projectRoot, appPath);
5050
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
5151

52-
const entryModule = nsWebpack.getEntryModule(appFullPath);
52+
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
5353
const entryPath = `.${sep}${entryModule}.ts`;
5454
const entries = { bundle: entryPath };
5555
if (platform === "ios") {

Diff for: templates/webpack.vue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = env => {
5656
const appFullPath = resolve(projectRoot, appPath);
5757
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
5858

59-
const entryModule = nsWebpack.getEntryModule(appFullPath);
59+
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
6060
const entryPath = `.${sep}${entryModule}`;
6161
const entries = { bundle: entryPath };
6262
if (platform === "ios") {

0 commit comments

Comments
 (0)