dinou 9.3.0 → 10.0.1
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 +196 -0
- package/README.md +157 -132
- package/dinou/adapters/bun.js +34 -5
- package/dinou/adapters/cloudflare.js +110 -17
- package/dinou/adapters/deno.js +46 -8
- package/dinou/adapters/netlify.js +86 -50
- package/dinou/adapters/node.js +8 -0
- package/dinou/assets.d.ts +32 -5
- package/dinou/bun/build.js +190 -106
- package/dinou/cli.js +992 -532
- package/dinou/cloudflare/build.js +187 -106
- package/dinou/compiled/autoprefixer/index.js +509 -517
- package/dinou/compiled/babel-core/index.js +738 -716
- package/dinou/compiled/babel-generator/index.js +341 -299
- package/dinou/compiled/babel-loader/index.js +766 -744
- package/dinou/compiled/babel-parser/index.js +2 -2
- package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
- package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
- package/dinou/compiled/babel-preset-react/index.js +752 -730
- package/dinou/compiled/babel-preset-typescript/index.js +738 -716
- package/dinou/compiled/babel-traverse/index.js +463 -433
- package/dinou/compiled/babel-types/index.js +176 -176
- package/dinou/compiled/chokidar/index.js +4 -4
- package/dinou/compiled/commander/index.js +15 -15
- package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
- package/dinou/compiled/css-loader/index.js +289 -289
- package/dinou/compiled/css-loader/runtime/api.js +85 -0
- package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
- package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
- package/dinou/compiled/css-loader/runtime/package.json +3 -0
- package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
- package/dinou/compiled/fast-glob/index.js +5810 -0
- package/dinou/compiled/generic-names/index.js +16 -16
- package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
- package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
- package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
- package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
- package/dinou/compiled/postcss/index.js +83 -83
- package/dinou/compiled/postcss-import/index.js +147 -117
- package/dinou/compiled/postcss-modules/index.js +216 -216
- package/dinou/compiled/resolve/index.js +1224 -0
- package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
- package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
- package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
- package/dinou/compiled/rollup-plugin-json/index.js +22 -18
- package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
- package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
- package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
- package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
- package/dinou/compiled/vendors-manifest.json +59 -83
- package/dinou/core/asset-extensions.js +482 -33
- package/dinou/core/bailout-proxy.js +21 -2
- package/dinou/core/build-static-pages.js +523 -371
- package/dinou/core/builtin-asset-extensions.js +63 -0
- package/dinou/core/cache-revalidate.js +449 -256
- package/dinou/core/cache-slot.js +289 -79
- package/dinou/core/client-webpack.jsx +470 -39
- package/dinou/core/client.jsx +402 -39
- package/dinou/core/config.js +3 -0
- package/dinou/core/copy-static-dirs.js +98 -0
- package/dinou/core/createScopedName.js +22 -4
- package/dinou/core/dinou-paths.js +1 -1
- package/dinou/core/discover-layouts.js +200 -0
- package/dinou/core/edge-ssr.js +1 -1
- package/dinou/core/ensure-vendor-mode.js +78 -19
- package/dinou/core/env.js +544 -0
- package/dinou/core/export-static.js +41 -9
- package/dinou/core/generate-route-types.js +989 -95
- package/dinou/core/generate-static-rsc.js +5 -6
- package/dinou/core/generate-static.js +45 -6
- package/dinou/core/get-abs-path-with-ext.js +217 -75
- package/dinou/core/get-asset-from-manifest.js +19 -8
- package/dinou/core/get-error-jsx.js +4 -5
- package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
- package/dinou/core/get-jsx.js +220 -53
- package/dinou/core/handler.js +1647 -466
- package/dinou/core/import-module.js +7 -0
- package/dinou/core/layout-functions.js +72 -13
- package/dinou/core/link.jsx +34 -6
- package/dinou/core/load-dinou-config.js +520 -89
- package/dinou/core/manifest-provider.js +4 -14
- package/dinou/core/navigation-utils.js +141 -3
- package/dinou/core/navigation.js +134 -50
- package/dinou/core/node-middleware-runner.js +165 -0
- package/dinou/core/postcss-pipeline.js +236 -0
- package/dinou/core/ppr-context.js +114 -22
- package/dinou/core/ppr-runtime.js +391 -127
- package/dinou/core/redirect.jsx +1 -1
- package/dinou/core/render-jsx-to-client-jsx.js +216 -48
- package/dinou/core/request-context.js +59 -3
- package/dinou/core/resolve-contextual-dinou.js +523 -0
- package/dinou/core/resolve-setup-files.js +85 -27
- package/dinou/core/revalidating.js +10 -2
- package/dinou/core/route-generator.js +6 -2
- package/dinou/core/rsc-renderer.js +4 -1
- package/dinou/core/run-ssg.js +6 -0
- package/dinou/core/runtime-env.js +265 -0
- package/dinou/core/server-css-modules-plugin.js +155 -0
- package/dinou/core/server-function-proxy-webpack.js +27 -2
- package/dinou/core/server-function-proxy.js +27 -2
- package/dinou/core/slot.js +47 -2
- package/dinou/core/static-assets.js +503 -0
- package/dinou/core/storage-adapter.js +452 -24
- package/dinou/core/transform-server-functions.js +272 -24
- package/dinou/core/tsconfig-aliases.js +964 -0
- package/dinou/core/uneject.js +640 -0
- package/dinou/core/url-resolver.js +1 -1
- package/dinou/core/vfs.js +11 -2
- package/dinou/css.d.ts +4 -1
- package/dinou/deno/build.js +205 -153
- package/dinou/deno/seed-kv.js +4 -0
- package/dinou/env.d.ts +22 -2
- package/dinou/esbuild/build.js +40 -50
- package/dinou/esbuild/dev.js +33 -7
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
- package/dinou/esbuild/helpers-esbuild/write.js +13 -3
- package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
- package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
- package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
- package/dinou/index.d.ts +1028 -88
- package/dinou/node/build.js +138 -74
- package/dinou/node/bundle-dual-engine.js +393 -131
- package/dinou/node/dev.js +1005 -275
- package/dinou/package.json +11 -34
- package/dinou/rollup/postcss.config.js +3 -4
- package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
- package/dinou/rollup/rollup.config.js +174 -101
- package/dinou/scripts/build-vendors.js +123 -33
- package/dinou/server.d.ts +126 -15
- package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
- package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
- package/dinou/webpack/loaders/server-functions-loader.js +1 -1
- package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
- package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
- package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
- package/dinou/webpack/postcss.config.js +3 -4
- package/dinou/webpack/webpack.config.js +408 -132
- package/eject.js +6 -224
- package/package.json +7 -9
- package/dinou/compiled/cross-env/index.js +0 -661
- package/dinou/compiled/dotenv/index.js +0 -375
- package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
- package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
- package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
- package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
- package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
package/dinou/esbuild/build.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
delete process.env.DINOU_DEV;
|
|
2
|
+
process.env.NODE_ENV = "production";
|
|
3
|
+
|
|
1
4
|
import esbuild from "esbuild";
|
|
2
5
|
import fs from "node:fs/promises";
|
|
3
6
|
import getConfigEsbuildProd from "./helpers-esbuild/get-config-esbuild-prod.js";
|
|
@@ -5,7 +8,13 @@ import getEsbuildEntries from "./helpers-esbuild/get-esbuild-entries.js";
|
|
|
5
8
|
import { fileURLToPath } from "url";
|
|
6
9
|
import path from "node:path";
|
|
7
10
|
import { updateManifestForModule } from "./helpers-esbuild/update-manifest-for-module.js";
|
|
8
|
-
import
|
|
11
|
+
import { generateRouteTypes } from "../core/generate-route-types.js";
|
|
12
|
+
import { getDinouConfig } from "../core/load-dinou-config.js";
|
|
13
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
14
|
+
import ensureVendorMode, {
|
|
15
|
+
isUnvendorizedRequested,
|
|
16
|
+
} from "../core/ensure-vendor-mode.js";
|
|
17
|
+
loadEnvFiles(process.cwd(), { mode: "production" });
|
|
9
18
|
if (!ensureVendorMode()) {
|
|
10
19
|
await new Promise(() => {});
|
|
11
20
|
}
|
|
@@ -15,8 +24,8 @@ const __dirname = path.dirname(__filename);
|
|
|
15
24
|
|
|
16
25
|
const outdir = ".dinou/dist3";
|
|
17
26
|
await fs.rm(outdir, { recursive: true, force: true });
|
|
18
|
-
await fs.rm(".dinou/
|
|
19
|
-
await fs.rm(".dinou/
|
|
27
|
+
await fs.rm(".dinou/dist1", { recursive: true, force: true });
|
|
28
|
+
await fs.rm(".dinou/netlify", { recursive: true, force: true });
|
|
20
29
|
|
|
21
30
|
const absPathToClientRedirect = path.resolve(
|
|
22
31
|
__dirname,
|
|
@@ -37,17 +46,17 @@ const frameworkEntryPoints = {
|
|
|
37
46
|
__dirname,
|
|
38
47
|
"../core/server-function-proxy.js"
|
|
39
48
|
),
|
|
40
|
-
runtime: path.resolve(__dirname, "react-refresh/react-refresh-runtime.js"),
|
|
41
|
-
"react-refresh-entry": path.resolve(
|
|
42
|
-
__dirname,
|
|
43
|
-
"react-refresh/react-refresh-entry.js"
|
|
44
|
-
),
|
|
45
49
|
dinouClientRedirect: absPathToClientRedirect,
|
|
46
50
|
dinouLink: absPathToLink,
|
|
47
51
|
dinouSlot: absPathToSlot,
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
try {
|
|
55
|
+
const dinouConfig = await getDinouConfig();
|
|
56
|
+
const enableReactCompiler = dinouConfig?.reactCompiler !== false;
|
|
57
|
+
try {
|
|
58
|
+
generateRouteTypes(process.cwd());
|
|
59
|
+
} catch (e) {}
|
|
51
60
|
const manifest = {};
|
|
52
61
|
|
|
53
62
|
const [
|
|
@@ -55,7 +64,7 @@ try {
|
|
|
55
64
|
detectedCSSEntries,
|
|
56
65
|
detectedAssetEntries,
|
|
57
66
|
serverFiles,
|
|
58
|
-
] = await getEsbuildEntries({ manifest });
|
|
67
|
+
] = await getEsbuildEntries({ manifest, dinouConfig });
|
|
59
68
|
|
|
60
69
|
updateManifestForModule(
|
|
61
70
|
absPathToClientRedirect,
|
|
@@ -86,16 +95,12 @@ try {
|
|
|
86
95
|
{}
|
|
87
96
|
);
|
|
88
97
|
|
|
89
|
-
const
|
|
90
|
-
(acc, dAE) => ({ ...acc, [dAE.outfileName]: dAE.absPath }),
|
|
91
|
-
{}
|
|
92
|
-
);
|
|
98
|
+
const serverAssetPaths = [...detectedAssetEntries].map((dAE) => dAE.absPath);
|
|
93
99
|
|
|
94
100
|
const entryPoints = {
|
|
95
101
|
...frameworkEntryPoints,
|
|
96
102
|
...componentEntryPoints,
|
|
97
103
|
...cssEntryPoints,
|
|
98
|
-
...assetEntryPoints,
|
|
99
104
|
};
|
|
100
105
|
|
|
101
106
|
await esbuild.build(
|
|
@@ -104,47 +109,32 @@ try {
|
|
|
104
109
|
manifest,
|
|
105
110
|
outdir,
|
|
106
111
|
serverFiles,
|
|
112
|
+
serverAssetPaths,
|
|
113
|
+
dinouConfig,
|
|
114
|
+
reactCompiler: enableReactCompiler,
|
|
107
115
|
})
|
|
108
116
|
);
|
|
109
117
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
platform: "node",
|
|
119
|
-
target: "node20",
|
|
120
|
-
format: "esm",
|
|
121
|
-
conditions: ["react-server", "node", "import"],
|
|
122
|
-
outdir: ".dinou/dist3/server",
|
|
123
|
-
external: [
|
|
124
|
-
"express",
|
|
125
|
-
"chokidar",
|
|
126
|
-
"dotenv",
|
|
127
|
-
"fsevents",
|
|
128
|
-
"@swc/core",
|
|
129
|
-
"@babel/core",
|
|
130
|
-
"esbuild",
|
|
131
|
-
],
|
|
132
|
-
banner: {
|
|
133
|
-
js: "import { createRequire as ___createRequire } from 'node:module'; import { fileURLToPath as ___fileURLToPath } from 'node:url'; import ___path from 'node:path'; const require = ___createRequire(import.meta.url || ___path.resolve(process.cwd(), 'package.json')); const __filename = import.meta.url ? ___fileURLToPath(import.meta.url) : ___path.resolve(process.cwd(), 'index.js'); const __dirname = ___path.dirname(__filename); process.env.NODE_ENV = process.env.NODE_ENV || 'production';",
|
|
134
|
-
},
|
|
135
|
-
sourcemap: true,
|
|
136
|
-
});
|
|
137
|
-
await fs.writeFile(
|
|
138
|
-
path.resolve(process.cwd(), ".dinou/dist3/server/package.json"),
|
|
139
|
-
JSON.stringify({ type: "module" }, null, 2)
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
// 🏗️ Pre-render static pages (SSG) at build time
|
|
143
|
-
const { execSync } = await import("node:child_process");
|
|
144
|
-
execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
|
|
118
|
+
// 🏗️ Pre-render static pages (SSG) & compile Dual-Bundle Server/Netlify adapters
|
|
119
|
+
const { spawnSync } = await import("node:child_process");
|
|
120
|
+
const ssgArgs = [
|
|
121
|
+
"--conditions=react-server",
|
|
122
|
+
...(isUnvendorizedRequested() ? ["--conditions=unvendorized"] : []),
|
|
123
|
+
path.resolve(__dirname, "../core/run-ssg.js"),
|
|
124
|
+
];
|
|
125
|
+
const ssgRes = spawnSync(process.execPath, ssgArgs, {
|
|
145
126
|
stdio: "inherit",
|
|
146
|
-
env: {
|
|
127
|
+
env: {
|
|
128
|
+
...process.env,
|
|
129
|
+
NODE_ENV: "production",
|
|
130
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
131
|
+
},
|
|
147
132
|
});
|
|
133
|
+
if (ssgRes.status !== 0) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
`[Dinou SSG] Static generation exited with code ${ssgRes.status ?? 1}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
148
138
|
} catch (err) {
|
|
149
139
|
console.error("Error in build:", err);
|
|
150
140
|
process.exit(1);
|
package/dinou/esbuild/dev.js
CHANGED
|
@@ -16,11 +16,15 @@ import {
|
|
|
16
16
|
transformToDisk,
|
|
17
17
|
getMirrorPath,
|
|
18
18
|
} from "./helpers-esbuild/swc-disk-cache.js";
|
|
19
|
+
import { generateRouteTypes } from "../core/generate-route-types.js";
|
|
20
|
+
import { getDinouConfig } from "../core/load-dinou-config.js";
|
|
21
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
19
22
|
|
|
20
23
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
24
|
const __dirname = path.dirname(__filename);
|
|
22
25
|
|
|
23
26
|
export async function startEsbuildDev(options = {}) {
|
|
27
|
+
loadEnvFiles(process.cwd(), { mode: "development" });
|
|
24
28
|
const onRebuilt = options.onRebuilt || (() => {});
|
|
25
29
|
const onBuildStart = options.onBuildStart || (() => {});
|
|
26
30
|
const onBuildEnd = options.onBuildEnd || (() => {});
|
|
@@ -33,8 +37,13 @@ export async function startEsbuildDev(options = {}) {
|
|
|
33
37
|
delete globalThis.__DINOU_RAW_SERVER_FUNCTIONS_MANIFEST__;
|
|
34
38
|
}
|
|
35
39
|
await fs.rm(outdir, { recursive: true, force: true });
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
for (const stale of [
|
|
41
|
+
"react-client-manifest.json",
|
|
42
|
+
"server-functions-manifest.json",
|
|
43
|
+
"manifest.json",
|
|
44
|
+
]) {
|
|
45
|
+
await fs.rm(path.join(".dinou/node-dev", stale), { force: true });
|
|
46
|
+
}
|
|
38
47
|
|
|
39
48
|
let currentCtx = null; // Track the active esbuild context
|
|
40
49
|
let activeBuildResolve = null;
|
|
@@ -71,23 +80,30 @@ export async function startEsbuildDev(options = {}) {
|
|
|
71
80
|
|
|
72
81
|
const changedIds = new Set();
|
|
73
82
|
const hmrEngine = { value: null };
|
|
83
|
+
const cssRefreshRef = { refresh: null };
|
|
74
84
|
|
|
75
85
|
let manifest = {};
|
|
76
86
|
let entryPoints = {};
|
|
77
87
|
let cssEntryPoints = {};
|
|
88
|
+
let serverAssetPaths = [];
|
|
89
|
+
let activeDinouConfig = null;
|
|
78
90
|
let allComponentEntries = {};
|
|
79
91
|
let activeComponentEntries = new Map();
|
|
80
92
|
let pathToOutfile = new Map();
|
|
81
93
|
let outfileNameToPath = new Map();
|
|
82
94
|
|
|
83
95
|
async function updateEntriesAndComponents() {
|
|
96
|
+
activeDinouConfig = await getDinouConfig();
|
|
97
|
+
try {
|
|
98
|
+
generateRouteTypes(process.cwd());
|
|
99
|
+
} catch (e) {}
|
|
84
100
|
manifest = {};
|
|
85
101
|
const [
|
|
86
102
|
esbuildEntries,
|
|
87
103
|
detectedCSSEntries,
|
|
88
104
|
detectedAssetEntries,
|
|
89
105
|
serverFiles,
|
|
90
|
-
] = await getEsbuildEntries({ manifest });
|
|
106
|
+
] = await getEsbuildEntries({ manifest, dinouConfig: activeDinouConfig });
|
|
91
107
|
|
|
92
108
|
updateManifestForModule(
|
|
93
109
|
absPathToClientRedirect,
|
|
@@ -126,10 +142,7 @@ export async function startEsbuildDev(options = {}) {
|
|
|
126
142
|
{}
|
|
127
143
|
);
|
|
128
144
|
|
|
129
|
-
|
|
130
|
-
(acc, dAE) => ({ ...acc, [dAE.outfileName]: dAE.absPath }),
|
|
131
|
-
{}
|
|
132
|
-
);
|
|
145
|
+
serverAssetPaths = [...detectedAssetEntries].map((dAE) => dAE.absPath);
|
|
133
146
|
|
|
134
147
|
allComponentEntries = componentEntryPoints;
|
|
135
148
|
for (const [outName, absP] of Object.entries(componentEntryPoints)) {
|
|
@@ -169,7 +182,10 @@ export async function startEsbuildDev(options = {}) {
|
|
|
169
182
|
manifest,
|
|
170
183
|
changedIds,
|
|
171
184
|
hmrEngine,
|
|
185
|
+
cssRefreshRef,
|
|
172
186
|
serverFiles: currentServerFiles,
|
|
187
|
+
serverAssetPaths,
|
|
188
|
+
dinouConfig: activeDinouConfig,
|
|
173
189
|
hmrPort: options.hmrPort,
|
|
174
190
|
onManifestUpdated: async () => {
|
|
175
191
|
await onRebuilt();
|
|
@@ -289,6 +305,16 @@ export async function startEsbuildDev(options = {}) {
|
|
|
289
305
|
}
|
|
290
306
|
return Promise.resolve();
|
|
291
307
|
},
|
|
308
|
+
refreshStyles: async () => {
|
|
309
|
+
if (typeof cssRefreshRef.refresh === "function") {
|
|
310
|
+
try {
|
|
311
|
+
return await cssRefreshRef.refresh();
|
|
312
|
+
} catch (err) {
|
|
313
|
+
console.error("❌ [Esbuild Dev] CSS refresh error:", err);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return false;
|
|
317
|
+
},
|
|
292
318
|
restart: async () => {
|
|
293
319
|
console.log("⚡ [Esbuild Dev] Recreating client bundle due to directive change...");
|
|
294
320
|
await updateEntriesAndComponents();
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { TsconfigPathsPlugin } from "#esbuild-plugins/tsconfig-paths";
|
|
2
1
|
import reactClientManifestPlugin from "../plugins-esbuild/react-client-manifest-plugin.js";
|
|
3
2
|
import serverFunctionsPlugin from "../plugins-esbuild/server-functions-plugin.js";
|
|
4
3
|
import cssProcessorPlugin from "../plugins-esbuild/css-processor-plugin.js";
|
|
5
4
|
import assetsPlugin from "../plugins-esbuild/assets-plugin.js";
|
|
6
|
-
import copyStaticFiles from "#esbuild-copy-static-files";
|
|
7
5
|
import manifestGeneratorPlugin from "../plugins-esbuild/manifest-generator-plugin.js";
|
|
8
6
|
import writePlugin from "../plugins-esbuild/write-plugin.js";
|
|
9
7
|
import babelReactCompilerPlugin from "../plugins-esbuild/babel-react-compiler-plugin.js";
|
|
8
|
+
import { esbuildContextualDinouPlugin } from "../../core/resolve-contextual-dinou.js";
|
|
9
|
+
import { copyStaticDirectoriesToOutdir } from "../../core/copy-static-dirs.js";
|
|
10
|
+
import { getEsbuildPublicEnvDefines } from "../../core/env.js";
|
|
11
|
+
import { getAssetExtensionsInfo } from "../../core/asset-extensions.js";
|
|
12
|
+
import {
|
|
13
|
+
esbuildTsconfigAliasesPlugin,
|
|
14
|
+
getSanitizedEsbuildTsconfigRaw,
|
|
15
|
+
} from "../../core/tsconfig-aliases.js";
|
|
10
16
|
import { existsSync } from "node:fs";
|
|
11
17
|
|
|
12
18
|
export default function getConfigEsbuildProd({
|
|
@@ -14,30 +20,50 @@ export default function getConfigEsbuildProd({
|
|
|
14
20
|
outdir = ".dinou/dist3",
|
|
15
21
|
manifest = {},
|
|
16
22
|
serverFiles,
|
|
23
|
+
serverAssetPaths = [],
|
|
24
|
+
dinouConfig = null,
|
|
25
|
+
reactCompiler = true,
|
|
17
26
|
}) {
|
|
18
27
|
const manifestData = {};
|
|
28
|
+
const projectRoot = process.cwd();
|
|
29
|
+
const parsedTsconfig = getSanitizedEsbuildTsconfigRaw(projectRoot);
|
|
30
|
+
const { regex: activeAssetRegex } = getAssetExtensionsInfo(
|
|
31
|
+
dinouConfig,
|
|
32
|
+
projectRoot
|
|
33
|
+
);
|
|
19
34
|
let plugins = [
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
esbuildContextualDinouPlugin({ projectRoot }),
|
|
36
|
+
esbuildTsconfigAliasesPlugin({
|
|
37
|
+
projectRoot,
|
|
38
|
+
assetRegex: activeAssetRegex,
|
|
39
|
+
}),
|
|
22
40
|
cssProcessorPlugin({ outdir }),
|
|
23
41
|
reactClientManifestPlugin({
|
|
24
42
|
manifest,
|
|
25
|
-
manifestPath: `.dinou/
|
|
43
|
+
manifestPath: `.dinou/dist1/react-client-manifest.json`,
|
|
44
|
+
}),
|
|
45
|
+
assetsPlugin({
|
|
46
|
+
dinouConfig,
|
|
47
|
+
serverAssetPaths,
|
|
48
|
+
projectRoot,
|
|
26
49
|
}),
|
|
27
|
-
assetsPlugin(),
|
|
28
50
|
manifestGeneratorPlugin(manifestData),
|
|
29
51
|
serverFunctionsPlugin({ manifestData, serverFiles }),
|
|
52
|
+
reactCompiler && babelReactCompilerPlugin({ serverFiles }),
|
|
30
53
|
writePlugin(),
|
|
31
|
-
];
|
|
54
|
+
].filter(Boolean);
|
|
32
55
|
|
|
33
|
-
|
|
34
|
-
if (staticDir) {
|
|
56
|
+
if (existsSync("public")) {
|
|
35
57
|
plugins = [
|
|
36
|
-
copyStaticFiles({
|
|
37
|
-
src: staticDir,
|
|
38
|
-
dest: outdir,
|
|
39
|
-
}),
|
|
40
58
|
...plugins,
|
|
59
|
+
{
|
|
60
|
+
name: "copy-static-files",
|
|
61
|
+
setup(build) {
|
|
62
|
+
build.onEnd(() => {
|
|
63
|
+
copyStaticDirectoriesToOutdir(projectRoot, outdir);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
},
|
|
41
67
|
];
|
|
42
68
|
}
|
|
43
69
|
|
|
@@ -50,6 +76,7 @@ export default function getConfigEsbuildProd({
|
|
|
50
76
|
sourcemap: false,
|
|
51
77
|
chunkNames: "[name]-[hash]",
|
|
52
78
|
entryNames: "[name]-[hash]",
|
|
79
|
+
tsconfigRaw: parsedTsconfig,
|
|
53
80
|
jsx: "automatic",
|
|
54
81
|
target: "es2022",
|
|
55
82
|
write: false,
|
|
@@ -57,9 +84,7 @@ export default function getConfigEsbuildProd({
|
|
|
57
84
|
metafile: true,
|
|
58
85
|
logLevel: "warning",
|
|
59
86
|
minify: true,
|
|
60
|
-
define: {
|
|
61
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
62
|
-
},
|
|
87
|
+
define: getEsbuildPublicEnvDefines({ mode: "production" }),
|
|
63
88
|
external: [
|
|
64
89
|
"/__SERVER_FUNCTION_PROXY__",
|
|
65
90
|
"/serverFunctionProxy.js",
|
|
@@ -6,23 +6,42 @@ import stableChunkNamesAndMapsPlugin from "../plugins-esbuild/stable-chunk-names
|
|
|
6
6
|
import assetsPlugin from "../plugins-esbuild/assets-plugin.js";
|
|
7
7
|
import skipMissingEntryPointsPlugin from "../plugins-esbuild/skip-missing-entry-points-plugin.js";
|
|
8
8
|
import { swcRedirectPlugin } from "./swc-disk-cache.js";
|
|
9
|
+
import { esbuildContextualDinouPlugin } from "../../core/resolve-contextual-dinou.js";
|
|
10
|
+
import { copyStaticDirectoriesToOutdir } from "../../core/copy-static-dirs.js";
|
|
11
|
+
import { getEsbuildPublicEnvDefines } from "../../core/env.js";
|
|
12
|
+
import { getAssetExtensionsInfo } from "../../core/asset-extensions.js";
|
|
13
|
+
import {
|
|
14
|
+
esbuildTsconfigAliasesPlugin,
|
|
15
|
+
getSanitizedEsbuildTsconfigRaw,
|
|
16
|
+
} from "../../core/tsconfig-aliases.js";
|
|
9
17
|
import fs from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
18
|
|
|
12
19
|
export default function getConfigEsbuild({
|
|
13
20
|
entryPoints,
|
|
14
21
|
outdir = ".dinou/public",
|
|
15
22
|
manifest = {},
|
|
16
23
|
changedIds,
|
|
24
|
+
cssModuleClassChanges,
|
|
17
25
|
hmrEngine,
|
|
26
|
+
cssRefreshRef,
|
|
18
27
|
serverFiles,
|
|
28
|
+
serverAssetPaths = [],
|
|
29
|
+
dinouConfig = null,
|
|
19
30
|
onManifestUpdated,
|
|
20
31
|
onBuildStart,
|
|
21
32
|
onBuildEnd,
|
|
22
33
|
hmrPort,
|
|
23
34
|
}) {
|
|
35
|
+
const sharedCssModuleClassChanges = cssModuleClassChanges || new Set();
|
|
24
36
|
let esbuildRebuildStart = 0;
|
|
25
37
|
let plugins = [
|
|
38
|
+
esbuildContextualDinouPlugin({ projectRoot: process.cwd() }),
|
|
39
|
+
esbuildTsconfigAliasesPlugin({
|
|
40
|
+
projectRoot: process.cwd(),
|
|
41
|
+
getAssetRegex: () =>
|
|
42
|
+
getAssetExtensionsInfo(dinouConfig, process.cwd()).regex,
|
|
43
|
+
preferSwcMirror: true,
|
|
44
|
+
}),
|
|
26
45
|
swcRedirectPlugin({ projectRoot: process.cwd() }),
|
|
27
46
|
...(onBuildStart
|
|
28
47
|
? [
|
|
@@ -41,12 +60,33 @@ export default function getConfigEsbuild({
|
|
|
41
60
|
]
|
|
42
61
|
: []),
|
|
43
62
|
skipMissingEntryPointsPlugin(),
|
|
44
|
-
cssProcessorPlugin({
|
|
63
|
+
cssProcessorPlugin({
|
|
64
|
+
outdir,
|
|
65
|
+
hmrEngine,
|
|
66
|
+
changedIds,
|
|
67
|
+
cssRefreshRef,
|
|
68
|
+
cssModuleClassChanges: sharedCssModuleClassChanges,
|
|
69
|
+
}),
|
|
45
70
|
serverFunctionsPlugin({ serverFiles }),
|
|
46
|
-
reactClientManifestPlugin({
|
|
47
|
-
|
|
71
|
+
reactClientManifestPlugin({
|
|
72
|
+
manifest,
|
|
73
|
+
manifestPath: ".dinou/node-dev/react-client-manifest.json",
|
|
74
|
+
onManifestUpdated,
|
|
75
|
+
}),
|
|
76
|
+
assetsPlugin({
|
|
77
|
+
changedIds,
|
|
78
|
+
serverAssetPaths,
|
|
79
|
+
dinouConfig,
|
|
80
|
+
projectRoot: process.cwd(),
|
|
81
|
+
}),
|
|
48
82
|
stableChunkNamesAndMapsPlugin({ changedIds }),
|
|
49
|
-
esmHmrPlugin({
|
|
83
|
+
esmHmrPlugin({
|
|
84
|
+
entryNames: ["main", "error"],
|
|
85
|
+
changedIds,
|
|
86
|
+
cssModuleClassChanges: sharedCssModuleClassChanges,
|
|
87
|
+
hmrEngine,
|
|
88
|
+
hmrPort,
|
|
89
|
+
}),
|
|
50
90
|
...(onBuildEnd
|
|
51
91
|
? [
|
|
52
92
|
{
|
|
@@ -65,61 +105,24 @@ export default function getConfigEsbuild({
|
|
|
65
105
|
];
|
|
66
106
|
|
|
67
107
|
const shouldWriteToDisk = process.env.DINOU_WRITE_TO_DISK === "true";
|
|
68
|
-
|
|
69
|
-
if (staticDir && shouldWriteToDisk) {
|
|
108
|
+
if (fs.existsSync("public") && shouldWriteToDisk) {
|
|
70
109
|
let staticCopied = false;
|
|
71
110
|
plugins = [
|
|
111
|
+
...plugins,
|
|
72
112
|
{
|
|
73
113
|
name: "copy-static-files-once",
|
|
74
114
|
setup(build) {
|
|
75
115
|
build.onEnd(() => {
|
|
76
116
|
if (staticCopied) return;
|
|
77
117
|
staticCopied = true;
|
|
78
|
-
|
|
79
|
-
fs.cpSync(staticDir, outdir, { recursive: true, force: true });
|
|
80
|
-
} catch (e) {}
|
|
118
|
+
copyStaticDirectoriesToOutdir(process.cwd(), outdir);
|
|
81
119
|
});
|
|
82
120
|
},
|
|
83
121
|
},
|
|
84
|
-
...plugins,
|
|
85
122
|
];
|
|
86
123
|
}
|
|
87
124
|
|
|
88
|
-
|
|
89
|
-
if (fs.existsSync("tsconfig.json")) {
|
|
90
|
-
try {
|
|
91
|
-
const raw = fs.readFileSync("tsconfig.json", "utf8");
|
|
92
|
-
const clean = raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "").replace(/,(\s*[}\]])/g, "$1");
|
|
93
|
-
userTsconfig = JSON.parse(clean);
|
|
94
|
-
} catch (e) {}
|
|
95
|
-
}
|
|
96
|
-
const compilerOptions = userTsconfig.compilerOptions || {};
|
|
97
|
-
const userPaths = compilerOptions.paths || {};
|
|
98
|
-
|
|
99
|
-
const paths = {};
|
|
100
|
-
for (const [alias, targets] of Object.entries(userPaths)) {
|
|
101
|
-
const list = Array.isArray(targets) ? targets : [targets];
|
|
102
|
-
const swcTargets = list.map((t) => {
|
|
103
|
-
const norm = t.replace(/^\.\//, "");
|
|
104
|
-
return `.dinou/swc/${norm}`;
|
|
105
|
-
});
|
|
106
|
-
paths[alias] = [...swcTargets, ...list];
|
|
107
|
-
}
|
|
108
|
-
if (!paths["@/*"]) {
|
|
109
|
-
paths["@/*"] = [".dinou/swc/src/*", "src/*"];
|
|
110
|
-
}
|
|
111
|
-
if (!paths["~/*"]) {
|
|
112
|
-
paths["~/*"] = [".dinou/swc/src/*", "src/*"];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const tsconfigRaw = {
|
|
116
|
-
...userTsconfig,
|
|
117
|
-
compilerOptions: {
|
|
118
|
-
...compilerOptions,
|
|
119
|
-
baseUrl: compilerOptions.baseUrl || ".",
|
|
120
|
-
paths,
|
|
121
|
-
},
|
|
122
|
-
};
|
|
125
|
+
const tsconfigRaw = getSanitizedEsbuildTsconfigRaw(process.cwd());
|
|
123
126
|
|
|
124
127
|
const isDev = process.env.NODE_ENV !== "production";
|
|
125
128
|
|
|
@@ -138,13 +141,12 @@ export default function getConfigEsbuild({
|
|
|
138
141
|
conditions: ["style"],
|
|
139
142
|
metafile: true,
|
|
140
143
|
logLevel: "warning",
|
|
141
|
-
define: {
|
|
142
|
-
"process.env.NODE_ENV": JSON.stringify("development"),
|
|
143
|
-
},
|
|
144
|
+
define: getEsbuildPublicEnvDefines({ mode: "development" }),
|
|
144
145
|
external: [
|
|
145
146
|
"/__SERVER_FUNCTION_PROXY__",
|
|
146
147
|
"/serverFunctionProxy.js",
|
|
147
148
|
"/__hmr_client__.js",
|
|
149
|
+
"/runtime.js",
|
|
148
150
|
"/react-refresh-entry.js",
|
|
149
151
|
],
|
|
150
152
|
plugins,
|