Add a globals.registerWebpackModules that can register dynamic require webpack context (#5087)

This commit is contained in:
Panayot Cankov
2017-11-22 13:02:42 +02:00
committed by GitHub
parent 71c50b2cb1
commit 255fedac83
5 changed files with 50 additions and 2 deletions

View File

@@ -82,13 +82,13 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
if (xmlFilePath) {
// Custom components with XML
var jsFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "js");
var subExports = context;
if (global.moduleExists(moduleName)) {
// Component has registered code module.
subExports = global.loadModule(moduleName);
} else {
var jsFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "js");
if (jsFilePath) {
// Component has code file.
subExports = global.loadModule(jsFilePath)

View File

@@ -11,6 +11,8 @@ import { profile } from "../../../profiling";
import * as debugModule from "../../../utils/debug";
import * as platform from "../../../platform";
import * as filesystem from "../../../file-system";
const UI_PATH = "ui/";
const MODULES = {
"TabViewItem": "ui/tab-view",
@@ -119,6 +121,13 @@ const applyComponentCss = profile("applyComponentCss", (instance: View, moduleNa
if (typeof (<any>instance).addCssFile === "function") {//instance instanceof Page) {
if (moduleNamePath && !cssApplied) {
const appPath = filesystem.knownFolders.currentApp().path;
const cssPathRelativeToApp = (moduleNamePath.startsWith(appPath) ? "./" + moduleNamePath.substr(appPath.length + 1) : moduleNamePath) + ".css";
if (global.moduleExists(cssPathRelativeToApp)) {
(<any>instance).addCssFile(cssPathRelativeToApp);
}
let cssFilePath = resolveFileName(moduleNamePath, "css");
if (cssFilePath) {
(<any>instance).addCssFile(cssFilePath);

View File

@@ -508,7 +508,7 @@ export class StyleScope {
}
this._reset();
let parsedCssSelectors = cssString ? CSSSource.fromSource(cssString, this._keyframes, cssFileName) : CSSSource.fromFile(cssFileName, this._keyframes);
let parsedCssSelectors = cssString ? CSSSource.fromSource(cssString, this._keyframes, cssFileName) : CSSSource.fromURI(cssFileName, this._keyframes);
this._css = this._css + parsedCssSelectors.source;
this._localCssSelectors.push.apply(this._localCssSelectors, parsedCssSelectors.selectors);
this._localCssSelectorVersion++;