Skip to content

Commit 2912293

Browse files
authored
fix: atoms local (calcom#22245)
* Revert "fix: atoms for local development (calcom#22178)" This reverts commit d74d99d. * chore: remove comment * feat: local dev scripts * feat: local dev scripts
1 parent 0825cce commit 2912293

7 files changed

Lines changed: 25 additions & 26 deletions

File tree

packages/platform/atoms/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
globals.min.css
2-
cal-atoms-dev.tgz
1+
globals.min.css

packages/platform/atoms/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"build": "NODE_OPTIONS='--max_old_space_size=12288' rm -rf dist && yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify && mkdir ./dist/packages/prisma-client && cp -rf ../../../node_modules/.prisma/client/*.d.ts ./dist/packages/prisma-client",
1111
"publish-npm": "yarn build && npm publish --access public",
1212
"test": "jest",
13-
"pack-dev": "yarn build && npm pack && mv calcom-atoms-*.tgz cal-atoms-dev.tgz"
13+
"dev-on": "node scripts/dev-on.js",
14+
"dev-off": "git checkout -- package.json vite.config.ts"
1415
},
1516
"devDependencies": {
1617
"@rollup/plugin-node-resolve": "^15.0.1",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from "fs";
2+
import path from "path";
3+
import { fileURLToPath } from "url";
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
const packageJsonPath = path.join(__dirname, "../package.json");
7+
const viteConfigPath = path.join(__dirname, "../vite.config.ts");
8+
9+
// Modify package.json
10+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
11+
packageJson.main = "./dist/cal-atoms.umd.cjs";
12+
packageJson.exports["."].require = "./dist/cal-atoms.umd.cjs";
13+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
14+
15+
// Modify vite.config.ts
16+
let viteConfig = fs.readFileSync(viteConfigPath, "utf-8");
17+
viteConfig = viteConfig.replace(/formats: \["es"\],/g, "");
18+
viteConfig = viteConfig.replace(/external: \[([^\]]+)\]/, 'external: [$1, "react-awesome-query-builder"]');
19+
viteConfig = viteConfig.replace(/format: "esm",\s*/g, "");
20+
fs.writeFileSync(viteConfigPath, viteConfig);

packages/platform/atoms/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default defineConfig(({ mode }) => {
3636
rollupOptions: {
3737
external: ["react", "fs", "path", "os", "react/jsx-runtime", "react-dom", "react-dom/client"],
3838
output: {
39-
format: "esm", // Force ESM output
39+
format: "esm",
4040
globals: {
4141
react: "React",
4242
"react-dom": "ReactDOM",

packages/platform/examples/base/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ REDIS_URL="redis://localhost:6379"
1919
```
2020

2121
3. Start "apps/api/v2" api using `yarn dev`.
22-
4. Setup "packages/platform/atoms" by running `yarn atoms-dev-on` in the example app directory - it will pack atoms into a dev .tgz and switch the dependency to point to it. When you are done with development, run `yarn atoms-dev-off` to switch back to the published version because otherwise examples app would have entry in the yarn.lock file pointing to the dev .tgz and installation would fail in prod because dev tar file exists only locally.
22+
4. Start "packages/platform/atoms" atoms package with `yarn dev`.
2323
5. Start "apps/web" cal web app using `yarn dx`.
2424
6. Open your browser at "http://localhost:3000/" and login with admin username `admin@example.com` and password `ADMINadmin2022!`.
2525
7. In the web app navigate to `http://localhost:3000/settings/organizations/new` and create a sample organization. When asked for phone verification code enter `111111`.

packages/platform/examples/base/atoms-dev-on.sh

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

packages/platform/examples/base/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"private": true,
55
"scripts": {
66
"dev": "PORT=4321 next dev",
7-
"atoms-dev-on": "./atoms-dev-on.sh",
8-
"atoms-dev-off": "git checkout -- package.json ../../../../yarn.lock",
97
"build": "next build",
108
"start": "next start",
119
"lint": "next lint"

0 commit comments

Comments
 (0)