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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dinou-ejected",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -118,10 +118,6 @@
|
|
|
118
118
|
"unvendorized": "@rollup/plugin-replace",
|
|
119
119
|
"default": "./compiled/rollup-plugin-replace/index.js"
|
|
120
120
|
},
|
|
121
|
-
"#rollup-plugin-copy": {
|
|
122
|
-
"unvendorized": "rollup-plugin-copy",
|
|
123
|
-
"default": "./compiled/rollup-plugin-copy/index.js"
|
|
124
|
-
},
|
|
125
121
|
"#rollup-plugin-delete": {
|
|
126
122
|
"unvendorized": "rollup-plugin-delete",
|
|
127
123
|
"default": "./compiled/rollup-plugin-delete/index.js"
|
|
@@ -130,10 +126,6 @@
|
|
|
130
126
|
"unvendorized": "rollup-plugin-postcss",
|
|
131
127
|
"default": "./compiled/rollup-plugin-postcss/index.js"
|
|
132
128
|
},
|
|
133
|
-
"#rollup-plugin-tsconfig-paths": {
|
|
134
|
-
"unvendorized": "rollup-plugin-tsconfig-paths",
|
|
135
|
-
"default": "./compiled/rollup-plugin-tsconfig-paths/index.js"
|
|
136
|
-
},
|
|
137
129
|
"#babel-loader": {
|
|
138
130
|
"unvendorized": "babel-loader",
|
|
139
131
|
"default": "./compiled/babel-loader/index.js"
|
|
@@ -150,22 +142,10 @@
|
|
|
150
142
|
"unvendorized": "copy-webpack-plugin",
|
|
151
143
|
"default": "./compiled/copy-webpack-plugin/index.js"
|
|
152
144
|
},
|
|
153
|
-
"#tsconfig-paths-webpack-plugin": {
|
|
154
|
-
"unvendorized": "tsconfig-paths-webpack-plugin",
|
|
155
|
-
"default": "./compiled/tsconfig-paths-webpack-plugin/index.js"
|
|
156
|
-
},
|
|
157
145
|
"#commander": {
|
|
158
146
|
"unvendorized": "commander",
|
|
159
147
|
"default": "./compiled/commander/index.js"
|
|
160
148
|
},
|
|
161
|
-
"#dotenv": {
|
|
162
|
-
"unvendorized": "dotenv",
|
|
163
|
-
"default": "./compiled/dotenv/index.js"
|
|
164
|
-
},
|
|
165
|
-
"#cross-env": {
|
|
166
|
-
"unvendorized": "cross-env",
|
|
167
|
-
"default": "./compiled/cross-env/index.js"
|
|
168
|
-
},
|
|
169
149
|
"#ws": {
|
|
170
150
|
"unvendorized": "ws",
|
|
171
151
|
"default": "./compiled/ws/index.js"
|
|
@@ -174,23 +154,24 @@
|
|
|
174
154
|
"unvendorized": "chokidar",
|
|
175
155
|
"default": "./compiled/chokidar/index.js"
|
|
176
156
|
},
|
|
177
|
-
"#
|
|
178
|
-
"unvendorized": "
|
|
179
|
-
"default": "./compiled/
|
|
157
|
+
"#fast-glob": {
|
|
158
|
+
"unvendorized": "fast-glob",
|
|
159
|
+
"default": "./compiled/fast-glob/index.js"
|
|
180
160
|
},
|
|
181
|
-
"#
|
|
182
|
-
"unvendorized": "
|
|
183
|
-
"default": "./compiled/
|
|
161
|
+
"#resolve": {
|
|
162
|
+
"unvendorized": "resolve",
|
|
163
|
+
"default": "./compiled/resolve/index.js"
|
|
184
164
|
}
|
|
185
165
|
},
|
|
186
166
|
"dependencies": {
|
|
187
167
|
"@babel/core": "7.29.7",
|
|
168
|
+
"@babel/generator": "7.29.8",
|
|
188
169
|
"@babel/parser": "7.29.11",
|
|
189
170
|
"@babel/plugin-syntax-import-meta": "7.10.4",
|
|
190
171
|
"@babel/preset-react": "7.29.7",
|
|
191
172
|
"@babel/preset-typescript": "7.29.7",
|
|
192
173
|
"@babel/traverse": "7.29.10",
|
|
193
|
-
"@
|
|
174
|
+
"@babel/types": "7.29.11",
|
|
194
175
|
"@roggc/react-server-dom-esm": "19.3.1",
|
|
195
176
|
"@rollup/plugin-babel": "6.1.0",
|
|
196
177
|
"@rollup/plugin-commonjs": "28.0.9",
|
|
@@ -205,11 +186,9 @@
|
|
|
205
186
|
"chokidar": "4.0.3",
|
|
206
187
|
"commander": "14.0.3",
|
|
207
188
|
"copy-webpack-plugin": "14.0.0",
|
|
208
|
-
"cross-env": "7.0.3",
|
|
209
189
|
"css-loader": "7.1.5",
|
|
210
|
-
"dotenv": "16.6.1",
|
|
211
190
|
"esbuild": "0.27.7",
|
|
212
|
-
"
|
|
191
|
+
"fast-glob": "3.3.3",
|
|
213
192
|
"generic-names": "4.0.0",
|
|
214
193
|
"mini-css-extract-plugin": "2.10.2",
|
|
215
194
|
"postcss": "8.5.31",
|
|
@@ -218,13 +197,11 @@
|
|
|
218
197
|
"postcss-modules": "6.0.1",
|
|
219
198
|
"react-refresh": "0.17.0",
|
|
220
199
|
"react-server-dom-webpack": "19.3.1",
|
|
200
|
+
"resolve": "1.22.12",
|
|
221
201
|
"rollup": "4.65.0",
|
|
222
|
-
"rollup-plugin-copy": "3.5.0",
|
|
223
202
|
"rollup-plugin-delete": "3.0.2",
|
|
224
203
|
"rollup-plugin-postcss": "4.0.2",
|
|
225
|
-
"rollup-plugin-tsconfig-paths": "1.5.2",
|
|
226
204
|
"tailwindcss": "4.3.3",
|
|
227
|
-
"tsconfig-paths-webpack-plugin": "4.2.0",
|
|
228
205
|
"webpack": "5.112.2",
|
|
229
206
|
"webpack-cli": "6.0.1",
|
|
230
207
|
"webpack-dev-server": "5.2.7",
|
|
@@ -161,7 +161,13 @@ socket.addEventListener("message", ({ data: _data }) => {
|
|
|
161
161
|
|
|
162
162
|
if (data.type === "rsc-update") {
|
|
163
163
|
if (typeof window !== "undefined" && typeof window.__DINOU_ROUTER_REFRESH__ === "function") {
|
|
164
|
-
|
|
164
|
+
const refreshLayout = Boolean(
|
|
165
|
+
data.layout ||
|
|
166
|
+
(data.path &&
|
|
167
|
+
(/(?:^|[\\/])layout\.[jt]sx?$/i.test(data.path) ||
|
|
168
|
+
/\.module\.css$/i.test(data.path)))
|
|
169
|
+
);
|
|
170
|
+
window.__DINOU_ROUTER_REFRESH__({ layout: refreshLayout });
|
|
165
171
|
return;
|
|
166
172
|
}
|
|
167
173
|
reload();
|
|
@@ -173,16 +179,31 @@ socket.addEventListener("message", ({ data: _data }) => {
|
|
|
173
179
|
(data.type === "update" && data.url && (data.url.endsWith(".css") || data.url.includes("styles.css")))
|
|
174
180
|
) {
|
|
175
181
|
const targetUrl = data.url ? data.url.split("?")[0] : "";
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
const applyStyleUpdate = () => {
|
|
183
|
+
const links = document.querySelectorAll('link[rel="stylesheet"]');
|
|
184
|
+
for (const link of links) {
|
|
185
|
+
const rawHref = link.getAttribute("href");
|
|
186
|
+
if (!rawHref) continue;
|
|
187
|
+
const cleanHref = rawHref.split("?")[0];
|
|
188
|
+
if (!targetUrl || cleanHref.endsWith(targetUrl) || targetUrl.endsWith(cleanHref) || cleanHref.includes("styles.css")) {
|
|
189
|
+
const nextUrl = new URL(link.href, window.location.origin);
|
|
190
|
+
nextUrl.searchParams.set("t", String(Date.now()));
|
|
191
|
+
link.href = nextUrl.href;
|
|
192
|
+
}
|
|
185
193
|
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
if (typeof document !== "undefined" && document.body?.getAttribute("data-hydrated") === "true") {
|
|
197
|
+
applyStyleUpdate();
|
|
198
|
+
} else if (typeof window !== "undefined") {
|
|
199
|
+
let attempts = 0;
|
|
200
|
+
const waitHydration = setInterval(() => {
|
|
201
|
+
attempts++;
|
|
202
|
+
if (document.body?.getAttribute("data-hydrated") === "true" || attempts >= 60) {
|
|
203
|
+
clearInterval(waitHydration);
|
|
204
|
+
applyStyleUpdate();
|
|
205
|
+
}
|
|
206
|
+
}, 50);
|
|
186
207
|
}
|
|
187
208
|
return;
|
|
188
209
|
}
|
|
@@ -25,20 +25,23 @@ function reactRefreshWrapModules() {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// Only wrap user component chunks that contain actual app code (not third-party libraries)
|
|
28
|
+
// Only wrap user component chunks that contain actual JS/TS app code (not pure CSS chunks or third-party libraries)
|
|
29
29
|
const modulePaths = Object.keys(chunk.modules || {});
|
|
30
|
-
const hasUserCode = modulePaths.some(
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
!
|
|
35
|
-
!
|
|
36
|
-
!
|
|
37
|
-
!
|
|
38
|
-
!
|
|
39
|
-
!
|
|
40
|
-
!
|
|
41
|
-
|
|
30
|
+
const hasUserCode = modulePaths.some((p) => {
|
|
31
|
+
const cleanPath = p.replace(/\?.*$/, "");
|
|
32
|
+
return (
|
|
33
|
+
/\.(jsx?|tsx?)$/i.test(cleanPath) &&
|
|
34
|
+
!cleanPath.includes("node_modules") &&
|
|
35
|
+
!cleanPath.includes("dinou/core") &&
|
|
36
|
+
!cleanPath.includes("dinou\\core") &&
|
|
37
|
+
!cleanPath.includes("dinou/rollup") &&
|
|
38
|
+
!cleanPath.includes("dinou\\rollup") &&
|
|
39
|
+
!cleanPath.includes("dinou/esbuild") &&
|
|
40
|
+
!cleanPath.includes("dinou\\esbuild") &&
|
|
41
|
+
!cleanPath.includes("dinou/webpack") &&
|
|
42
|
+
!cleanPath.includes("dinou\\webpack")
|
|
43
|
+
);
|
|
44
|
+
});
|
|
42
45
|
|
|
43
46
|
if (!hasUserCode) {
|
|
44
47
|
return null;
|
|
@@ -10,6 +10,8 @@ const changedIds = new Set();
|
|
|
10
10
|
const pendingUpdateUrls = new Set();
|
|
11
11
|
let needsFullReload = false;
|
|
12
12
|
let hasPendingCssUpdate = false;
|
|
13
|
+
let lastStylesCssContent = null;
|
|
14
|
+
const lastChunkCodeByFile = new Map();
|
|
13
15
|
|
|
14
16
|
function normalizePath(p) {
|
|
15
17
|
return path.resolve(p).replace(/\\/g, "/").toLowerCase();
|
|
@@ -20,6 +22,8 @@ let activeHmrEngine = null;
|
|
|
20
22
|
|
|
21
23
|
function esmHmrPlugin() {
|
|
22
24
|
let hmrEngine = activeHmrEngine;
|
|
25
|
+
lastChunkCodeByFile.clear();
|
|
26
|
+
lastStylesCssContent = null;
|
|
23
27
|
|
|
24
28
|
return {
|
|
25
29
|
name: "esm-hmr",
|
|
@@ -68,7 +72,7 @@ function esmHmrPlugin() {
|
|
|
68
72
|
// Inject client HMR runtime if it's the entry
|
|
69
73
|
if (isClientEntry && !code.includes("/__hmr_client__.js")) {
|
|
70
74
|
return {
|
|
71
|
-
code: `import { createHotContext } from "/__hmr_client__.js";window.__hotContext = createHotContext;\n` + code,
|
|
75
|
+
code: `import "/runtime.js";import { createHotContext } from "/__hmr_client__.js";window.__hotContext = createHotContext;\n` + code,
|
|
72
76
|
map: null,
|
|
73
77
|
};
|
|
74
78
|
}
|
|
@@ -97,17 +101,55 @@ function esmHmrPlugin() {
|
|
|
97
101
|
source: clientSource,
|
|
98
102
|
});
|
|
99
103
|
|
|
104
|
+
const stylesAsset = bundle["styles.css"];
|
|
105
|
+
if (stylesAsset && stylesAsset.type === "asset") {
|
|
106
|
+
const nextCss = Buffer.isBuffer(stylesAsset.source)
|
|
107
|
+
? stylesAsset.source.toString("utf8")
|
|
108
|
+
: String(stylesAsset.source || "");
|
|
109
|
+
if (lastStylesCssContent !== null && nextCss !== lastStylesCssContent) {
|
|
110
|
+
hasPendingCssUpdate = true;
|
|
111
|
+
}
|
|
112
|
+
lastStylesCssContent = nextCss;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const isInitialBundle = lastChunkCodeByFile.size === 0;
|
|
116
|
+
if (isInitialBundle) {
|
|
117
|
+
for (const [fileName, chunkInfo] of Object.entries(bundle)) {
|
|
118
|
+
if (!fileName.endsWith(".css") && chunkInfo.type === "chunk") {
|
|
119
|
+
lastChunkCodeByFile.set(fileName, chunkInfo.code);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
100
124
|
if (changedIds.size > 0) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
if (
|
|
126
|
+
Array.from(changedIds).some((id) => {
|
|
127
|
+
const lower = id.toLowerCase();
|
|
128
|
+
return (
|
|
129
|
+
lower.endsWith(".css") ||
|
|
130
|
+
lower.endsWith(".scss") ||
|
|
131
|
+
lower.endsWith(".less")
|
|
132
|
+
);
|
|
133
|
+
})
|
|
134
|
+
) {
|
|
135
|
+
hasPendingCssUpdate = true;
|
|
136
|
+
}
|
|
105
137
|
|
|
106
138
|
for (const [fileName, chunkInfo] of Object.entries(bundle)) {
|
|
107
139
|
if (fileName.endsWith(".css") || chunkInfo.type !== "chunk") {
|
|
108
140
|
continue;
|
|
109
141
|
}
|
|
110
142
|
|
|
143
|
+
const prevChunkCode = lastChunkCodeByFile.get(fileName);
|
|
144
|
+
lastChunkCodeByFile.set(fileName, chunkInfo.code);
|
|
145
|
+
if (
|
|
146
|
+
!isInitialBundle &&
|
|
147
|
+
prevChunkCode !== undefined &&
|
|
148
|
+
prevChunkCode === chunkInfo.code
|
|
149
|
+
) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
111
153
|
let isChangedByJs = false;
|
|
112
154
|
|
|
113
155
|
// 1. Check facadeModuleId
|
|
@@ -150,8 +192,12 @@ function esmHmrPlugin() {
|
|
|
150
192
|
}
|
|
151
193
|
|
|
152
194
|
if (isChangedByJs) {
|
|
153
|
-
|
|
154
|
-
|
|
195
|
+
if (chunkInfo.code && chunkInfo.code.includes("import.meta.hot")) {
|
|
196
|
+
const urlId = "/" + fileName;
|
|
197
|
+
pendingUpdateUrls.add(urlId);
|
|
198
|
+
} else {
|
|
199
|
+
needsFullReload = true;
|
|
200
|
+
}
|
|
155
201
|
}
|
|
156
202
|
}
|
|
157
203
|
}
|
|
@@ -1,33 +1,71 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import path from "node:path";
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
getAssetExtensionsInfo,
|
|
4
|
+
getAssetInfo,
|
|
5
|
+
resolveAssetImport,
|
|
6
|
+
} from "../../core/asset-extensions.js";
|
|
7
|
+
|
|
8
|
+
function dinouAssetPlugin({
|
|
9
|
+
include = null,
|
|
10
|
+
dinouConfig = null,
|
|
11
|
+
projectRoot = process.cwd(),
|
|
12
|
+
emitFiles = true,
|
|
13
|
+
} = {}) {
|
|
14
|
+
const rootDir = path.resolve(projectRoot || process.cwd());
|
|
15
|
+
let cleanRegex =
|
|
16
|
+
include || getAssetExtensionsInfo(dinouConfig, rootDir).regex;
|
|
17
|
+
let emittedInCurrentBuild = new Set();
|
|
5
18
|
|
|
6
|
-
function dinouAssetPlugin({ include = regex } = {}) {
|
|
7
19
|
return {
|
|
8
20
|
name: "dinou-asset-plugin",
|
|
21
|
+
buildStart() {
|
|
22
|
+
cleanRegex =
|
|
23
|
+
include || getAssetExtensionsInfo(dinouConfig, rootDir).regex;
|
|
24
|
+
emittedInCurrentBuild = new Set();
|
|
25
|
+
},
|
|
26
|
+
resolveId(source, importer) {
|
|
27
|
+
if (!source || source.startsWith("\0")) return null;
|
|
28
|
+
const cleanSpec = source.split("?")[0].split("#")[0];
|
|
29
|
+
if (!cleanRegex.test(cleanSpec)) return null;
|
|
30
|
+
const resolved = resolveAssetImport(source, {
|
|
31
|
+
importer: importer || "",
|
|
32
|
+
projectRoot: rootDir,
|
|
33
|
+
assetRegex: cleanRegex,
|
|
34
|
+
});
|
|
35
|
+
return resolved || null;
|
|
36
|
+
},
|
|
9
37
|
async load(id) {
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
if (!id || id.startsWith("\0")) return null;
|
|
39
|
+
const cleanId = id.split("?")[0].split("#")[0];
|
|
40
|
+
if (!cleanRegex.test(cleanId)) return null;
|
|
13
41
|
|
|
14
|
-
|
|
15
|
-
const scoped = createScopedName(base, id);
|
|
16
|
-
const ext = path.extname(id);
|
|
42
|
+
this.addWatchFile(cleanId);
|
|
17
43
|
|
|
18
|
-
const
|
|
44
|
+
const info = getAssetInfo(cleanId, rootDir, {
|
|
45
|
+
includeBuffer: emitFiles,
|
|
46
|
+
});
|
|
19
47
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
if (emitFiles && info.buffer) {
|
|
49
|
+
const sharedEmitted =
|
|
50
|
+
typeof globalThis !== "undefined"
|
|
51
|
+
? globalThis.__DINOU_EMITTED_ASSETS__ ||
|
|
52
|
+
(globalThis.__DINOU_EMITTED_ASSETS__ = new Set())
|
|
53
|
+
: null;
|
|
54
|
+
if (
|
|
55
|
+
!emittedInCurrentBuild.has(info.fileName) &&
|
|
56
|
+
(!sharedEmitted || !sharedEmitted.has(info.fileName))
|
|
57
|
+
) {
|
|
58
|
+
emittedInCurrentBuild.add(info.fileName);
|
|
59
|
+
sharedEmitted?.add(info.fileName);
|
|
60
|
+
this.emitFile({
|
|
61
|
+
type: "asset",
|
|
62
|
+
fileName: info.fileName,
|
|
63
|
+
source: info.buffer,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
28
66
|
}
|
|
29
67
|
|
|
30
|
-
return `export default
|
|
68
|
+
return `export default ${JSON.stringify(info.publicUrl)};`;
|
|
31
69
|
},
|
|
32
70
|
};
|
|
33
71
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const manifestData = {};
|
|
2
5
|
|
|
3
6
|
function manifestGeneratorPlugin() {
|
|
4
7
|
return {
|
|
5
8
|
name: "manifest-generator",
|
|
6
|
-
generateBundle(options, bundle) {
|
|
9
|
+
async generateBundle(options, bundle) {
|
|
10
|
+
for (const key of Object.keys(manifestData)) {
|
|
11
|
+
delete manifestData[key];
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
for (const [fileName, info] of Object.entries(bundle)) {
|
|
8
15
|
if (info.type === "chunk" && info.name) {
|
|
9
16
|
const cleanName = info.name + ".js";
|
|
@@ -11,11 +18,13 @@ function manifestGeneratorPlugin() {
|
|
|
11
18
|
}
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
const dist1Dir = path.resolve(process.cwd(), ".dinou/dist1");
|
|
22
|
+
await fs.mkdir(dist1Dir, { recursive: true });
|
|
23
|
+
await fs.writeFile(
|
|
24
|
+
path.join(dist1Dir, "manifest.json"),
|
|
25
|
+
JSON.stringify(manifestData, null, 2),
|
|
26
|
+
"utf8"
|
|
27
|
+
);
|
|
19
28
|
},
|
|
20
29
|
};
|
|
21
30
|
}
|