dinou 8.0.3 → 8.1.0

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.
@@ -1,9 +1,14 @@
1
1
  import path from "node:path";
2
+ import fs from "node:fs";
2
3
  import manifestGeneratorPlugin from "./manifest-generator-plugin.js";
4
+ import parseExports from "../../core/parse-exports.js";
5
+ import { useServerRegex } from "../../constants.js";
6
+ import { extractServerFunctions, hasServerFunctions } from "../../core/transform-server-functions.js";
3
7
 
4
8
  class WebpackServerFunctionsPluginSimple {
5
- constructor() {
9
+ constructor(options = {}) {
6
10
  this.serverFunctions = new Map();
11
+ this.serverFiles = options.serverFiles || null;
7
12
  }
8
13
 
9
14
  apply(compiler) {
@@ -45,6 +50,34 @@ class WebpackServerFunctionsPluginSimple {
45
50
  }
46
51
  }
47
52
 
53
+ if (this.serverFiles && this.serverFiles.size > 0) {
54
+ for (const filePath of this.serverFiles) {
55
+ const rel = path.relative(process.cwd(), filePath).replace(/\\/g, "/");
56
+ if (!serverFunctionsManifest[rel]) {
57
+ try {
58
+ const fileCode = fs.readFileSync(filePath, "utf8");
59
+ if (useServerRegex.test(fileCode.trim())) {
60
+ const exports = parseExports(fileCode);
61
+ if (exports && exports.length > 0) {
62
+ serverFunctionsManifest[rel] = exports;
63
+ serverFunctionPaths.add(
64
+ path.resolve(process.cwd(), rel).replace(/\\/g, "/").toLowerCase()
65
+ );
66
+ }
67
+ } else if (hasServerFunctions(fileCode)) {
68
+ const actions = extractServerFunctions(fileCode, filePath);
69
+ if (actions && actions.length > 0) {
70
+ serverFunctionsManifest[rel] = actions;
71
+ serverFunctionPaths.add(
72
+ path.resolve(process.cwd(), rel).replace(/\\/g, "/").toLowerCase()
73
+ );
74
+ }
75
+ }
76
+ } catch (e) {}
77
+ }
78
+ }
79
+ }
80
+
48
81
  // 2. Generate final manifest
49
82
  const manifestContent = JSON.stringify(
50
83
  serverFunctionsManifest,
@@ -105,8 +138,17 @@ class WebpackServerFunctionsPluginSimple {
105
138
  }
106
139
 
107
140
  // 5. Replace placeholder ONLY in chunks that actually contain server functions
141
+ const isProd =
142
+ process.env.NODE_ENV === "production" &&
143
+ process.env.DINOU_DEV !== "true";
108
144
  const manifest = manifestGeneratorPlugin.manifestData;
109
- const hashedPath = manifest["serverFunctionProxy.js"] || "serverFunctionProxy.js";
145
+ const proxyName = manifest["serverFunctionProxy.js"];
146
+ if (isProd && !proxyName) {
147
+ throw new Error(
148
+ "[Dinou] webpack serverFunctionsPlugin: could not find hashed 'serverFunctionProxy.js' in manifest during production build."
149
+ );
150
+ }
151
+ const hashedPath = proxyName || "serverFunctionProxy.js";
110
152
 
111
153
  for (const filename of targetAssetFiles) {
112
154
  if (filename.endsWith(".js") && assets[filename]) {
@@ -1,3 +1,4 @@
1
+ import "./helpers/patch-webpack-internals.js";
1
2
  import "dotenv/config";
2
3
  import path from "node:path";
3
4
  import fs from "node:fs";
@@ -336,6 +337,7 @@ export default async () => {
336
337
  }),
337
338
  new ServerFunctionsPlugin({
338
339
  manifest: manifestGeneratorPlugin.manifestData,
340
+ serverFiles,
339
341
  }),
340
342
  isDevelopment && new WebpackMemoryPlugin(),
341
343
  !isDevelopment && {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "8.0.3",
3
+ "version": "8.1.0",
4
4
  "description": "Full-stack React 19 framework with native RSC, Server Functions, progressive streaming, and zero vendor lock-in.",
5
5
  "type": "module",
6
6
  "main": "./dinou/index.js",
@@ -58,54 +58,54 @@
58
58
  "url": "https://github.com/roggc/dinou.git"
59
59
  },
60
60
  "dependencies": {
61
- "@babel/core": "^7.27.4",
62
- "@babel/parser": "^7.28.3",
63
- "@babel/plugin-syntax-import-meta": "^7.10.4",
64
- "@babel/preset-react": "^7.27.1",
65
- "@babel/preset-typescript": "^7.27.1",
66
- "@babel/traverse": "^7.28.3",
67
- "@esbuild-plugins/tsconfig-paths": "^0.1.2",
68
- "@roggc/react-server-dom-esm": "^19.3.0",
69
- "@rollup/plugin-babel": "^6.0.4",
70
- "@rollup/plugin-commonjs": "^28.0.6",
71
- "@rollup/plugin-json": "^6.1.0",
72
- "@rollup/plugin-node-resolve": "^16.0.1",
73
- "@rollup/plugin-replace": "^6.0.2",
74
- "@swc/core": "^1.15.10",
75
- "@tailwindcss/postcss": "^4.1.10",
76
- "autoprefixer": "^10.4.21",
77
- "babel-loader": "^10.0.0",
78
- "babel-plugin-react-compiler": "^1.0.0",
79
- "chokidar": "^4.0.3",
80
- "commander": "^14.0.0",
81
- "copy-webpack-plugin": "^14.0.0",
82
- "cross-env": "^7.0.3",
83
- "css-loader": "^7.1.2",
84
- "dotenv": "^16.5.0",
85
- "esbuild": "^0.27.0",
86
- "esbuild-copy-static-files": "^0.1.0",
87
- "generic-names": "^4.0.0",
88
- "mini-css-extract-plugin": "^2.9.4",
89
- "postcss": "^8.5.5",
90
- "postcss-import": "^16.1.1",
91
- "postcss-loader": "^8.2.0",
92
- "postcss-modules": "^6.0.1",
93
- "react-refresh": "^0.17.0",
94
- "react-server-dom-webpack": "^19.3.0",
95
- "rollup": "^4.46.2",
96
- "rollup-plugin-copy": "^3.5.0",
97
- "rollup-plugin-delete": "^3.0.1",
98
- "rollup-plugin-postcss": "^4.0.2",
99
- "rollup-plugin-tsconfig-paths": "^1.5.2",
100
- "tailwindcss": "^4.1.10",
101
- "tsconfig-paths-webpack-plugin": "^4.2.0",
102
- "webpack": "^5.103.0",
103
- "webpack-cli": "^6.0.1",
104
- "webpack-dev-server": "^5.2.2",
105
- "ws": "^8.18.3"
61
+ "@babel/core": "7.29.7",
62
+ "@babel/parser": "7.29.11",
63
+ "@babel/plugin-syntax-import-meta": "7.10.4",
64
+ "@babel/preset-react": "7.29.7",
65
+ "@babel/preset-typescript": "7.29.7",
66
+ "@babel/traverse": "7.29.10",
67
+ "@esbuild-plugins/tsconfig-paths": "0.1.2",
68
+ "@roggc/react-server-dom-esm": "19.3.1",
69
+ "@rollup/plugin-babel": "6.1.0",
70
+ "@rollup/plugin-commonjs": "28.0.9",
71
+ "@rollup/plugin-json": "6.1.0",
72
+ "@rollup/plugin-node-resolve": "16.0.3",
73
+ "@rollup/plugin-replace": "6.0.3",
74
+ "@swc/core": "1.16.20",
75
+ "@tailwindcss/postcss": "4.3.3",
76
+ "autoprefixer": "10.6.1",
77
+ "babel-loader": "10.1.1",
78
+ "babel-plugin-react-compiler": "1.0.0",
79
+ "chokidar": "4.0.3",
80
+ "commander": "14.0.3",
81
+ "copy-webpack-plugin": "14.0.0",
82
+ "cross-env": "7.0.3",
83
+ "css-loader": "7.1.5",
84
+ "dotenv": "16.6.1",
85
+ "esbuild": "0.27.7",
86
+ "esbuild-copy-static-files": "0.1.0",
87
+ "generic-names": "4.0.0",
88
+ "mini-css-extract-plugin": "2.10.2",
89
+ "postcss": "8.5.31",
90
+ "postcss-import": "16.2.0",
91
+ "postcss-loader": "8.2.1",
92
+ "postcss-modules": "6.0.1",
93
+ "react-refresh": "0.17.0",
94
+ "react-server-dom-webpack": "19.3.1",
95
+ "rollup": "4.65.0",
96
+ "rollup-plugin-copy": "3.5.0",
97
+ "rollup-plugin-delete": "3.0.2",
98
+ "rollup-plugin-postcss": "4.0.2",
99
+ "rollup-plugin-tsconfig-paths": "1.5.2",
100
+ "tailwindcss": "4.3.3",
101
+ "tsconfig-paths-webpack-plugin": "4.2.0",
102
+ "webpack": "5.112.2",
103
+ "webpack-cli": "6.0.1",
104
+ "webpack-dev-server": "5.2.7",
105
+ "ws": "8.22.0"
106
106
  },
107
107
  "peerDependencies": {
108
- "react": ">=19.3.0",
109
- "react-dom": ">=19.3.0"
108
+ "react": ">=19.3.1",
109
+ "react-dom": ">=19.3.1"
110
110
  }
111
111
  }