@rayburst/cli 0.1.16 → 0.1.18

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.
package/bin/rayburst.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { Command } from 'commander';
4
4
  import chalk from 'chalk';
5
- import { spawn, exec } from 'child_process';
5
+ import { spawn } from 'child_process';
6
6
  import { fileURLToPath } from 'url';
7
7
  import { dirname, join, resolve } from 'path';
8
8
  import {
@@ -29,7 +29,7 @@ program
29
29
  .command('start')
30
30
  .description('Start the Rayburst application')
31
31
  .option('-p, --port <port>', 'Port to run the server on', '3105')
32
- .option('-e, --env <environment>', 'Environment (local|staging|production)', 'production')
32
+ .option('-e, --env <environment>', 'Environment (development|staging|production)', 'development')
33
33
  .action((options) => {
34
34
  console.log(chalk.blue('šŸš€ Starting Rayburst CLI...'));
35
35
  console.log(chalk.gray(` Port: ${options.port}`));
@@ -48,22 +48,6 @@ program
48
48
  stdio: 'inherit',
49
49
  });
50
50
 
51
- // Open browser after server starts
52
- let browserOpened = false;
53
- setTimeout(() => {
54
- if (!browserOpened) {
55
- browserOpened = true;
56
- const url = `http://localhost:${options.port}`;
57
- const openCommand = process.platform === 'darwin' ? 'open' :
58
- process.platform === 'win32' ? 'start' : 'xdg-open';
59
- exec(`${openCommand} ${url}`, (err) => {
60
- if (err) {
61
- console.log(chalk.dim(`\nšŸ’” Open your browser to: ${url}`));
62
- }
63
- });
64
- }
65
- }, 2000);
66
-
67
51
  server.on('error', (err) => {
68
52
  console.error(chalk.red('Failed to start server:'), err);
69
53
  process.exit(1);
package/package.json CHANGED
@@ -1,22 +1,12 @@
1
1
  {
2
2
  "name": "@rayburst/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Rayburst CLI - A module federation host for Rayburst app",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "rayburst": "./bin/rayburst.js"
8
8
  },
9
9
  "main": "./server.js",
10
- "files": [
11
- "bin",
12
- "src",
13
- "scripts",
14
- "dist",
15
- "server.js",
16
- "vite.config.ts",
17
- "vite-plugin-api.js",
18
- "index.html"
19
- ],
20
10
  "scripts": {
21
11
  "dev": "vite",
22
12
  "build": "vite build",
@@ -39,9 +29,12 @@
39
29
  },
40
30
  "devDependencies": {
41
31
  "@module-federation/vite": "^1.9.0",
32
+ "@tailwindcss/vite": "^4.1.17",
42
33
  "@vitejs/plugin-react": "^4.2.1",
43
34
  "react": "^19.0.0",
44
35
  "react-dom": "^19.0.0",
36
+ "tailwindcss": "^4.1.17",
37
+ "tw-animate-css": "^1.4.0",
45
38
  "vite": "^7.1.7"
46
39
  },
47
40
  "peerDependencies": {
package/server.js CHANGED
@@ -25,14 +25,13 @@ const hasBuilt = existsSync(distPath);
25
25
  // Environment-specific remote URLs
26
26
  function getRemoteUrl(env) {
27
27
  switch (env) {
28
- case 'local':
29
- return 'http://localhost:3000';
28
+ case 'production':
29
+ return 'https://www.rayburst.app';
30
30
  case 'staging':
31
31
  return 'https://dev.rayburst.app';
32
32
  case 'development':
33
- case 'production':
34
33
  default:
35
- return 'https://www.rayburst.app';
34
+ return 'http://localhost:3000';
36
35
  }
37
36
  }
38
37
 
package/src/main.tsx CHANGED
@@ -86,14 +86,113 @@ class ErrorBoundary extends React.Component<
86
86
  }
87
87
  }
88
88
 
89
+ // Function to load remote CSS
90
+ const loadRemoteCSS = async () => {
91
+ try {
92
+ // Determine the remote URL based on environment
93
+ const isDevelopment = import.meta.env.DEV;
94
+ const remoteUrl = isDevelopment
95
+ ? 'http://localhost:3000'
96
+ : import.meta.env.PROD
97
+ ? 'https://www.rayburst.app'
98
+ : 'https://dev.rayburst.app';
99
+
100
+ console.log('[CLI] Attempting to load CSS from:', remoteUrl, '(dev mode:', isDevelopment, ')');
101
+
102
+ if (isDevelopment) {
103
+ // In development mode, Vite serves CSS as a JavaScript module
104
+ // We need to dynamically import it to trigger Vite's CSS injection
105
+ console.log('[CLI] Development mode: Importing CSS module from Vite dev server');
106
+
107
+ const cssModuleUrl = `${remoteUrl}/src/styles.css`;
108
+
109
+ try {
110
+ // Check if we've already loaded this CSS module
111
+ if (!(window as any).__rayburstCssLoaded) {
112
+ console.log('[CLI] Dynamically importing CSS module:', cssModuleUrl);
113
+
114
+ // Create a script tag to load the CSS module
115
+ const script = document.createElement('script');
116
+ script.type = 'module';
117
+ script.textContent = `import '${cssModuleUrl}';`;
118
+ document.head.appendChild(script);
119
+
120
+ // Mark as loaded
121
+ (window as any).__rayburstCssLoaded = true;
122
+ console.log('[CLI] CSS module import initiated');
123
+
124
+ // Give it a moment to process
125
+ await new Promise(resolve => setTimeout(resolve, 100));
126
+ } else {
127
+ console.log('[CLI] CSS module already loaded');
128
+ }
129
+ } catch (cssErr) {
130
+ console.warn('[CLI] Could not load CSS module, styles may be missing:', cssErr);
131
+ }
132
+ } else {
133
+ // In production/staging, fetch the index.html to find the CSS file
134
+ const response = await fetch(remoteUrl);
135
+ const html = await response.text();
136
+
137
+ // Extract CSS filename from the HTML
138
+ const cssMatch = html.match(/href="\/assets\/(style-[^"]+\.css)"/);
139
+
140
+ if (cssMatch && cssMatch[1]) {
141
+ const cssFile = cssMatch[1];
142
+ const cssUrl = `${remoteUrl}/assets/${cssFile}`;
143
+
144
+ console.log('[CLI] Loading remote CSS:', cssUrl);
145
+
146
+ // Check if CSS is already loaded
147
+ const existingLink = document.querySelector(`link[href="${cssUrl}"]`);
148
+ if (!existingLink) {
149
+ const link = document.createElement('link');
150
+ link.rel = 'stylesheet';
151
+ link.href = cssUrl;
152
+ document.head.appendChild(link);
153
+ console.log('[CLI] Remote CSS loaded successfully');
154
+
155
+ // Wait for CSS to load
156
+ await new Promise((resolve) => {
157
+ link.onload = resolve;
158
+ link.onerror = resolve;
159
+ });
160
+ }
161
+ } else {
162
+ console.warn('[CLI] No CSS file found in remote HTML');
163
+ }
164
+ }
165
+ } catch (err) {
166
+ console.error('[CLI] Failed to load remote CSS:', err);
167
+ }
168
+ };
169
+
89
170
  // Dynamically import the remote app
90
- const RemoteApp = lazy(() => {
91
- // @ts-ignore - Module federation import
92
- return import('rayburstApp/App')
93
- .catch((err) => {
94
- console.error('[CLI] Failed to load remote app:', err);
95
- throw new Error('Could not load Rayburst application from remote.');
171
+ const RemoteApp = lazy(async () => {
172
+ console.log('[CLI] Attempting to load remote app from rayburstApp/App');
173
+ console.log('[CLI] Expected remote URL:', 'http://localhost:3000/remoteEntry.js');
174
+
175
+ // Load the remote CSS first (in parallel with module loading)
176
+ const cssPromise = loadRemoteCSS();
177
+
178
+ try {
179
+ // @ts-ignore - Module federation import
180
+ const module = await import('rayburstApp/App');
181
+ console.log('[CLI] Successfully loaded remote app module:', module);
182
+
183
+ // Wait for CSS to finish loading
184
+ await cssPromise;
185
+
186
+ return module;
187
+ } catch (err: any) {
188
+ console.error('[CLI] Failed to load remote app:', err);
189
+ console.error('[CLI] Error details:', {
190
+ name: err.name,
191
+ message: err.message,
192
+ stack: err.stack
96
193
  });
194
+ throw new Error('Could not load Rayburst application. Make sure it is running on port 3000.');
195
+ }
97
196
  });
98
197
 
99
198
  function App() {
package/vite.config.ts CHANGED
@@ -6,14 +6,13 @@ import { apiPlugin } from './vite-plugin-api.js';
6
6
  // Determine remote URL based on environment
7
7
  function getRemoteUrl(env: string): string {
8
8
  switch (env) {
9
- case 'local':
10
- return 'http://localhost:3000';
9
+ case 'production':
10
+ return 'https://www.rayburst.app';
11
11
  case 'staging':
12
12
  return 'https://dev.rayburst.app';
13
13
  case 'development':
14
- case 'production':
15
14
  default:
16
- return 'https://www.rayburst.app';
15
+ return 'http://localhost:3000';
17
16
  }
18
17
  }
19
18
 
@@ -1,5 +0,0 @@
1
- function getDefaultExportFromCjs (x) {
2
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3
- }
4
-
5
- export { getDefaultExportFromCjs as g };
@@ -1,9 +0,0 @@
1
- import { _ as __vitePreload } from './preload-helper-Dea3Szod.js';
2
-
3
- const remoteEntryPromise = __vitePreload(() => import('./remoteEntry-lfoFMEF5.js'),true ?[]:void 0);
4
- // __tla only serves as a hack for vite-plugin-top-level-await.
5
- Promise.resolve(remoteEntryPromise)
6
- .then(remoteEntry => {
7
- return Promise.resolve(remoteEntry.__tla)
8
- .then(remoteEntry.init).catch(remoteEntry.init)
9
- });