[REF] config: move mode from owl.__info__ to owl.config

and move it to its own file.
This commit is contained in:
Aaron Bohy
2019-10-14 13:10:33 +02:00
committed by Géry Debongnie
parent 9e37b968e8
commit 9f93da4765
2 changed files with 33 additions and 17 deletions
+31
View File
@@ -0,0 +1,31 @@
import { QWeb } from "./qweb/index";
/**
* This file creates and exports the OWL 'config' object, with keys:
* - 'mode': 'prod' or 'dev',
*/
interface Config {
mode: string;
}
const _config:Partial<Config> = {};
Object.defineProperty(_config, "mode", {
get() {
return QWeb.dev ? "dev" : "prod";
},
set(mode: string) {
QWeb.dev = mode === "dev";
if (QWeb.dev) {
const url = `https://github.com/odoo/owl/blob/master/doc/tooling.md#development-mode`;
console.warn(
`Owl is running in 'dev' mode. This is not suitable for production use. See ${url} for more information.`
);
} else {
console.log(`Owl is now running in 'prod' mode.`);
}
},
});
export const config:Config = _config as Config;
+2 -17
View File
@@ -7,6 +7,7 @@
import { EventBus } from "./core/event_bus";
import { Observer } from "./core/observer";
import { QWeb } from "./qweb/index";
import { config } from "./config";
import * as _store from "./store";
import * as _utils from "./utils";
import * as _tags from "./tags";
@@ -19,6 +20,7 @@ import { Router } from "./router/router";
export { Component } from "./component/component";
export { QWeb };
export { config };
export const Context = _context.Context;
export const useState = _hooks.useState;
@@ -35,20 +37,3 @@ export const hooks = Object.assign({}, _hooks, {
useStore: _store.useStore
});
export const __info__ = {};
Object.defineProperty(__info__, "mode", {
get() {
return QWeb.dev ? "dev" : "prod";
},
set(mode: string) {
QWeb.dev = mode === "dev";
if (QWeb.dev) {
const url = `https://github.com/odoo/owl/blob/master/doc/tooling.md#development-mode`;
console.warn(
`Owl is running in 'dev' mode. This is not suitable for production use. See ${url} for more information.`
);
} else {
console.log(`Owl is now running in 'prod' mode.`);
}
}
});