rasengan 1.0.0-beta.60 → 1.0.0-beta.61

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.0.0-beta.61 (2025-03-22)
4
+
3
5
  ## 1.0.0-beta.60 (2025-03-16)
4
6
 
5
7
  ## 1.0.0-beta.59 (2025-03-16)
@@ -48,7 +48,7 @@ export const createDefaultViteConfig = (rootPath, __dirname, mode, config) => {
48
48
  client: {
49
49
  build: {
50
50
  manifest: true,
51
- outDir: 'dist/client',
51
+ outDir: config.ssr ? 'dist/client' : 'dist',
52
52
  rollupOptions: {
53
53
  input: './src/index',
54
54
  },
@@ -95,7 +95,6 @@ export const Adapters = {
95
95
  export function rasengan({ adapter = { name: Adapters.DEFAULT, prepare: async () => { } }, }) {
96
96
  let config;
97
97
  let viteConfig;
98
- const templateFileRegex = /template\.(tsx|jsx)$/;
99
98
  const buildOptions = resolveBuildOptions({});
100
99
  return {
101
100
  name: 'vite-plugin-rasengan',
@@ -126,8 +125,11 @@ export function rasengan({ adapter = { name: Adapters.DEFAULT, prepare: async ()
126
125
  return fs.existsSync(modulePath);
127
126
  });
128
127
  const module = await this.load({ id: modulePath });
129
- // Generate the template.js file into the dist/assets
130
- fs.writeFileSync(path.posix.join(process.cwd(), buildOptions.buildDirectory, buildOptions.clientPathDirectory, buildOptions.assetPathDirectory, 'template.js'), module.code, 'utf-8');
128
+ // SPA mode only
129
+ if (!config.ssr) {
130
+ // Generate the template.js file into the dist/assets
131
+ fs.writeFileSync(path.posix.join(process.cwd(), buildOptions.buildDirectory, buildOptions.assetPathDirectory, 'template.js'), module.code, 'utf-8');
132
+ }
131
133
  },
132
134
  async closeBundle() {
133
135
  // We check here if the environment is client has been built because it's the
@@ -136,7 +138,7 @@ export function rasengan({ adapter = { name: Adapters.DEFAULT, prepare: async ()
136
138
  // Check if SPA mode is enabled
137
139
  if (!config.ssr) {
138
140
  // Load the template.js file
139
- const templatePath = path.posix.join(process.cwd(), buildOptions.buildDirectory, buildOptions.clientPathDirectory, buildOptions.assetPathDirectory, 'template.js');
141
+ const templatePath = path.posix.join(process.cwd(), buildOptions.buildDirectory, buildOptions.assetPathDirectory, 'template.js');
140
142
  const Template = (await import(templatePath)).default;
141
143
  // Render the index.html file
142
144
  await renderIndexHTML(Template, {
@@ -144,24 +146,28 @@ export function rasengan({ adapter = { name: Adapters.DEFAULT, prepare: async ()
144
146
  config,
145
147
  });
146
148
  }
147
- // Generate a config.json file into the dist/client/assets
148
- fs.writeFileSync(path.posix.join(process.cwd(), buildOptions.buildDirectory, buildOptions.clientPathDirectory, buildOptions.assetPathDirectory, 'config.json'), JSON.stringify({
149
+ // Generate a config.json file into the dist/client/assets or dist/assets
150
+ fs.writeFileSync(path.posix.join(process.cwd(), buildOptions.buildDirectory, config.ssr ? buildOptions.clientPathDirectory : '', buildOptions.assetPathDirectory, 'config.json'), JSON.stringify({
149
151
  buildOptions,
150
152
  ssr: config.ssr,
151
153
  }), 'utf-8');
152
- // Preparing app for deployment
153
- switch (adapter.name) {
154
- case Adapters.VERCEL: {
155
- console.log('Preparing app for deployment to Vercel');
156
- await adapter.prepare();
157
- break;
158
- }
159
- default:
160
- break;
161
- }
154
+ // Prepare the app for deployment
155
+ await prepareToDeploy(adapter);
162
156
  }
163
157
  },
164
158
  apply: 'build',
165
159
  };
166
160
  }
161
+ const prepareToDeploy = async (adapter) => {
162
+ // Preparing app for deployment
163
+ switch (adapter.name) {
164
+ case Adapters.VERCEL: {
165
+ console.log('Preparing app for deployment to Vercel');
166
+ await adapter.prepare();
167
+ break;
168
+ }
169
+ default:
170
+ break;
171
+ }
172
+ };
167
173
  export const plugins = [loadRasenganGlobal()];
@@ -8,11 +8,13 @@ import fs from "node:fs/promises";
8
8
  export const renderIndexHTML = async (template, options) => {
9
9
  const { rootPath, config } = options;
10
10
  const buildOptions = resolveBuildOptions({});
11
- const manifest = new ManifestManager(path.posix.join(buildOptions.buildDirectory, buildOptions.clientPathDirectory, buildOptions.manifestPathDirectory, 'manifest.json'));
11
+ const manifest = new ManifestManager(path.posix.join(buildOptions.buildDirectory, config.ssr ? buildOptions.clientPathDirectory : '', buildOptions.manifestPathDirectory, 'manifest.json'));
12
12
  // Get assets tags
13
13
  const assets = manifest.generateMetaTags(''); // TODO: Add the correct path
14
14
  // Generate html from template
15
15
  const html = renderToString(_jsx(TemplateLayout, { Template: template, assets: assets, isSpaMode: true }));
16
16
  // Render the html into an index.html file
17
- await fs.writeFile(path.posix.join(rootPath, buildOptions.buildDirectory, buildOptions.clientPathDirectory, 'index.html'), html, 'utf-8');
17
+ await fs.writeFile(path.posix.join(rootPath, buildOptions.buildDirectory, 'index.html'), html, 'utf-8');
18
+ // Delete the dist/assets/template.js file
19
+ await fs.rm(path.posix.join(rootPath, buildOptions.buildDirectory, buildOptions.assetPathDirectory, 'template.js'));
18
20
  };
@@ -40,5 +40,8 @@ export const renderToStream = async (Component, res) => {
40
40
  };
41
41
  export const renderToString = (Component) => {
42
42
  const html = ReactDOM.renderToString(Component);
43
- return html;
43
+ return `
44
+ <!DOCTYPE html>
45
+ ${html}
46
+ `;
44
47
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.60",
4
+ "version": "1.0.0-beta.61",
5
5
  "description": "The modern React Framework",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",