revine 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import fs from "fs-extra";
3
3
  import { updateViteConfig } from "../config/vite.js";
4
4
  import { logInfo } from "../utils/logger.js";
5
5
  export async function setupTailwind(projectDir) {
6
- logInfo("\nSetting up Tailwind CSS v4...");
6
+ logInfo("\nSetting up Tailwind CSS...");
7
7
  // Point to the hidden Vite config
8
8
  const viteConfigPath = path.join(projectDir, ".revine", "bundler", "vite.config.ts");
9
9
  // Now use existing updateViteConfig logic on this new path
@@ -13,8 +13,8 @@ export async function setupTailwind(projectDir) {
13
13
  await fs.ensureDir(cssDir);
14
14
  await fs.writeFile(path.join(cssDir, "global.css"), "@import 'tailwindcss';\n");
15
15
  // Prepend the CSS import to src/main.tsx
16
- const mainTsxPath = path.join(projectDir, "src", "main.tsx");
16
+ const rootTsxPath = path.join(projectDir, "src", "root.tsx");
17
17
  const mainContent = `import './styles/global.css';\n` +
18
- (await fs.readFile(mainTsxPath, "utf-8"));
19
- await fs.writeFile(mainTsxPath, mainContent);
18
+ (await fs.readFile(rootTsxPath, "utf-8"));
19
+ await fs.writeFile(rootTsxPath, mainContent);
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revine",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "A react framework, but better.",
5
5
  "license": "ISC",
6
6
  "author": "Rachit Bharadwaj",
@@ -4,7 +4,7 @@ import { updateViteConfig } from "../config/vite.js";
4
4
  import { logInfo } from "../utils/logger.js";
5
5
 
6
6
  export async function setupTailwind(projectDir: string) {
7
- logInfo("\nSetting up Tailwind CSS v4...");
7
+ logInfo("\nSetting up Tailwind CSS...");
8
8
 
9
9
  // Point to the hidden Vite config
10
10
  const viteConfigPath = path.join(
@@ -26,9 +26,9 @@ export async function setupTailwind(projectDir: string) {
26
26
  );
27
27
 
28
28
  // Prepend the CSS import to src/main.tsx
29
- const mainTsxPath = path.join(projectDir, "src", "main.tsx");
29
+ const rootTsxPath = path.join(projectDir, "src", "root.tsx");
30
30
  const mainContent =
31
31
  `import './styles/global.css';\n` +
32
- (await fs.readFile(mainTsxPath, "utf-8"));
33
- await fs.writeFile(mainTsxPath, mainContent);
32
+ (await fs.readFile(rootTsxPath, "utf-8"));
33
+ await fs.writeFile(rootTsxPath, mainContent);
34
34
  }
@@ -0,0 +1,38 @@
1
+ import { createBrowserRouter } from "react-router-dom";
2
+ import { lazy, Suspense, ComponentType } from "react";
3
+
4
+ const pages = import.meta.glob("../../src/pages/**/*.tsx");
5
+
6
+ const routes = Object.entries(pages).map(([filePath, component]) => {
7
+ let cleaned = filePath.replace(/\\/g, "/");
8
+
9
+ cleaned = cleaned.replace(/.*\/pages\//, "");
10
+
11
+ cleaned = cleaned.replace(/\.tsx$/i, "");
12
+
13
+ cleaned = cleaned.replace(/\/index$/, "");
14
+
15
+ cleaned = cleaned.replace(/\[(\w+)\]/g, ":$1");
16
+
17
+ if (cleaned === "index") {
18
+ cleaned = "";
19
+ }
20
+
21
+ // 6. Route path is empty for index => "/"
22
+ const routePath = cleaned === "" ? "/" : `/${cleaned}`;
23
+
24
+ const Component = lazy(
25
+ component as unknown as () => Promise<{ default: ComponentType }>
26
+ );
27
+
28
+ return {
29
+ path: routePath,
30
+ element: (
31
+ <Suspense fallback={<div>Loading...</div>}>
32
+ <Component />
33
+ </Suspense>
34
+ ),
35
+ };
36
+ });
37
+
38
+ export const router = createBrowserRouter(routes);
@@ -11,7 +11,7 @@
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
14
- <script type="module" src="/src/main.tsx"></script>
14
+ <script type="module" src="/src/root.tsx"></script>
15
15
  <noscript>
16
16
  <h1>This application requires JavaScript to run.</h1>
17
17
  </noscript>
@@ -1,30 +1,5 @@
1
- import { createBrowserRouter, RouterProvider } from "react-router-dom";
2
- import { lazy, Suspense, ComponentType } from "react";
3
-
4
- const pages = import.meta.glob("./pages/**/*.tsx");
5
-
6
- const routes = Object.entries(pages).map(([path, component]) => {
7
- const routePath = path
8
- .replace(/\.\/pages\//i, "")
9
- .replace(/\.tsx$/i, "")
10
- .replace(/\/index$/i, "")
11
- .replace(/\[(\w+)\]/g, ":$1");
12
-
13
- const Component = lazy(
14
- component as unknown as () => Promise<{ default: ComponentType }>
15
- );
16
-
17
- return {
18
- path: routePath === "index" ? "/" : `/${routePath}`,
19
- element: (
20
- <Suspense fallback={<div>Loading...</div>}>
21
- <Component />
22
- </Suspense>
23
- ),
24
- };
25
- });
26
-
27
- const router = createBrowserRouter(routes);
1
+ import { RouterProvider } from "react-router-dom";
2
+ import { router } from "../.revine/routing/fileBased";
28
3
 
29
4
  export default function App() {
30
5
  return <RouterProvider router={router} />;
@@ -16,5 +16,5 @@
16
16
  "noFallthroughCasesInSwitch": true,
17
17
  "types": ["vite/client"]
18
18
  },
19
- "include": ["src", ".revine/bundler/types/**/*"]
19
+ "include": ["src", ".revine/**/*"]
20
20
  }
File without changes