dinou 4.0.3 → 4.0.5
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 +19 -0
- package/README.md +112 -2
- package/dinou/core/build-static-pages.js +257 -261
- package/dinou/core/client-error-webpack.jsx +7 -5
- package/dinou/core/client-error.jsx +7 -5
- package/dinou/core/client-webpack.jsx +8 -6
- package/dinou/core/client.jsx +8 -6
- package/dinou/core/server-function-proxy-webpack.js +23 -7
- package/dinou/core/server-function-proxy.js +22 -6
- package/dinou/core/server.js +51 -1
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +2 -0
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.mjs +64 -0
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +42 -48
- package/dinou/package.json +5 -2
- package/dinou/rollup/rollup.config.js +6 -1
- package/dinou/webpack/helpers/get-webpack-entries.js +37 -8
- package/dinou/webpack/loaders/server-functions-loader.js +5 -10
- package/dinou/webpack/webpack.config.js +45 -36
- package/package.json +5 -2
|
@@ -20,7 +20,7 @@ async function getCSSEntries({
|
|
|
20
20
|
assetInclude = assetRegex,
|
|
21
21
|
manifest = {},
|
|
22
22
|
} = {}) {
|
|
23
|
-
|
|
23
|
+
const detectedClientEntries = new Set();
|
|
24
24
|
const detectedCSSEntries = new Set();
|
|
25
25
|
// const detectedAssetEntries = new Set();
|
|
26
26
|
// const serverModules = new Set();
|
|
@@ -29,7 +29,7 @@ async function getCSSEntries({
|
|
|
29
29
|
code,
|
|
30
30
|
baseFilePath,
|
|
31
31
|
visited = new Set(),
|
|
32
|
-
isTopLevelClientComponent = false
|
|
32
|
+
isTopLevelClientComponent = false,
|
|
33
33
|
) {
|
|
34
34
|
if (visited.has(baseFilePath)) {
|
|
35
35
|
return { imports: [], assets: [], csss: [] };
|
|
@@ -71,7 +71,7 @@ async function getCSSEntries({
|
|
|
71
71
|
} catch (err) {
|
|
72
72
|
console.warn(
|
|
73
73
|
`[get-esbuild-entries] Could not read import: ${absImportPathWithExt}`,
|
|
74
|
-
err.message
|
|
74
|
+
err.message,
|
|
75
75
|
);
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
@@ -115,7 +115,7 @@ async function getCSSEntries({
|
|
|
115
115
|
importedCode,
|
|
116
116
|
absImportPathWithExt,
|
|
117
117
|
visited,
|
|
118
|
-
isTopLevelClientComponent
|
|
118
|
+
isTopLevelClientComponent,
|
|
119
119
|
);
|
|
120
120
|
nested.imports.forEach((p) => imports.add(p));
|
|
121
121
|
nested.assets.forEach((p) => assets.add(p));
|
|
@@ -123,7 +123,7 @@ async function getCSSEntries({
|
|
|
123
123
|
} catch (err) {
|
|
124
124
|
console.warn(
|
|
125
125
|
`[get-esbuild-entries] Could not process imports of: ${absImportPathWithExt}`,
|
|
126
|
-
err.message
|
|
126
|
+
err.message,
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -188,10 +188,32 @@ async function getCSSEntries({
|
|
|
188
188
|
const normalizedPath = normalizePath(absPath);
|
|
189
189
|
|
|
190
190
|
if (isClientModule) {
|
|
191
|
+
const name = path.basename(absPath, path.extname(absPath));
|
|
192
|
+
|
|
193
|
+
detectedClientEntries.add({
|
|
194
|
+
absPath: normalizedPath,
|
|
195
|
+
name,
|
|
196
|
+
});
|
|
197
|
+
const { imports } = await getImportsAndAssetsAndCsss(
|
|
198
|
+
code,
|
|
199
|
+
absPath,
|
|
200
|
+
new Set(),
|
|
201
|
+
true,
|
|
202
|
+
);
|
|
203
|
+
const clientComponentRegex = /\.(js|jsx|ts|tsx)$/i;
|
|
204
|
+
imports.forEach((imp) => {
|
|
205
|
+
if (clientComponentRegex.test(imp) && !imp.includes("node_modules")) {
|
|
206
|
+
const name = path.basename(imp, path.extname(imp));
|
|
207
|
+
detectedClientEntries.add({
|
|
208
|
+
absPath: normalizePath(imp),
|
|
209
|
+
name,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
191
213
|
} else if (isPageOrLayout(absPath)) {
|
|
192
214
|
if (!isAsyncDefaultExport(code)) {
|
|
193
215
|
console.warn(
|
|
194
|
-
`[react-client-manifest] The file ${normalizedPath} is a page or layout without "use client" directive, but its default export is not an async function
|
|
216
|
+
`[react-client-manifest] The file ${normalizedPath} is a page or layout without "use client" directive, but its default export is not an async function.`,
|
|
195
217
|
);
|
|
196
218
|
}
|
|
197
219
|
// serverModules.add({
|
|
@@ -206,7 +228,7 @@ async function getCSSEntries({
|
|
|
206
228
|
...csss.map((cssPath) => ({
|
|
207
229
|
absPath: normalizePath(cssPath),
|
|
208
230
|
name: path.basename(cssPath, path.extname(cssPath)),
|
|
209
|
-
}))
|
|
231
|
+
})),
|
|
210
232
|
);
|
|
211
233
|
}
|
|
212
234
|
|
|
@@ -225,6 +247,13 @@ async function getCSSEntries({
|
|
|
225
247
|
}
|
|
226
248
|
} // end for files
|
|
227
249
|
|
|
250
|
+
for (const dCE of detectedClientEntries) {
|
|
251
|
+
const hash = hashFilePath(dCE.absPath);
|
|
252
|
+
const outfileName = `${dCE.name}-${hash}`;
|
|
253
|
+
dCE.outfile = `${outfileName}.js`;
|
|
254
|
+
dCE.outfileName = outfileName;
|
|
255
|
+
}
|
|
256
|
+
|
|
228
257
|
for (const dCSSE of detectedCSSEntries) {
|
|
229
258
|
const hash = hashFilePath(dCSSE.absPath);
|
|
230
259
|
const outfileName = `${dCSSE.name}-${hash}`;
|
|
@@ -240,7 +269,7 @@ async function getCSSEntries({
|
|
|
240
269
|
// }
|
|
241
270
|
|
|
242
271
|
// console.log("detectedCssEntries", detectedCSSEntries);
|
|
243
|
-
return [detectedCSSEntries];
|
|
272
|
+
return [detectedCSSEntries, detectedClientEntries];
|
|
244
273
|
}
|
|
245
274
|
|
|
246
275
|
module.exports = getCSSEntries;
|
|
@@ -4,15 +4,10 @@ const parseExports = require("../../core/parse-exports.js");
|
|
|
4
4
|
const { useServerRegex } = require("../../constants.js");
|
|
5
5
|
|
|
6
6
|
module.exports = function (source) {
|
|
7
|
-
// Detect "use server"
|
|
8
|
-
const lines = source.split("\n");
|
|
9
7
|
let hasUseServer = false;
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
hasUseServer = true;
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
9
|
+
if (useServerRegex.test(source)) {
|
|
10
|
+
hasUseServer = true;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
if (!hasUseServer) return source;
|
|
@@ -45,7 +40,7 @@ const loadProxy = new Function('return import("/"+"__SERVER_FUNCTION_PROXY__")')
|
|
|
45
40
|
export default (...args) =>
|
|
46
41
|
loadProxy().then(mod =>
|
|
47
42
|
(mod.default ?? mod ?? window.__SERVER_FUNCTION_PROXY_LIB__).createServerFunctionProxy(${JSON.stringify(
|
|
48
|
-
key
|
|
43
|
+
key,
|
|
49
44
|
)})(...args)
|
|
50
45
|
);
|
|
51
46
|
`;
|
|
@@ -53,7 +48,7 @@ export default (...args) =>
|
|
|
53
48
|
proxyCode += `
|
|
54
49
|
export const ${exp} = (...args) =>
|
|
55
50
|
loadProxy().then(mod => (mod.default ?? mod ?? window.__SERVER_FUNCTION_PROXY_LIB__).createServerFunctionProxy(${JSON.stringify(
|
|
56
|
-
key
|
|
51
|
+
key,
|
|
57
52
|
)})(...args)
|
|
58
53
|
);
|
|
59
54
|
`;
|
|
@@ -68,7 +63,7 @@ export const ${exp} = (...args) =>
|
|
|
68
63
|
|
|
69
64
|
this.emitFile(
|
|
70
65
|
`server-functions/${normalizedPath}.json`,
|
|
71
|
-
JSON.stringify(manifestEntry, null, 2)
|
|
66
|
+
JSON.stringify(manifestEntry, null, 2),
|
|
72
67
|
);
|
|
73
68
|
|
|
74
69
|
return proxyCode;
|
|
@@ -37,7 +37,24 @@ console.log(
|
|
|
37
37
|
: "📦 [Dinou] Library Mode detected (Webpack: Using node_modules)",
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
+
const projectRoot = process.cwd();
|
|
41
|
+
|
|
42
|
+
const outputDirs = [
|
|
43
|
+
path.resolve(projectRoot, "public"),
|
|
44
|
+
path.resolve(projectRoot, "dist3"),
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
function cleanDir(dir) {
|
|
48
|
+
if (fs.existsSync(dir)) {
|
|
49
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
module.exports = async () => {
|
|
54
|
+
const outputDir = path.resolve(process.cwd(), outputDirectory);
|
|
55
|
+
|
|
56
|
+
// 🔥 CLEAN HARD
|
|
57
|
+
cleanDir(outputDir);
|
|
41
58
|
const [cssEntries] = await getCSSEntries();
|
|
42
59
|
return {
|
|
43
60
|
performance: {
|
|
@@ -90,45 +107,31 @@ module.exports = async () => {
|
|
|
90
107
|
// chunkFilename: "[name]-[contenthash].js",
|
|
91
108
|
},
|
|
92
109
|
module: {
|
|
93
|
-
noParse: [/dist3/, /public/],
|
|
110
|
+
// noParse: [/[\\/]dist3[\\/]/, /[\\/]public[\\/]/],
|
|
94
111
|
rules: [
|
|
95
|
-
// {
|
|
96
|
-
// test: /\.(js|jsx|ts|tsx)$/,
|
|
97
|
-
// include: path.resolve(process.cwd(), "dist3"),
|
|
98
|
-
// use: "null-loader",
|
|
99
|
-
// },
|
|
100
|
-
|
|
101
112
|
{
|
|
102
|
-
test: /\.
|
|
113
|
+
test: /\.[jt]sx?$/,
|
|
103
114
|
// include: [
|
|
104
115
|
// path.resolve(process.cwd(), "src"),
|
|
105
|
-
// path.resolve(__dirname, "../core"),
|
|
106
|
-
// path.resolve(process.cwd(), "node_modules/dinou"),
|
|
107
116
|
// isEjected && path.resolve(process.cwd(), "dinou"),
|
|
117
|
+
// path.resolve(__dirname, "../core"),
|
|
108
118
|
// ].filter(Boolean),
|
|
109
|
-
|
|
110
|
-
loader: "babel-loader",
|
|
111
|
-
options: {
|
|
112
|
-
presets: [
|
|
113
|
-
["@babel/preset-react", { runtime: "automatic" }],
|
|
114
|
-
"@babel/preset-typescript",
|
|
115
|
-
],
|
|
116
|
-
plugins: [
|
|
117
|
-
"@babel/plugin-syntax-import-meta",
|
|
118
|
-
// isDevelopment && require.resolve("react-refresh/babel"),
|
|
119
|
-
].filter(Boolean),
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
exclude: [
|
|
123
|
-
/node_modules\/(?!dinou)/,
|
|
124
|
-
path.resolve(process.cwd(), "dist3"),
|
|
125
|
-
path.resolve(process.cwd(), "public"),
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
test: /\.[jt]sx?$/,
|
|
130
|
-
include: path.resolve(process.cwd(), "src"),
|
|
119
|
+
exclude: [/node_modules\/(?!dinou)/, ...outputDirs],
|
|
131
120
|
use: [
|
|
121
|
+
{
|
|
122
|
+
loader: "babel-loader",
|
|
123
|
+
options: {
|
|
124
|
+
presets: [
|
|
125
|
+
["@babel/preset-react", { runtime: "automatic" }],
|
|
126
|
+
"@babel/preset-typescript",
|
|
127
|
+
],
|
|
128
|
+
plugins: [
|
|
129
|
+
"babel-plugin-react-compiler",
|
|
130
|
+
"@babel/plugin-syntax-import-meta",
|
|
131
|
+
// isDevelopment && require.resolve("react-refresh/babel"),
|
|
132
|
+
].filter(Boolean),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
132
135
|
{
|
|
133
136
|
loader: path.resolve(
|
|
134
137
|
__dirname,
|
|
@@ -214,8 +217,13 @@ module.exports = async () => {
|
|
|
214
217
|
filename: "[name].css",
|
|
215
218
|
}),
|
|
216
219
|
manifestGeneratorPlugin,
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
new webpack.IgnorePlugin({
|
|
221
|
+
checkResource(resource, context) {
|
|
222
|
+
if (!context) return false;
|
|
223
|
+
|
|
224
|
+
return outputDirs.some((dir) => context.startsWith(dir));
|
|
225
|
+
},
|
|
226
|
+
}),
|
|
219
227
|
new ServerFunctionsPlugin({
|
|
220
228
|
manifest: manifestGeneratorPlugin.manifestData,
|
|
221
229
|
}),
|
|
@@ -268,7 +276,8 @@ module.exports = async () => {
|
|
|
268
276
|
// Rest of node_modules
|
|
269
277
|
defaultVendors: {
|
|
270
278
|
test: /[\\/]node_modules[\\/]/,
|
|
271
|
-
name: "vendors",
|
|
279
|
+
// name: "vendors",
|
|
280
|
+
name: false,
|
|
272
281
|
priority: 20,
|
|
273
282
|
chunks: "all",
|
|
274
283
|
reuseExistingChunk: true,
|
|
@@ -277,7 +286,7 @@ module.exports = async () => {
|
|
|
277
286
|
},
|
|
278
287
|
},
|
|
279
288
|
watchOptions: {
|
|
280
|
-
ignored:
|
|
289
|
+
ignored: outputDirs.map((dir) => `${dir}/**`),
|
|
281
290
|
},
|
|
282
291
|
stats: "normal", // or 'verbose' in dev
|
|
283
292
|
infrastructureLogging: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dinou",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.5",
|
|
4
|
+
"description": "Full-Stack React 19 framework with React Server Components, Server Functions, and Streaming SSR.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"dinou": "./cli.js"
|
|
@@ -54,9 +54,11 @@
|
|
|
54
54
|
"@rollup/plugin-json": "^6.1.0",
|
|
55
55
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
56
56
|
"@rollup/plugin-replace": "^6.0.2",
|
|
57
|
+
"@swc/core": "^1.15.10",
|
|
57
58
|
"@tailwindcss/postcss": "^4.1.10",
|
|
58
59
|
"autoprefixer": "^10.4.21",
|
|
59
60
|
"babel-loader": "^10.0.0",
|
|
61
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
60
62
|
"chokidar": "^4.0.3",
|
|
61
63
|
"commander": "^14.0.0",
|
|
62
64
|
"concurrently": "^9.2.0",
|
|
@@ -72,6 +74,7 @@
|
|
|
72
74
|
"generic-names": "^4.0.0",
|
|
73
75
|
"loader-utils": "^3.3.1",
|
|
74
76
|
"mini-css-extract-plugin": "^2.9.4",
|
|
77
|
+
"multer": "^2.0.2",
|
|
75
78
|
"postcss": "^8.5.5",
|
|
76
79
|
"postcss-import": "^16.1.1",
|
|
77
80
|
"postcss-loader": "^8.2.0",
|