feat: global autoRegisterUIModules to disable auto ui registering

That way you can do it manually which means not everything will be packaged with webpack!
This commit is contained in:
Martin Guillon
2020-11-01 11:11:16 +01:00
parent 17658ed777
commit 01e9d97062
2 changed files with 11 additions and 7 deletions

View File

@ -4,7 +4,10 @@ import './globals';
// Register "dynamically" loaded module that need to be resolved by the // Register "dynamically" loaded module that need to be resolved by the
// XML/component builders. // XML/component builders.
import * as coreUIModules from './ui/index'; import * as coreUIModules from './ui/index';
if (global.autoRegisterUIModules !== false) {
global.registerModule('@nativescript/core/ui', () => coreUIModules); global.registerModule('@nativescript/core/ui', () => coreUIModules);
}
// global.registerModule('text/formatted-string', () => require('./text/formatted-string')); // global.registerModule('text/formatted-string', () => require('./text/formatted-string'));
// global.registerModule('text/span', () => require('./text/span')); // global.registerModule('text/span', () => require('./text/span'));

View File

@ -1,4 +1,4 @@
declare var global: NodeJS.Global & typeof globalThis; declare let global: NodeJS.Global & typeof globalThis;
interface ModuleResolver { interface ModuleResolver {
/** /**
@ -124,6 +124,7 @@ declare namespace NodeJS {
TNS_WEBPACK?: boolean; TNS_WEBPACK?: boolean;
isIOS?: boolean; isIOS?: boolean;
isAndroid?: boolean; isAndroid?: boolean;
autoRegisterUIModules?: boolean;
__requireOverride?: (name: string, dir: string) => any; __requireOverride?: (name: string, dir: string) => any;
} }
} }
@ -209,7 +210,7 @@ declare type HeaderInit = Headers | Array<string>;
declare function fetch(url: string, init?: RequestInit): Promise<Response>; declare function fetch(url: string, init?: RequestInit): Promise<Response>;
// declare var console: Console; // declare var console: Console;
declare var require: NodeRequire; declare let require: NodeRequire;
// Extend NodeRequire with the webpack's require context extension. // Extend NodeRequire with the webpack's require context extension.
interface RequireContext { interface RequireContext {
@ -223,12 +224,12 @@ interface NodeRequire {
context(path: string, deep?: boolean, filter?: RegExp): RequireContext; context(path: string, deep?: boolean, filter?: RegExp): RequireContext;
} }
declare var __dirname: string; declare let __dirname: string;
declare var __filename: string; declare let __filename: string;
declare var module: NodeModule; declare let module: NodeModule;
// Same as module.exports // Same as module.exports
declare var exports: any; declare let exports: any;
// Global functions // Global functions
declare function Deprecated(target: Object, key?: string | symbol, value?: any): void; declare function Deprecated(target: Object, key?: string | symbol, value?: any): void;