mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
refactor: return of missing css errors
This commit is contained in:
@ -3,6 +3,11 @@ import { screen, device } from "../platform/platform";
|
||||
import * as appCommonModule from "../application/application-common";
|
||||
import { PlatformContext, findMatch } from "./qualifier-matcher";
|
||||
import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat";
|
||||
import {
|
||||
isEnabled as traceEnabled,
|
||||
write as traceWrite,
|
||||
categories as traceCategories
|
||||
} from "../trace";
|
||||
|
||||
export class ModuleNameResolver implements ModuleNameResolverDefinition {
|
||||
private _cache = {};
|
||||
@ -18,6 +23,10 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition {
|
||||
this._cache[key] = result;
|
||||
}
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, traceCategories.ModuleNameResolver);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -52,6 +61,10 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition {
|
||||
let resolverInstance: ModuleNameResolver;
|
||||
|
||||
export function resolveModuleName(path: string, ext: string): string {
|
||||
if (global.__snapshot) {
|
||||
return resolveModuleSnapshot(path, ext);
|
||||
}
|
||||
|
||||
if (!resolverInstance) {
|
||||
resolverInstance = new ModuleNameResolver({
|
||||
width: screen.mainScreen.widthDIPs,
|
||||
@ -64,6 +77,19 @@ export function resolveModuleName(path: string, ext: string): string {
|
||||
return resolverInstance.resolveModuleName(path, ext);
|
||||
}
|
||||
|
||||
function resolveModuleSnapshot(path, ext) {
|
||||
traceWrite(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, traceCategories.ModuleNameResolver);
|
||||
|
||||
// Platform module when in snapshot. So resolve modules with default android phone.
|
||||
// NB: The only module name that should ever be resolved while in snapshot is app.css
|
||||
return new ModuleNameResolver({
|
||||
width: 400,
|
||||
height: 800,
|
||||
os: "Android",
|
||||
deviceType: "Phone"
|
||||
}).resolveModuleName(path, ext);
|
||||
}
|
||||
|
||||
export function clearCache() {
|
||||
if (resolverInstance) {
|
||||
resolverInstance.clearCache();
|
||||
|
Reference in New Issue
Block a user