mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
feat(webpack): read nativescript.config.ts main if set before fallback to package.json (#9769)
implements #9658 BREAKING CHANGES: Possibly breaking if a project has a main field set in the nativescript.config.ts - since after this lands, this value will be used instead of package.json main. The impact is likely very small, the steps to migrate: (Option A) remove main from nativescript.config.ts if set (Option B) update main to the correct path in nativescript.config.ts if set incorrectly
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { warnOnce } from './log';
|
||||
import { env } from '../index';
|
||||
import { error, warnOnce } from './log';
|
||||
|
||||
function getCLILib() {
|
||||
if (!env.nativescriptLibPath) {
|
||||
@ -28,7 +28,9 @@ export function getValue<T = any>(key: string, defaultValue?: any): T {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return (lib.projectConfigService as {
|
||||
getValue(key: string, defaultValue?: any): T;
|
||||
}).getValue(key, defaultValue);
|
||||
return (
|
||||
lib.projectConfigService as {
|
||||
getValue(key: string, defaultValue?: any): T;
|
||||
}
|
||||
).getValue(key, defaultValue);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import { dirname, resolve } from 'path';
|
||||
|
||||
import { getPackageJson, getProjectRootPath } from './project';
|
||||
import { error, info, warnOnce } from './log';
|
||||
import { getValue } from './config';
|
||||
import { env } from '../';
|
||||
|
||||
import AndroidPlatform from '../platforms/android';
|
||||
@ -99,6 +100,13 @@ export function getEntryPath() {
|
||||
return platform.getEntryPath();
|
||||
}
|
||||
|
||||
// try main from nativescript.config.ts
|
||||
const main = getValue('main');
|
||||
|
||||
if (main) {
|
||||
return resolve(getProjectRootPath(), main);
|
||||
}
|
||||
|
||||
// fallback to main field in package.json
|
||||
const packageJson = getPackageJson();
|
||||
|
||||
|
Reference in New Issue
Block a user