dinou 4.0.6 → 4.0.7

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
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [4.0.7]
9
+
10
+ ### Fixed
11
+
12
+ - env vars in getProps and json files in esbuild.
13
+
8
14
  ## [4.0.6]
9
15
 
10
16
  ### Fixed
@@ -9,7 +9,7 @@ function toFileUrl(p) {
9
9
  }
10
10
 
11
11
  const registerLoaderPath = toFileUrl(
12
- path.join(__dirname, "register-loader.mjs")
12
+ path.join(__dirname, "register-loader.mjs"),
13
13
  );
14
14
  const renderHtmlPath = path.resolve(__dirname, "render-html.js");
15
15
 
@@ -33,7 +33,7 @@ function renderAppToHtml(
33
33
  contextForChild,
34
34
  res,
35
35
  capturedStatus = null,
36
- isDynamic = false
36
+ isDynamic = false,
37
37
  ) {
38
38
  const jsxJson = getJSXJSON(reqPath);
39
39
  const hasJsxJson = hasJSXJSON(reqPath);
@@ -52,15 +52,15 @@ function renderAppToHtml(
52
52
  renderHtmlPath, // ⬅️ CHANGE 2: The script (path) is the first argument of fork (no need for "node")
53
53
  scriptArgs, // Positional arguments for the script (process.argv)
54
54
  {
55
- env: {
56
- NODE_ENV: process.env.NODE_ENV,
57
- DINOU_BUILD_TOOL: process.env.DINOU_BUILD_TOOL,
58
- }, // You can pass other environment variables if necessary
55
+ // env: {
56
+ // NODE_ENV: process.env.NODE_ENV,
57
+ // DINOU_BUILD_TOOL: process.env.DINOU_BUILD_TOOL,
58
+ // }, // You can pass other environment variables if necessary
59
59
  // ⬅️ CHANGE 3: Apply Whitelist to execArgv, resetting inherited options
60
60
  execArgv: childExecArgv,
61
61
  // ⬅️ CHANGE 4: stdio needs 'ipc' for fork to work and for the future communication channel
62
62
  stdio: ["ignore", "pipe", "pipe", "ipc"], // stdin, stdout, stderr, ipc
63
- }
63
+ },
64
64
  );
65
65
 
66
66
  // 💡 on('message') Implementation (IPC Channel)
@@ -88,7 +88,7 @@ function renderAppToHtml(
88
88
  if (command === "redirect") {
89
89
  const url = args.length === 1 ? args[0] : args[1];
90
90
  console.log(
91
- `[Dinou] Streaming active. Redirecting via JavaScript to: ${url}`
91
+ `[Dinou] Streaming active. Redirecting via JavaScript to: ${url}`,
92
92
  );
93
93
  const safeUrl = JSON.stringify(url);
94
94
  res.write(`<script>window.location.href = ${safeUrl};</script>`);
@@ -99,7 +99,7 @@ function renderAppToHtml(
99
99
  // --- STATUS (Warning) ---
100
100
  if (command === "status") {
101
101
  console.warn(
102
- `[Dinou Warning] HTTP status '${args[0]}' ignored because streaming started.`
102
+ `[Dinou Warning] HTTP status '${args[0]}' ignored because streaming started.`,
103
103
  );
104
104
  if (capturedStatus) capturedStatus.value = args[0];
105
105
  return;
@@ -110,12 +110,12 @@ function renderAppToHtml(
110
110
  const [name, options] = args;
111
111
  const path = options && options.path ? options.path : "/";
112
112
  console.log(
113
- `[Dinou] Streaming active. Clearing cookie '${name}' via JS.`
113
+ `[Dinou] Streaming active. Clearing cookie '${name}' via JS.`,
114
114
  );
115
115
  const safeName = JSON.stringify(name);
116
116
  const safePath = JSON.stringify(path);
117
117
  res.write(
118
- `<script>document.cookie = ${safeName} + "=; Max-Age=0; path=" + ${safePath} + ";";</script>`
118
+ `<script>document.cookie = ${safeName} + "=; Max-Age=0; path=" + ${safePath} + ";";</script>`,
119
119
  );
120
120
  return;
121
121
  }
@@ -129,13 +129,13 @@ function renderAppToHtml(
129
129
  if (options && options.httpOnly) {
130
130
  console.error(
131
131
  `[Dinou Error] Cannot set HttpOnly cookie '${name}' because streaming has already started. ` +
132
- `Headers are sent, and document.cookie cannot write HttpOnly cookies.`
132
+ `Headers are sent, and document.cookie cannot write HttpOnly cookies.`,
133
133
  );
134
134
  return; // We do nothing because it would fail silently in the browser
135
135
  }
136
136
 
137
137
  console.log(
138
- `[Dinou] Streaming active. Setting cookie '${name}' via JS.`
138
+ `[Dinou] Streaming active. Setting cookie '${name}' via JS.`,
139
139
  );
140
140
 
141
141
  // We build the cookie string manually for JS
@@ -148,7 +148,7 @@ function renderAppToHtml(
148
148
  if (options.maxAge) cookieStr += `; max-age=${options.maxAge}`;
149
149
  if (options.expires)
150
150
  cookieStr += `; expires=${new Date(
151
- options.expires
151
+ options.expires,
152
152
  ).toUTCString()}`;
153
153
  if (options.secure) cookieStr += `; secure`;
154
154
  if (options.sameSite)
@@ -164,7 +164,7 @@ function renderAppToHtml(
164
164
  // --- SET HEADER (Warning) ---
165
165
  if (command === "setHeader") {
166
166
  console.warn(
167
- `[Dinou Warning] Cannot set header '${args[0]}' because streaming started.`
167
+ `[Dinou Warning] Cannot set header '${args[0]}' because streaming started.`,
168
168
  );
169
169
  return;
170
170
  }
@@ -202,7 +202,7 @@ function renderAppToHtml(
202
202
  finalUrl = rawUrl;
203
203
  } else {
204
204
  console.warn(
205
- `[Dinou Security] Blocked unsafe redirect to: ${rawUrl}`
205
+ `[Dinou Security] Blocked unsafe redirect to: ${rawUrl}`,
206
206
  );
207
207
  // finalUrl remains "/"
208
208
  }
@@ -33,7 +33,7 @@ export default async function getEsbuildEntries({
33
33
  code,
34
34
  baseFilePath,
35
35
  visited = new Set(),
36
- isTopLevelClientComponent = false
36
+ isTopLevelClientComponent = false,
37
37
  ) {
38
38
  if (visited.has(baseFilePath)) {
39
39
  return { imports: [], assets: [], csss: [] };
@@ -75,7 +75,7 @@ export default async function getEsbuildEntries({
75
75
  } catch (err) {
76
76
  console.warn(
77
77
  `[get-esbuild-entries] Could not read import: ${absImportPathWithExt}`,
78
- err.message
78
+ err.message,
79
79
  );
80
80
  continue;
81
81
  }
@@ -111,6 +111,12 @@ export default async function getEsbuildEntries({
111
111
  continue;
112
112
  }
113
113
 
114
+ // 🚨 LA SOLUCIÓN: Si es un JSON, lo añadimos pero NO lo parseamos con Babel
115
+ if (absImportPathWithExt.endsWith(".json")) {
116
+ imports.add(absImportPathWithExt);
117
+ continue; // Esto evita que pase a la recursividad de Babel
118
+ }
119
+
114
120
  imports.add(absImportPathWithExt);
115
121
 
116
122
  // Procesar imports recursivamente para módulos no-client
@@ -119,7 +125,7 @@ export default async function getEsbuildEntries({
119
125
  importedCode,
120
126
  absImportPathWithExt,
121
127
  visited,
122
- isTopLevelClientComponent
128
+ isTopLevelClientComponent,
123
129
  );
124
130
  nested.imports.forEach((p) => imports.add(p));
125
131
  nested.assets.forEach((p) => assets.add(p));
@@ -127,7 +133,7 @@ export default async function getEsbuildEntries({
127
133
  } catch (err) {
128
134
  console.warn(
129
135
  `[get-esbuild-entries] Could not process imports of: ${absImportPathWithExt}`,
130
- err.message
136
+ err.message,
131
137
  );
132
138
  }
133
139
  }
@@ -203,7 +209,7 @@ export default async function getEsbuildEntries({
203
209
  code,
204
210
  absPath,
205
211
  new Set(),
206
- true
212
+ true,
207
213
  );
208
214
  const clientComponentRegex = /\.(js|jsx|ts|tsx)$/i;
209
215
  imports.forEach((imp) => {
@@ -218,14 +224,14 @@ export default async function getEsbuildEntries({
218
224
  } else if (isPageOrLayout(absPath)) {
219
225
  if (!isAsyncDefaultExport(code)) {
220
226
  console.warn(
221
- `[react-client-manifest] The file ${normalizedPath} is a page or layout without "use client" directive, but its default export is not an async function.`
227
+ `[react-client-manifest] The file ${normalizedPath} is a page or layout without "use client" directive, but its default export is not an async function.`,
222
228
  );
223
229
  }
224
230
  serverModules.add(normalizedPath);
225
231
  try {
226
232
  const { imports, assets, csss } = await getImportsAndAssetsAndCsss(
227
233
  code,
228
- absPath
234
+ absPath,
229
235
  );
230
236
 
231
237
  if (csss.length > 0) {
@@ -233,7 +239,7 @@ export default async function getEsbuildEntries({
233
239
  ...csss.map((cssPath) => ({
234
240
  absPath: normalizePath(cssPath),
235
241
  name: path.basename(cssPath, path.extname(cssPath)),
236
- }))
242
+ })),
237
243
  );
238
244
  }
239
245
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou-ejected",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "main": "index.js",
5
5
  "private": true,
6
6
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "Full-Stack React 19 framework with React Server Components, Server Functions, and Streaming SSR.",
5
5
  "main": "index.js",
6
6
  "bin": {