Skip to content

Commit 76b53eb

Browse files
chore: remove webpack config and convert next.config to TypeScript (calcom#26126)
* chore: remove webpack experimental flags from apps/web - Remove webpackMemoryOptimizations and webpackBuildWorker from experimental config - Remove unused DefinePlugin for process.env.BUILD_ID (not used anywhere in codebase) - Remove unused buildId parameter from webpack function signature These webpack-specific experimental flags were showing up during dev mode even though Turbopack is used for development. The flags only apply to production webpack builds and their presence in the config was confusing. Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com> * chore: remove webpack function for full Turbopack build - Remove entire webpack function (IgnorePlugin, PrismaPlugin, resolve.fallback, sideEffects) - Remove unused PrismaPlugin import - Turbopack handles all bundling without webpack configuration Benchmark shows no performance regression: - Main (with webpack): 67s compile - Full webpack removal: 69s compile Both fail at same pre-existing TypeScript error on main branch. Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com> * chore: convert next.config.js to TypeScript - Convert CommonJS require() to ES6 imports - Add proper TypeScript types for config and plugins - Remove /* eslint-disable */ comment - Keep all existing functionality intact Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com> * conditional load axiom --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 090247a commit 76b53eb

9 files changed

Lines changed: 246 additions & 239 deletions
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,58 @@
11
const isSingleOrgModeEnabled = !!process.env.NEXT_PUBLIC_SINGLE_ORG_SLUG;
22
const orgSlugCaptureGroupName = "orgSlug";
3+
34
/**
45
* Returns the leftmost subdomain from a given URL.
56
* It needs the URL domain to have atleast two dots.
67
* app.cal.com -> app
78
* app.company.cal.com -> app
89
* app.company.com -> app
910
*/
10-
const getLeftMostSubdomain = (url) => {
11-
if (!url.startsWith("http:") && !url.startsWith("https:")) {
11+
const getLeftMostSubdomain = (url: string): string | null => {
12+
let normalizedUrl = url;
13+
if (!normalizedUrl.startsWith("http:") && !normalizedUrl.startsWith("https:")) {
1214
// Make it a valid URL. Maybe we can simply return null and opt-out from orgs support till the use a URL scheme.
13-
url = `https://${url}`;
15+
normalizedUrl = `https://${normalizedUrl}`;
1416
}
15-
const _url = new URL(url);
16-
const regex = new RegExp(/^([a-z]+\:\/{2})?((?<subdomain>[\w-.]+)\.[\w-]+\.\w+)$/);
17-
//console.log(_url.hostname, _url.hostname.match(regex));
18-
return _url.hostname.match(regex)?.groups?.subdomain || null;
17+
const _url = new URL(normalizedUrl);
18+
// Using positional capture instead of named capture group for ES2017 compatibility
19+
// Group 1: protocol (optional), Group 2: full domain, Group 3: subdomain
20+
const regex = /^([a-z]+:\/{2})?(([\w-.]+)\.[\w-]+\.\w+)$/;
21+
return _url.hostname.match(regex)?.[3] ?? null;
1922
};
2023

21-
const getRegExpNotMatchingLeftMostSubdomain = (url) => {
24+
const getRegExpNotMatchingLeftMostSubdomain = (url: string): string => {
2225
const leftMostSubdomain = getLeftMostSubdomain(url);
2326
const subdomain = leftMostSubdomain ? `(?!${leftMostSubdomain})[^.]+` : "[^.]+";
2427
return subdomain;
2528
};
2629

30+
export interface NextJsOrgRewriteConfig {
31+
orgSlug: string;
32+
orgHostPath: string;
33+
disableRootPathRewrite: boolean;
34+
disableRootEmbedPathRewrite: boolean;
35+
}
36+
2737
// For app.cal.com, it will match all domains that are not starting with "app". Technically we would want to match domains like acme.cal.com, dunder.cal.com and not app.cal.com
28-
const getRegExpThatMatchesAllOrgDomains = (exports.getRegExpThatMatchesAllOrgDomains = ({ webAppUrl }) => {
38+
export const getRegExpThatMatchesAllOrgDomains = ({ webAppUrl }: { webAppUrl: string }): string => {
2939
if (isSingleOrgModeEnabled) {
3040
console.log("Single-Org-Mode enabled - Consider all domains to be org domains");
3141
// It works in combination with next.config.js where in this case we use orgSlug=NEXT_PUBLIC_SINGLE_ORG_SLUG
3242
return `.*`;
3343
}
3444
const subdomainRegExp = getRegExpNotMatchingLeftMostSubdomain(webAppUrl);
35-
return `^(?<${orgSlugCaptureGroupName}>${subdomainRegExp})\\.(?!vercel\.app).*`;
36-
});
45+
return `^(?<${orgSlugCaptureGroupName}>${subdomainRegExp})\\.(?!vercel\\.app).*`;
46+
};
3747

38-
const nextJsOrgRewriteConfig = {
48+
export const nextJsOrgRewriteConfig: NextJsOrgRewriteConfig = {
3949
// :orgSlug is special value which would get matching group from the regex in orgHostPath
4050
orgSlug: process.env.NEXT_PUBLIC_SINGLE_ORG_SLUG || `:${orgSlugCaptureGroupName}`,
4151
orgHostPath: getRegExpThatMatchesAllOrgDomains({
4252
webAppUrl: process.env.NEXT_PUBLIC_WEBAPP_URL || `https://${process.env.VERCEL_URL}`,
4353
}),
4454
// We disable root path rewrite because we want to serve dashboard on root path
4555
disableRootPathRewrite: isSingleOrgModeEnabled,
56+
// We disable root embed path rewrite in single org mode as well
57+
disableRootEmbedPathRewrite: isSingleOrgModeEnabled,
4658
};
47-
48-
exports.nextJsOrgRewriteConfig = nextJsOrgRewriteConfig;

apps/web/next-i18next.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/web/next-i18next.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import path from "path";
2+
3+
import i18nConfig from "@calcom/config/next-i18next.config";
4+
5+
import type { UserConfig } from "next-i18next";
6+
7+
const config: UserConfig = {
8+
...i18nConfig,
9+
localePath: path.resolve("./public/static/locales"),
10+
};
11+
12+
export default config;

0 commit comments

Comments
 (0)