1
0
Fork 0

Revert "Trial using lazy loading imports."

This reverts commit 718dd762cf.
This commit is contained in:
Kitteh 2021-05-16 12:04:47 +01:00
parent 718dd762cf
commit d658f468a5
28 changed files with 56 additions and 87 deletions

View file

@ -1,46 +1,68 @@
import { HomePage } from "./pages/Home";
import { KeyValueDeletePage } from "./pages/KeyValue/KeyValueDelete";
import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew";
import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit";
import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret";
import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions";
import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView";
import { LoginPage } from "./pages/Login";
import { MePage } from "./pages/Me";
import { NewKVEnginePage } from "./pages/NewEngines/NewKVEngine";
import { NewSecretsEnginePage } from "./pages/NewSecretsEngine";
import { NewTOTPEnginePage } from "./pages/NewEngines/NewTOTPEngine";
import { NewTOTPPage } from "./pages/TOTP/NewTOTP";
import { NewTransitEnginePage } from "./pages/NewEngines/NewTransitEngine";
import { NewTransitKeyPage } from "./pages/Transit/NewTransitKey";
import { Page } from "./types/Page"; import { Page } from "./types/Page";
import { PwGenPage } from "./pages/PwGen";
import { SetLanguagePage } from "./pages/SetLanguage";
import { SetVaultURLPage } from "./pages/SetVaultURL";
import { TOTPViewPage } from "./pages/TOTP/TOTPView";
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt";
import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt";
import { TransitRewrapPage } from "./pages/Transit/TransitRewrap";
import { TransitViewPage } from "./pages/Transit/TransitView";
import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret";
import { UnsealPage } from "./pages/Unseal";
import { getObjectKeys } from "./utils"; import { getObjectKeys } from "./utils";
/* eslint-disable */ /* eslint-disable */
import { PageType } from "z-pagerouter"; import { PageType } from "z-pagerouter";
/* eslint-enable */ /* eslint-enable */
type importType = Promise<{
default: { new (...args: unknown[]): Page };
}>;
type pagesList = { type pagesList = {
[key: string]: importType; [key: string]: Page;
}; };
export const allPages: pagesList = { export const allPages: pagesList = {
HOME: import("./pages/Home"), HOME: new HomePage(),
ME: import("./pages/Me"), ME: new MePage(),
TOTP: import("./pages/TOTP/TOTPView"), TOTP: new TOTPViewPage(),
NEW_TOTP: import("./pages/TOTP/NewTOTP"), NEW_TOTP: new NewTOTPPage(),
LOGIN: import("./pages/Login"), LOGIN: new LoginPage(),
SET_VAULT_URL: import("./pages/SetVaultURL"), SET_VAULT_URL: new SetVaultURLPage(),
UNSEAL: import("./pages/Unseal"), UNSEAL: new UnsealPage(),
SET_LANGUAGE: import("./pages/SetLanguage"), SET_LANGUAGE: new SetLanguagePage(),
TRANSIT_NEW_KEY: import("./pages/Transit/NewTransitKey"), TRANSIT_NEW_KEY: new NewTransitKeyPage(),
TRANSIT_VIEW: import("./pages/Transit/TransitView"), TRANSIT_VIEW: new TransitViewPage(),
TRANSIT_VIEW_SECRET: import("./pages/Transit/TransitViewSecret"), TRANSIT_VIEW_SECRET: new TransitViewSecretPage(),
TRANSIT_ENCRYPT: import("./pages/Transit/TransitEncrypt"), TRANSIT_ENCRYPT: new TransitEncryptPage(),
TRANSIT_DECRYPT: import("./pages/Transit/TransitDecrypt"), TRANSIT_DECRYPT: new TransitDecryptPage(),
TRANSIT_REWRAP: import("./pages/Transit/TransitRewrap"), TRANSIT_REWRAP: new TransitRewrapPage(),
KEY_VALUE_VIEW: import("./pages/KeyValue/KeyValueView"), KEY_VALUE_VIEW: new KeyValueViewPage(),
KEY_VALUE_SECRET: import("./pages/KeyValue/KeyValueSecret"), KEY_VALUE_SECRET: new KeyValueSecretPage(),
KEY_VALUE_VERSIONS: import("./pages/KeyValue/KeyValueVersions"), KEY_VALUE_VERSIONS: new KeyValueVersionsPage(),
KEY_VALUE_NEW_SECRET: import("./pages/KeyValue/KeyValueNew"), KEY_VALUE_NEW_SECRET: new KeyValueNewPage(),
KEY_VALUE_DELETE: import("./pages/KeyValue/KeyValueDelete"), KEY_VALUE_DELETE: new KeyValueDeletePage(),
KEY_VALUE_SECRET_EDIT: import("./pages/KeyValue/KeyValueSecretsEdit"), KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(),
PW_GEN: import("./pages/PwGen"), PW_GEN: new PwGenPage(),
NEW_SECRETS_ENGINE: import("./pages/NewSecretsEngine"), NEW_SECRETS_ENGINE: new NewSecretsEnginePage(),
NEW_KV_ENGINE: import("./pages/NewEngines/NewKVEngine"), NEW_KV_ENGINE: new NewKVEnginePage(),
NEW_TOTP_ENGINE: import("./pages/NewEngines/NewTOTPEngine"), NEW_TOTP_ENGINE: new NewTOTPEnginePage(),
NEW_TRANSIT_ENGINE: import("./pages/NewEngines/NewTransitEngine"), NEW_TRANSIT_ENGINE: new NewTransitEnginePage(),
}; };
// This should implement all o PageListType // This should implement all o PageListType
class PageList { class PageList {
constructor(pages: pagesList) { constructor(pages: pagesList) {
@ -52,7 +74,7 @@ class PageList {
return getObjectKeys(this.pages); return getObjectKeys(this.pages);
} }
async getPage(pageID: string): Promise<PageType> { async getPage(pageID: string): Promise<PageType> {
return new (await this.pages[pageID]).default(); return this.pages[pageID];
} }
} }

View file

@ -134,5 +134,3 @@ export class HomePage extends Page {
return i18next.t("home_page_title"); return i18next.t("home_page_title");
} }
} }
export { HomePage as default };

View file

@ -55,5 +55,3 @@ export class KeyValueDeletePage extends Page {
return i18next.t("kv_delete_title"); return i18next.t("kv_delete_title");
} }
} }
export { KeyValueDeletePage as default };

View file

@ -90,4 +90,3 @@ export class KeyValueNewPage extends Page {
return i18next.t("kv_new_title"); return i18next.t("kv_new_title");
} }
} }
export { KeyValueNewPage as default };

View file

@ -186,5 +186,3 @@ export class KeyValueSecretPage extends Page {
return i18next.t("kv_secret_title"); return i18next.t("kv_secret_title");
} }
} }
export { KeyValueSecretPage as default };

View file

@ -87,4 +87,3 @@ export class KeyValueSecretEditPage extends Page {
return i18next.t("kv_sec_edit_title"); return i18next.t("kv_sec_edit_title");
} }
} }
export { KeyValueSecretEditPage as default };

View file

@ -54,5 +54,3 @@ export class KeyValueVersionsPage extends Page {
return i18next.t("kv_sec_versions_title"); return i18next.t("kv_sec_versions_title");
} }
} }
export { KeyValueVersionsPage as default };

View file

@ -104,5 +104,3 @@ export class KeyValueViewPage extends Page {
return i18next.t("kv_view_title"); return i18next.t("kv_view_title");
} }
} }
export { KeyValueViewPage as default };

View file

@ -174,5 +174,3 @@ export class LoginPage extends Page {
return i18next.t("log_in_title"); return i18next.t("log_in_title");
} }
} }
export { LoginPage as default };

View file

@ -98,5 +98,3 @@ export class MePage extends Page {
return i18next.t("me_page_title"); return i18next.t("me_page_title");
} }
} }
export { MePage as default };

View file

@ -85,5 +85,3 @@ export class NewKVEnginePage extends Page {
return i18next.t("new_kv_engine_title"); return i18next.t("new_kv_engine_title");
} }
} }
export { NewKVEnginePage as default };

View file

@ -67,5 +67,3 @@ export class NewTOTPEnginePage extends Page {
return i18next.t("new_totp_engine_title"); return i18next.t("new_totp_engine_title");
} }
} }
export { NewTOTPEnginePage as default };

View file

@ -67,5 +67,3 @@ export class NewTransitEnginePage extends Page {
return i18next.t("new_transit_engine_title"); return i18next.t("new_transit_engine_title");
} }
} }
export { NewTransitEnginePage as default };

View file

@ -45,5 +45,3 @@ export class NewSecretsEnginePage extends Page {
return i18next.t("new_secrets_engine_title"); return i18next.t("new_secrets_engine_title");
} }
} }
export { NewSecretsEnginePage as default };

View file

@ -146,5 +146,3 @@ export class PwGenPage extends Page {
return i18next.t("password_generator_title"); return i18next.t("password_generator_title");
} }
} }
export { PwGenPage as default };

View file

@ -67,5 +67,3 @@ export class SetLanguagePage extends Page {
return i18next.t("set_language_title"); return i18next.t("set_language_title");
} }
} }
export { SetLanguagePage as default };

View file

@ -52,5 +52,3 @@ export class SetVaultURLPage extends Page {
return "Set Vault URL"; return "Set Vault URL";
} }
} }
export { SetVaultURLPage as default };

View file

@ -114,5 +114,3 @@ export class NewTOTPPage extends Page {
return i18next.t("totp_new_title"); return i18next.t("totp_new_title");
} }
} }
export { NewTOTPPage as default };

View file

@ -113,5 +113,3 @@ export class TOTPViewPage extends Page {
return i18next.t("totp_view_title"); return i18next.t("totp_view_title");
} }
} }
export { TOTPViewPage as default };

View file

@ -95,5 +95,3 @@ export class NewTransitKeyPage extends Page {
return i18next.t("transit_new_key_title"); return i18next.t("transit_new_key_title");
} }
} }
export { NewTransitKeyPage as default };

View file

@ -122,5 +122,3 @@ export class TransitDecryptPage extends Page {
return i18next.t("transit_decrypt_title"); return i18next.t("transit_decrypt_title");
} }
} }
export { TransitDecryptPage as default };

View file

@ -120,5 +120,3 @@ export class TransitEncryptPage extends Page {
return i18next.t("transit_encrypt_title"); return i18next.t("transit_encrypt_title");
} }
} }
export { TransitEncryptPage as default };

View file

@ -113,5 +113,3 @@ export class TransitRewrapPage extends Page {
return i18next.t("transit_rewrap_title"); return i18next.t("transit_rewrap_title");
} }
} }
export { TransitRewrapPage as default };

View file

@ -78,5 +78,3 @@ export class TransitViewPage extends Page {
return i18next.t("transit_view_title"); return i18next.t("transit_view_title");
} }
} }
export { TransitViewPage as default };

View file

@ -66,5 +66,3 @@ export class TransitViewSecretPage extends Page {
return i18next.t("transit_view_secret_title"); return i18next.t("transit_view_secret_title");
} }
} }
export { TransitViewSecretPage as default };

View file

@ -192,5 +192,3 @@ export class UnsealPage extends Page {
return i18next.t("unseal_vault_text"); return i18next.t("unseal_vault_text");
} }
} }
export { UnsealPage as default };

View file

@ -3,7 +3,7 @@
"outDir": "./dist/", "outDir": "./dist/",
"noImplicitAny": false, "noImplicitAny": false,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"module": "es2020", "module": "es6",
"target": "es2019", "target": "es2019",
"strictBindCallApply": true, "strictBindCallApply": true,
"noImplicitThis": true, "noImplicitThis": true,

View file

@ -22,8 +22,7 @@ module.exports = {
entry: './src/main.ts', entry: './src/main.ts',
output: { output: {
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
chunkFilename: '[name].js', filename: 'bundle.js',
filename: '[name].[contenthash].js',
}, },
stats: { stats: {
preset: VERBOSE ? "detailed" : "normal", preset: VERBOSE ? "detailed" : "normal",
@ -45,11 +44,7 @@ module.exports = {
modules: ['node_modules'], modules: ['node_modules'],
extensions: ['.tsx', '.ts', '.js', ".mjs"], extensions: ['.tsx', '.ts', '.js', ".mjs"],
}, },
optimization: {
splitChunks: {
chunks: 'all',
},
},
module: { module: {
rules: [ rules: [
{ {