mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: working with builder xml require vs dynamic import wip
This commit is contained in:
@@ -72,7 +72,7 @@ const createComponentInstance = profile('createComponentInstance', (elementName:
|
||||
// console.log('CUSTOM namespace:', namespace)
|
||||
resolvedModuleName = resolveModuleName(namespace, '');
|
||||
}
|
||||
instanceModule = global.loadModule(resolvedModuleName, true);
|
||||
instanceModule = global.loadModule(resolvedModuleName);
|
||||
} else {
|
||||
// load module from @nativescript/core/ui or mapped paths
|
||||
// resolvedModuleName =
|
||||
@@ -84,7 +84,7 @@ const createComponentInstance = profile('createComponentInstance', (elementName:
|
||||
// .join('-')
|
||||
// .toLowerCase();
|
||||
|
||||
instanceModule = global.loadModule(CORE_UI_BARREL, false);
|
||||
instanceModule = global.loadModule(CORE_UI_BARREL);
|
||||
// don't register core modules for HMR self-accept
|
||||
// instanceModule = global.loadModule(resolvedModuleName, false);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ const getComponentModuleExports = profile('getComponentModuleExports', (instance
|
||||
if (codeFileAttribute) {
|
||||
const resolvedCodeFileModule = resolveModuleName(sanitizeModuleName(codeFileAttribute), '');
|
||||
if (resolvedCodeFileModule) {
|
||||
moduleExports = global.loadModule(resolvedCodeFileModule, true);
|
||||
moduleExports = global.loadModule(resolvedCodeFileModule);
|
||||
(<any>instance).exports = moduleExports;
|
||||
} else {
|
||||
throw new Error(`Code file with path "${codeFileAttribute}" cannot be found! Looking for webpack module with name "${resolvedCodeFileModule}"`);
|
||||
@@ -155,6 +155,10 @@ const applyComponentAttributes = profile('applyComponentAttributes', (instance:
|
||||
}
|
||||
}
|
||||
|
||||
console.log('applyComponentAttributes called for attr:', attr, 'with value:', attrValue);
|
||||
if (attr === 'navigatingTo') {
|
||||
console.log('@@@ navigatingTo moduleExports:', moduleExports);
|
||||
}
|
||||
if (attr.indexOf('.') !== -1) {
|
||||
let subObj = instance;
|
||||
const properties = attr.split('.');
|
||||
@@ -185,6 +189,9 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
|
||||
const { instance, instanceModule } = createComponentInstance(elementName, namespace, null);
|
||||
moduleExports = getComponentModuleExports(instance, <any>moduleExports, attributes);
|
||||
console.log('getComponentModule called for element:', elementName, 'with namespace:', namespace, 'and attributes:', attributes);
|
||||
console.log('moduleExports ---');
|
||||
console.log(moduleExports);
|
||||
if (isRootComponent) {
|
||||
applyComponentCss(instance, moduleNamePath, attributes);
|
||||
}
|
||||
@@ -202,6 +209,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
export function setPropertyValue(instance: View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: any) {
|
||||
// Note: instanceModule can be null if we are loading custom component with no code-behind.
|
||||
if (isBinding(propertyValue) && instance.bind) {
|
||||
console.log('1 setPropertyValue, Binding detected for property:', propertyName, 'with value:', propertyValue);
|
||||
const bindOptions = getBindingOptions(propertyName, getBindingExpressionFromAttribute(propertyValue));
|
||||
instance.bind(
|
||||
{
|
||||
@@ -213,6 +221,8 @@ export function setPropertyValue(instance: View, instanceModule: Object, exports
|
||||
bindOptions[bindingConstants.source],
|
||||
);
|
||||
} else if (isEventOrGesture(propertyName, instance)) {
|
||||
console.log('2 setPropertyValue, Binding detected for property:', propertyName, 'with value:', propertyValue);
|
||||
console.log('setPropertyValue, exports:', exports);
|
||||
// Get the event handler from page module exports.
|
||||
const handler = exports && exports[propertyValue];
|
||||
|
||||
@@ -221,8 +231,10 @@ export function setPropertyValue(instance: View, instanceModule: Object, exports
|
||||
instance.on(propertyName, handler);
|
||||
}
|
||||
} else if (isKnownFunction(propertyName, instance) && exports && typeof exports[propertyValue] === 'function') {
|
||||
console.log('3 setPropertyValue, Binding detected for property:', propertyName, 'with value:', propertyValue);
|
||||
instance[propertyName] = exports[propertyValue];
|
||||
} else {
|
||||
console.log('4 setPropertyValue, Binding detected for property:', propertyName, 'with value:', propertyValue);
|
||||
instance[propertyName] = propertyValue;
|
||||
}
|
||||
}
|
||||
@@ -233,11 +245,11 @@ function getBindingExpressionFromAttribute(value: string): string {
|
||||
|
||||
function isBinding(value: any): boolean {
|
||||
let isBinding;
|
||||
|
||||
if (typeof value === 'string') {
|
||||
const str = value.trim();
|
||||
isBinding = str.indexOf('{{') === 0 && str.lastIndexOf('}}') === str.length - 2;
|
||||
}
|
||||
console.log('isBinding called with value:', value, ' isBinding:', isBinding);
|
||||
|
||||
return isBinding;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user