Skip to content

Commit

Permalink
[Calendar] Fix rollup and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mup authored and wrdhub committed Jul 24, 2024
1 parent e6cfb28 commit d0b1dce
Show file tree
Hide file tree
Showing 44 changed files with 182 additions and 121 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ entities/
translations/
node_modules/
build/
build-calendar-app/
dist/
libs/
app-android/
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/DevBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ importScripts("./worker.js")
async function buildDesktopPart({ version }) {
await runStep("Desktop: Esbuild", async () => {
await esbuild({
entryPoints: ["src/desktop/DesktopMain.ts", "src/desktop/sqlworker.ts"],
entryPoints: ["src/common/desktop/DesktopMain.ts", "src/common/desktop/sqlworker.ts"],
outdir: "./build/desktop",
// Why we bundle at the moment:
// - We need to include all the imports: we currently use some node_modules directly, without pre-bundling them like rest of libs we can't avoid it
Expand Down Expand Up @@ -258,8 +258,8 @@ globalThis.buildOptions.sqliteNativePath = "./better-sqlite3.node";`,
await fs.writeFile("./build-calendar-app/package.json", content, "utf-8")

await fs.mkdir("build/desktop", { recursive: true })
await fs.copyFile("src/desktop/preload.js", "build/desktop/preload.js")
await fs.copyFile("src/desktop/preload-webdialog.js", "build/desktop/preload-webdialog.js")
await fs.copyFile("src/common/desktop/preload.js", "build/desktop/preload.js")
await fs.copyFile("src/common/desktop/preload-webdialog.js", "build/desktop/preload-webdialog.js")
})
}

Expand Down
127 changes: 92 additions & 35 deletions buildSrc/RollupConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,60 @@ export const allowedImports = {
"login",
"sharing",
],
"ui-extra": ["polyfill-helpers", "common-min", "common", "boot", "gui-base", "main", "settings", "contacts", "sanitizer", "login", "mail-editor"],
"mail-settings": [
"polyfill-helpers",
"common-min",
"common",
"boot",
"gui-base",
"main",
"contacts",
"sanitizer",
"mail-editor",
"mail-view",
"date",
"date-gui",
"login",
"sharing",
"settings",
],
"calendar-settings": [
"polyfill-helpers",
"common-min",
"common",
"boot",
"gui-base",
"main",
"contacts",
"sanitizer",
"mail-editor",
"mail-view",
"date",
"date-gui",
"login",
"sharing",
"settings",
],
"ui-extra": [
"polyfill-helpers",
"common-min",
"common",
"boot",
"gui-base",
"main",
"settings",
"mail-settings",
"calendar-settings",
"contacts",
"sanitizer",
"login",
"mail-editor",
],
sharing: ["polyfill-helpers", "common-min", "common", "boot", "gui-base", "main"],
"native-common": ["polyfill-helpers", "common-min", "common"],
"native-main": ["polyfill-helpers", "common-min", "common", "boot", "gui-base", "main", "native-common", "login"],
"native-worker": ["polyfill-helpers", "common-min", "common"],
"setup-wizard": ["boot", "common-min", "gui-base", "main", "native-common", "native-main", "settings", "ui-extra"],
"setup-wizard": ["boot", "common-min", "gui-base", "main", "native-common", "native-main", "settings", "mail-settings", "calendar-settings", "ui-extra"],
jszip: ["polyfill-helpers"],
"worker-lazy": ["common-min", "common", "worker", "worker-search", "date"],
"worker-search": ["common-min", "common", "worker", "worker-lazy"],
Expand Down Expand Up @@ -113,78 +161,83 @@ export function getChunkName(moduleId, { getModuleInfo }) {
// everything marked as assertMainOrNodeBoot goes into boot bundle right now
// (which is getting merged into app.js)
return "boot"
} else if (isIn("src/calendar/export") || isIn("src/misc/DateParser") || isIn("src/calendar/model") || isIn("src/calendar/gui")) {
} else if (
isIn("src/calendar-app/calendar/export") ||
isIn("src/common/misc/DateParser") ||
isIn("src/calendar-app/calendar/model") ||
isIn("src/calendar-app/calendar/gui")
) {
// this contains code that is important to the calendar view but might be used by other parts of the app on the main thread
// like time-based input components and formatting code.
return "date-gui"
} else if (moduleId.includes("luxon") || isIn("src/calendar/date")) {
} else if (moduleId.includes("luxon") || isIn("src/common/calendar/date")) {
// common calendar/time code that might be used in main or worker threads
// primarily luxon and utility functions based on it, but no display code
// (formatting, UI components)
return "date"
} else if (isIn("src/misc/HtmlSanitizer") || isIn("libs/purify")) {
} else if (isIn("src/common/misc/HtmlSanitizer") || isIn("libs/purify")) {
return "sanitizer"
} else if (isIn("src/gui/base")) {
} else if (isIn("src/common/gui/base")) {
// these gui elements are used from everywhere
return "gui-base"
} else if (isIn("src/native/main/wizard")) {
} else if (isIn("src/common/native/main/wizard")) {
return "setup-wizard"
} else if (isIn("src/native/main") || moduleId.includes("SearchInPageOverlay")) {
} else if (isIn("src/common/native/main") || moduleId.includes("SearchInPageOverlay")) {
return "native-main"
} else if (
isIn("src/mail/editor") ||
isIn("src/mail-app/mail/editor") ||
moduleId.includes("squire") ||
isIn("src/gui/editor") ||
isIn("src/mail/signature") ||
isIn("src/templates") ||
isIn("src/knowledgebase") ||
isIn("src/mail/press")
isIn("src/common/gui/editor") ||
isIn("src/mail-app/mail/signature") ||
isIn("src/mail-app/templates") ||
isIn("src/mail-app/knowledgebase") ||
isIn("src/mail-app/mail/press")
) {
// squire is most often used with mail editor and they are both not too big so we merge them
return "mail-editor"
} else if (
isIn("src/common/api/main") ||
isIn("src/mail/model") ||
isIn("src/contacts/model") ||
isIn("src/search/model") ||
isIn("src/misc/ErrorHandlerImpl") ||
isIn("src/misc") ||
isIn("src/file") ||
isIn("src/gui") ||
isIn("src/serviceworker") ||
isIn("src/mail-app/mail/model") ||
isIn("src/mail-app/contacts/model") ||
isIn("src/mail-app/search/model") ||
isIn("src/common/misc/ErrorHandlerImpl") ||
isIn("src/common/misc") ||
isIn("src/common/file") ||
isIn("src/common/gui") ||
isIn("src/common/serviceworker") ||
moduleId.includes(path.normalize("packages/tutanota-usagetests"))
) {
// Things which we always need for main thread anyway, at least currently
return "main"
} else if (isIn("src/mail/view") || isIn("src/mail/export")) {
} else if (isIn("src/mail-app/mail/view") || isIn("src/mail-app/mail/export")) {
return "mail-view"
} else if (moduleId.includes("wasm-loader")) {
return "wasm"
} else if (moduleId.includes("wasm-fallback")) {
return "wasm-fallback"
} else if (isIn("src/native/worker")) {
} else if (isIn("src/common/native/worker")) {
return "worker"
} else if (isIn("src/native/common")) {
} else if (isIn("src/common/native/common")) {
return "native-common"
} else if (isIn("src/search")) {
} else if (isIn("src/mail-app/search")) {
return "search"
} else if (isIn("src/calendar/view")) {
} else if (isIn("src/calendar-app/calendar/view")) {
return "calendar-view"
} else if (isIn("src/contacts")) {
} else if (isIn("src/mail-app/contacts")) {
return "contacts"
} else if (isIn("src/login/recover") || isIn("src/support") || isIn("src/login/contactform")) {
} else if (isIn("src/common/login/recover") || isIn("src/common/support") || isIn("src/common/login/contactform")) {
// Collection of small UI components which are used not too often
// Perhaps contact form should be separate
// Recover things depends on HtmlEditor which we don't want to load on each login
return "ui-extra"
} else if (isIn("src/login")) {
} else if (isIn("src/common/login")) {
return "login"
} else if (
isIn("src/common/api/common") ||
isIn("src/common/api/entities") ||
isIn("src/desktop/config/ConfigKeys") ||
moduleId.includes("cborg") ||
isIn("src/offline") ||
isIn("src/common/offline") ||
// CryptoError is needed on the main thread in order to check errors
// We have to define both the entry point and the files referenced from it which is annoying
isIn("packages/tutanota-crypto/dist/error") ||
Expand All @@ -200,11 +253,15 @@ export function getChunkName(moduleId, { getModuleInfo }) {
moduleId.includes("commonjs-dynamic-modules")
) {
return "polyfill-helpers"
} else if (isIn("src/settings") || isIn("src/subscription") || isIn("libs/qrcode") || isIn("src/termination")) {
} else if (isIn("src/common/settings") || isIn("src/common/subscription") || isIn("libs/qrcode") || isIn("src/common/termination")) {
// subscription and settings depend on each other right now.
// subscription is also a kitchen sink with signup, utils and views, we should break it up
return "settings"
} else if (isIn("src/sharing")) {
} else if (isIn("src/mail-app/settings")) {
return "mail-settings"
} else if (isIn("src/calendar-app/settings")) {
return "calendar-settings"
} else if (isIn("src/common/sharing")) {
return "sharing"
} else if (isIn("src/common/api/worker/facades/lazy")) {
// things that are not used for login and are generally accessed occasionally
Expand Down Expand Up @@ -298,7 +355,7 @@ export function bundleDependencyCheckPlugin() {
}
for (const moduleId of Object.keys(chunk.modules)) {
// Its a translation file and they are in their own chunks. We can skip further checks.
if (moduleId.includes(path.normalize("src/translations"))) {
if (moduleId.includes(path.normalize("src/mail-app/translations"))) {
continue
}
const ownChunk = getChunkName(moduleId, { getModuleInfo })
Expand All @@ -308,7 +365,7 @@ export function bundleDependencyCheckPlugin() {

for (const importedId of getModuleInfo(moduleId).importedIds) {
// static dependencies on translation files are not allowed
if (importedId.includes(path.normalize("src/translations"))) {
if (importedId.includes(path.normalize("src/mail-app/translations"))) {
pushToMapEntry(staticLangImports, moduleId, importedId)
}
const importedChunk = getChunkName(importedId, { getModuleInfo })
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/buildWebapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function bundleServiceWorker(bundles, version, minify) {
)
.concat(["images/logo-favicon.png", "images/logo-favicon-152.png", "images/logo-favicon-196.png", "images/font.ttf"])
const swBundle = await rollup({
input: ["src/serviceworker/sw.ts"],
input: ["src/common/serviceworker/sw.ts"],
plugins: [
typescript(),
minify && terser(),
Expand Down
2 changes: 1 addition & 1 deletion src/calendar-app/calendar/view/SettingsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { BackgroundColumnLayout } from "../../../common/gui/BackgroundColumnLayo
import { theme } from "../../../common/gui/theme.js"
import { styles } from "../../../common/gui/styles.js"
import { MobileHeader } from "../../../common/gui/MobileHeader.js"
import { getAvailableDomains } from "../../../mail-app/settings/mailaddress/MailAddressesUtils.js"
import { getAvailableDomains } from "../../../common/settings/mailaddress/MailAddressesUtils.js"
import { UserListView } from "../../../mail-app/settings/UserListView.js"
import { showUserImportDialog, UserViewer } from "../../../mail-app/settings/UserViewer.js"
import { exportUserCsv } from "../../../mail-app/settings/UserDataExporter.js"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/common/EntityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
listIdPart,
RANGE_ITEM_LIMIT,
} from "./utils/EntityUtils"
import { Type, ValueType } from "./EntityConstants"
import { Type, ValueType } from "./EntityConstants.js"
import { downcast, groupByAndMap, last, promiseMap, TypeRef } from "@tutao/tutanota-utils"
import { resolveTypeReference } from "./EntityFunctions"
import type { ElementEntity, ListElementEntity, SomeEntity } from "./EntityTypes"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/common/EntityFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type } from "./EntityConstants"
import { Type } from "./EntityConstants.js"
import { TypeRef } from "@tutao/tutanota-utils"
import type { TypeModel } from "./EntityTypes"
import { typeModels as baseTypeModels } from "../entities/base/TypeModels.js"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/common/EntityTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AssociationType, Cardinality, Type, ValueType } from "./EntityConstants"
import { AssociationType, Cardinality, Type, ValueType } from "./EntityConstants.js"
import { TypeRef } from "@tutao/tutanota-utils"
import type { BlobElement, Element, ListElement } from "./utils/EntityUtils.js"

Expand Down
2 changes: 1 addition & 1 deletion src/common/api/common/utils/EntityUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
uint8ArrayToBase64,
utf8Uint8ArrayToString,
} from "@tutao/tutanota-utils"
import { Cardinality, ValueType } from "../EntityConstants"
import { Cardinality, ValueType } from "../EntityConstants.js"
import type { ElementEntity, Entity, ModelValue, SomeEntity, TypeModel } from "../EntityTypes"

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/main/UserError.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TutanotaError } from "../../../../packages/tutanota-error/lib/index.js"
import type { TranslationKeyType } from "../../misc/TranslationKey"
import { lang } from "../../misc/LanguageViewModel"
import type { lazy } from "@tutao/tutanota-utils"
import { assertMainOrNode } from "../common/Env"
import { TutanotaError } from "@tutao/tutanota-error"

assertMainOrNode()

Expand Down
2 changes: 1 addition & 1 deletion src/common/api/worker/crypto/InstanceMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
uint8ArrayToBase64,
utf8Uint8ArrayToString,
} from "@tutao/tutanota-utils"
import { AssociationType, Cardinality, Type, ValueType } from "../../common/EntityConstants"
import { AssociationType, Cardinality, Type, ValueType } from "../../common/EntityConstants.js"
import { compress, uncompress } from "../Compression"
import type { ModelValue, TypeModel } from "../../common/EntityTypes"
import { assertWorkerOrNode } from "../../common/Env"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/worker/rest/DefaultEntityRestCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
UserGroupRootTypeRef,
UserTypeRef,
} from "../../entities/sys/TypeRefs.js"
import { ValueType } from "../../common/EntityConstants"
import { ValueType } from "../../common/EntityConstants.js"
import { NotAuthorizedError, NotFoundError } from "../../common/error/RestError"
import { CalendarEventUidIndexTypeRef, Mail, MailDetailsBlobTypeRef, MailTypeRef } from "../../entities/tutanota/TypeRefs.js"
import { firstBiggerThanSecond, GENERATED_MAX_ID, GENERATED_MIN_ID, getElementId, isSameId } from "../../common/utils/EntityUtils"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/worker/rest/EntityRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { isSameTypeRef, Mapper, ofClass, promiseMap, splitInChunks, TypeRef } fr
import { assertWorkerOrNode } from "../../common/Env"
import type { ListElementEntity, SomeEntity, TypeModel } from "../../common/EntityTypes"
import { getElementId, LOAD_MULTIPLE_LIMIT, POST_MULTIPLE_LIMIT } from "../../common/utils/EntityUtils"
import { Type } from "../../common/EntityConstants"
import { Type } from "../../common/EntityConstants.js"
import { SetupMultipleError } from "../../common/error/SetupMultipleError"
import { expandId } from "./DefaultEntityRestCache.js"
import { InstanceMapper } from "../crypto/InstanceMapper"
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/worker/search/SearchFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { FULL_INDEXED_TIMESTAMP, NOTHING_INDEXED_TIMESTAMP } from "../../common/
import { compareNewestFirst, firstBiggerThanSecond, timestampToGeneratedId } from "../../common/utils/EntityUtils"
import { INITIAL_MAIL_INDEX_INTERVAL_DAYS, MailIndexer } from "./MailIndexer"
import { SuggestionFacade } from "./SuggestionFacade"
import { AssociationType, Cardinality, ValueType } from "../../common/EntityConstants"
import { AssociationType, Cardinality, ValueType } from "../../common/EntityConstants.js"
import { NotAuthorizedError, NotFoundError } from "../../common/error/RestError"
import { iterateBinaryBlocks } from "./SearchIndexEncoding"
import type { BrowserData } from "../../../misc/ClientConstants"
Expand Down
Empty file removed src/common/gui/base/NewList.ts
Empty file.
2 changes: 1 addition & 1 deletion src/common/login/recover/RecoverLoginDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { showProgressDialog } from "../../gui/dialogs/ProgressDialog"
import { isMailAddress } from "../../misc/FormatValidator.js"
import { Autocomplete, TextField, TextFieldType } from "../../gui/base/TextField.js"
import { lang } from "../../misc/LanguageViewModel.js"
import { PasswordForm, PasswordModel } from "../../../mail-app/settings/PasswordForm.js"
import { PasswordForm, PasswordModel } from "../../settings/PasswordForm.js"
import { Icons } from "../../gui/base/icons/Icons"
import { Dialog, DialogType } from "../../gui/base/Dialog"
import { HtmlEditor, HtmlEditorMode } from "../../gui/editor/HtmlEditor"
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion src/common/native/main/WebCommonNativeFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class WebCommonNativeFacade implements CommonNativeFacade {
async promptForNewPassword(title: string, oldPassword: string | null): Promise<string> {
const [{ Dialog }, { PasswordForm, PasswordModel }] = await Promise.all([
import("../../gui/base/Dialog.js"),
import("../../../mail-app/settings/PasswordForm.js"),
import("../../settings/PasswordForm.js"),
])
const model = new PasswordModel(this.usageTestController, this.logins, { checkOldPassword: false, enforceStrength: false })

Expand Down
4 changes: 2 additions & 2 deletions src/common/settings/AccountMaintenanceSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
GroupInfo,
GroupInfoTypeRef,
} from "../api/entities/sys/TypeRefs.js"
import { ExpandableTable } from "../../mail-app/settings/ExpandableTable.js"
import { ExpandableTable } from "./ExpandableTable.js"
import { showProgressDialog } from "../gui/dialogs/ProgressDialog.js"
import { SettingsExpander } from "../../mail-app/settings/SettingsExpander.js"
import { SettingsExpander } from "./SettingsExpander.js"
import { LoginButton } from "../gui/base/buttons/LoginButton.js"
import { showLeavingUserSurveyWizard } from "../subscription/LeavingUserSurveyWizard.js"
import { SURVEY_VERSION_NUMBER } from "../subscription/LeavingUserSurveyConstants.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { Booking, CustomerInfo, CustomerProperties, NotificationMailTemplate } from "../../common/api/entities/sys/TypeRefs.js"
import { BookingTypeRef, createNotificationMailTemplate, CustomerInfoTypeRef, CustomerPropertiesTypeRef } from "../../common/api/entities/sys/TypeRefs.js"
import { HtmlEditor } from "../../common/gui/editor/HtmlEditor"
import { InfoLink, lang, languages } from "../../common/misc/LanguageViewModel"
import type { Booking, CustomerInfo, CustomerProperties, NotificationMailTemplate } from "../api/entities/sys/TypeRefs.js"
import { BookingTypeRef, createNotificationMailTemplate, CustomerInfoTypeRef, CustomerPropertiesTypeRef } from "../api/entities/sys/TypeRefs.js"
import { HtmlEditor } from "../gui/editor/HtmlEditor.js"
import { InfoLink, lang, languages } from "../misc/LanguageViewModel.js"
import stream from "mithril/stream"
import Stream from "mithril/stream"
import { Dialog, DialogType } from "../../common/gui/base/Dialog"
import { Dialog, DialogType } from "../gui/base/Dialog.js"
import m from "mithril"
import type { SelectorItemList } from "../../common/gui/base/DropDownSelector.js"
import { DropDownSelector } from "../../common/gui/base/DropDownSelector.js"
import { TextField } from "../../common/gui/base/TextField.js"
import { showProgressDialog } from "../../common/gui/dialogs/ProgressDialog"
import type { SelectorItemList } from "../gui/base/DropDownSelector.js"
import { DropDownSelector } from "../gui/base/DropDownSelector.js"
import { TextField } from "../gui/base/TextField.js"
import { showProgressDialog } from "../gui/dialogs/ProgressDialog.js"
import { assertNotNull, LazyLoaded, memoized, neverNull, ofClass } from "@tutao/tutanota-utils"
import { htmlSanitizer } from "../../common/misc/HtmlSanitizer"
import { PayloadTooLargeError } from "../../common/api/common/error/RestError"
import { SegmentControl } from "../../common/gui/base/SegmentControl"
import { insertInlineImageB64ClickHandler } from "../mail/view/MailViewerUtils"
import { insertInlineImageB64ClickHandler } from "../../mail-app/mail/view/MailViewerUtils"
import { UserError } from "../../common/api/main/UserError"
import { showNotAvailableForFreeDialog, showPlanUpgradeRequiredDialog } from "../../common/misc/SubscriptionDialogs"
import { getAvailablePlansWithWhitelabel, isWhitelabelActive } from "../../common/subscription/SubscriptionUtils"
Expand Down
Loading

0 comments on commit d0b1dce

Please sign in to comment.