@qzsy/vinext 0.1.9 → 0.1.10
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/dist/index.js +30 -7
- package/dist/server/app-rsc-handler.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -341,6 +341,22 @@ const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
|
341
341
|
const _appBrowserServerActionClientPath = resolveShimModulePath(normalizePathSeparators(path.resolve(__dirname, "server")), "app-browser-server-action-client");
|
|
342
342
|
const _appRscHandlerPath = resolveShimModulePath(normalizePathSeparators(path.resolve(__dirname, "server")), "app-rsc-handler");
|
|
343
343
|
const _canExternalizeAppRscHandler = _appRscHandlerPath.endsWith(".js");
|
|
344
|
+
const _defaultImageLoaderShimPath = resolveShimModulePath(_shimsDir, "default-image-loader");
|
|
345
|
+
/** Absolute path to `images.loaderFile` when configured; set in vinext:config. */
|
|
346
|
+
let _imageLoaderFile;
|
|
347
|
+
function isImageShimModule(importer) {
|
|
348
|
+
if (!importer) return false;
|
|
349
|
+
const normalized = normalizePathSeparators(importer.split("?")[0]);
|
|
350
|
+
return /\/shims\/image\.(tsx?|jsx?)$/.test(normalized);
|
|
351
|
+
}
|
|
352
|
+
function isDefaultImageLoaderRequest(id, importer) {
|
|
353
|
+
const cleanId = id.startsWith("\0") ? id.slice(1) : id;
|
|
354
|
+
const normalizedId = normalizePathSeparators(cleanId.split("?")[0]);
|
|
355
|
+
if (normalizedId === normalizePathSeparators(_defaultImageLoaderShimPath)) return true;
|
|
356
|
+
if (/\/shims\/default-image-loader\.(tsx?|jsx?)$/.test(normalizedId)) return true;
|
|
357
|
+
if (isImageShimModule(importer) && (cleanId === "./default-image-loader.js" || cleanId === "./default-image-loader" || cleanId === "./default-image-loader.ts" || cleanId === "./default-image-loader.tsx")) return true;
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
344
360
|
function isValidExportIdentifier(name) {
|
|
345
361
|
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
346
362
|
}
|
|
@@ -623,6 +639,16 @@ function vinext(options = {}) {
|
|
|
623
639
|
serverOnlyShimPath: resolveShimModulePath(shimsDir, "server-only")
|
|
624
640
|
}),
|
|
625
641
|
dataUrlCssPlugin(),
|
|
642
|
+
{
|
|
643
|
+
name: "vinext:image-loader-file",
|
|
644
|
+
enforce: "pre",
|
|
645
|
+
resolveId: {
|
|
646
|
+
filter: { id: /default-image-loader/ },
|
|
647
|
+
handler(id, importer) {
|
|
648
|
+
if (_imageLoaderFile && isDefaultImageLoaderRequest(id, importer)) return _imageLoaderFile;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
},
|
|
626
652
|
{
|
|
627
653
|
name: "vinext:config",
|
|
628
654
|
enforce: "pre",
|
|
@@ -827,9 +853,7 @@ function vinext(options = {}) {
|
|
|
827
853
|
overlay: false
|
|
828
854
|
};
|
|
829
855
|
const cssModulesOverride = config.css?.modules === false || typeof config.css?.modules === "object" && "Loader" in config.css.modules ? {} : { modules: { Loader: sassComposesLoader.Loader } };
|
|
830
|
-
|
|
831
|
-
const imageLoaderFile = nextConfig.images?.loaderFile;
|
|
832
|
-
const imageLoaderAlias = imageLoaderFile != null ? { [defaultImageLoaderShimPath]: imageLoaderFile } : {};
|
|
856
|
+
_imageLoaderFile = nextConfig.images?.loaderFile;
|
|
833
857
|
const viteConfig = {
|
|
834
858
|
appType: "custom",
|
|
835
859
|
build: {
|
|
@@ -877,8 +901,7 @@ function vinext(options = {}) {
|
|
|
877
901
|
alias: {
|
|
878
902
|
...tsconfigPathAliases,
|
|
879
903
|
...nextConfig.aliases,
|
|
880
|
-
...nextShimMap
|
|
881
|
-
...imageLoaderAlias
|
|
904
|
+
...nextShimMap
|
|
882
905
|
},
|
|
883
906
|
dedupe: [
|
|
884
907
|
"react",
|
|
@@ -922,10 +945,10 @@ function vinext(options = {}) {
|
|
|
922
945
|
const incomingInclude = config.optimizeDeps?.include ?? [];
|
|
923
946
|
const depOptimizeAliasPlugin = {
|
|
924
947
|
name: "vinext:dep-optimize-alias",
|
|
925
|
-
resolveId(id) {
|
|
948
|
+
resolveId(id, importer) {
|
|
926
949
|
const shimBase = _reactServerShims.get(id);
|
|
927
950
|
if (shimBase !== void 0) return resolveShimModulePath(shimsDir, shimBase);
|
|
928
|
-
if (
|
|
951
|
+
if (_imageLoaderFile && isDefaultImageLoaderRequest(id, importer)) return _imageLoaderFile;
|
|
929
952
|
}
|
|
930
953
|
};
|
|
931
954
|
const depOptimizeNodeEnvOptions = getDepOptimizeNodeEnvOptions(viteMajorVersion, nodeEnvDefine);
|
|
@@ -17,11 +17,11 @@ import "./app-page-response.js";
|
|
|
17
17
|
import { buildNextDataNotFoundResponse, normalizePagesDataRequest } from "./pages-data-route.js";
|
|
18
18
|
import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
|
|
19
19
|
import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
|
|
20
|
+
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
20
21
|
import { pickRootParams, setRootParams } from "../shims/root-params.js";
|
|
21
22
|
import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
|
|
22
23
|
import { buildPageCacheTags } from "./implicit-tags.js";
|
|
23
24
|
import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
|
|
24
|
-
import { flattenErrorCauses } from "../utils/error-cause.js";
|
|
25
25
|
import { finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
|
|
26
26
|
import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
|
|
27
27
|
import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
|