vinext 0.0.20 → 0.0.21
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.d.ts.map +1 -1
- package/dist/index.js +54 -12
- package/dist/index.js.map +1 -1
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +70 -3
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +13 -4
- package/dist/server/middleware.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA6B,MAAM,MAAM,CAAC;AAoH9D;;;;;;;;GAQG;AACH,iBAAS,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAkBnF;AAuGD;;;;;;;;;;;GAWG;AACH,iBAAe,2BAA2B,CACxC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,EAAE,CAAA;CAAE,GAAG,SAAS,CAAC,CAqEzC;AA0CD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA8B1D;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB;;;CAGvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,qBAAqB;;;CAG1B,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,iBAAiB,CACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB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,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,GACD,MAAM,EAAE,CAwDV;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,EAAE,CAoyFpE;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAuG/B;AA8KD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGhH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC;AAC5F,OAAO,EAAE,2BAA2B,IAAI,4BAA4B,EAAE,CAAC;AACvE,OAAO,EAAE,wBAAwB,IAAI,yBAAyB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1559,6 +1559,9 @@ hydrate();
|
|
|
1559
1559
|
});
|
|
1560
1560
|
}
|
|
1561
1561
|
const imageImportDimCache = new Map();
|
|
1562
|
+
// Shared state for the MDX proxy plugin. Populated during config() if MDX
|
|
1563
|
+
// files are detected and @mdx-js/rollup is installed.
|
|
1564
|
+
let mdxDelegate = null;
|
|
1562
1565
|
const plugins = [
|
|
1563
1566
|
// Resolve tsconfig paths/baseUrl aliases so real-world Next.js repos
|
|
1564
1567
|
// that use @/*, #/*, or baseUrl imports work out of the box.
|
|
@@ -1753,11 +1756,10 @@ hydrate();
|
|
|
1753
1756
|
// already configured. Applies remark/rehype plugins from next.config.
|
|
1754
1757
|
const hasMdxPlugin = pluginsFlat.some((p) => p && typeof p === "object" && typeof p.name === "string" &&
|
|
1755
1758
|
(p.name === "@mdx-js/rollup" || p.name === "mdx"));
|
|
1756
|
-
const mdxPlugins = [];
|
|
1757
1759
|
if (!hasMdxPlugin && hasMdxFiles(root, hasAppDir ? appDir : null, hasPagesDir ? pagesDir : null)) {
|
|
1758
1760
|
try {
|
|
1759
1761
|
const mdxRollup = await import("@mdx-js/rollup");
|
|
1760
|
-
const
|
|
1762
|
+
const mdxFactory = mdxRollup.default ?? mdxRollup;
|
|
1761
1763
|
const mdxOpts = {};
|
|
1762
1764
|
if (nextConfig.mdx) {
|
|
1763
1765
|
if (nextConfig.mdx.remarkPlugins)
|
|
@@ -1767,7 +1769,7 @@ hydrate();
|
|
|
1767
1769
|
if (nextConfig.mdx.recmaPlugins)
|
|
1768
1770
|
mdxOpts.recmaPlugins = nextConfig.mdx.recmaPlugins;
|
|
1769
1771
|
}
|
|
1770
|
-
|
|
1772
|
+
mdxDelegate = mdxFactory(mdxOpts);
|
|
1771
1773
|
if (nextConfig.mdx) {
|
|
1772
1774
|
console.log("[vinext] Auto-injected @mdx-js/rollup with remark/rehype plugins from next.config");
|
|
1773
1775
|
}
|
|
@@ -1991,10 +1993,6 @@ hydrate();
|
|
|
1991
1993
|
},
|
|
1992
1994
|
};
|
|
1993
1995
|
}
|
|
1994
|
-
// Add auto-injected MDX plugin if needed
|
|
1995
|
-
if (mdxPlugins.length > 0) {
|
|
1996
|
-
viteConfig.plugins = mdxPlugins;
|
|
1997
|
-
}
|
|
1998
1996
|
return viteConfig;
|
|
1999
1997
|
},
|
|
2000
1998
|
configResolved(config) {
|
|
@@ -2100,6 +2098,31 @@ hydrate();
|
|
|
2100
2098
|
}
|
|
2101
2099
|
},
|
|
2102
2100
|
},
|
|
2101
|
+
// Proxy plugin for @mdx-js/rollup. The real MDX plugin is created lazily
|
|
2102
|
+
// during vinext:config's config() (when MDX files are detected), but
|
|
2103
|
+
// plugins returned from config() hooks run too late in the pipeline —
|
|
2104
|
+
// after vite:import-analysis. This top-level proxy with enforce:"pre"
|
|
2105
|
+
// ensures MDX transforms run at the correct stage. Both vinext:config
|
|
2106
|
+
// and this proxy are enforce:"pre", and vinext:config comes first in
|
|
2107
|
+
// the array, so mdxDelegate is already set when this proxy's hooks fire.
|
|
2108
|
+
{
|
|
2109
|
+
name: "vinext:mdx",
|
|
2110
|
+
enforce: "pre",
|
|
2111
|
+
config(config, env) {
|
|
2112
|
+
if (!mdxDelegate?.config)
|
|
2113
|
+
return;
|
|
2114
|
+
const hook = mdxDelegate.config;
|
|
2115
|
+
const fn = typeof hook === "function" ? hook : hook.handler;
|
|
2116
|
+
return fn.call(this, config, env);
|
|
2117
|
+
},
|
|
2118
|
+
transform(code, id, options) {
|
|
2119
|
+
if (!mdxDelegate?.transform)
|
|
2120
|
+
return;
|
|
2121
|
+
const hook = mdxDelegate.transform;
|
|
2122
|
+
const fn = typeof hook === "function" ? hook : hook.handler;
|
|
2123
|
+
return fn.call(this, code, id, options);
|
|
2124
|
+
},
|
|
2125
|
+
},
|
|
2103
2126
|
// Shim React canary/experimental APIs (ViewTransition, addTransitionType)
|
|
2104
2127
|
// that exist in Next.js's bundled React canary but not in stable React 19.
|
|
2105
2128
|
// Provides graceful no-op fallbacks so projects using these APIs degrade
|
|
@@ -2366,9 +2389,22 @@ hydrate();
|
|
|
2366
2389
|
const result = await runMiddleware(server, middlewarePath, middlewareRequest);
|
|
2367
2390
|
if (!result.continue) {
|
|
2368
2391
|
if (result.redirectUrl) {
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2392
|
+
const redirectHeaders = { Location: result.redirectUrl };
|
|
2393
|
+
if (result.responseHeaders) {
|
|
2394
|
+
for (const [key, value] of result.responseHeaders) {
|
|
2395
|
+
const existing = redirectHeaders[key];
|
|
2396
|
+
if (existing === undefined) {
|
|
2397
|
+
redirectHeaders[key] = value;
|
|
2398
|
+
}
|
|
2399
|
+
else if (Array.isArray(existing)) {
|
|
2400
|
+
existing.push(value);
|
|
2401
|
+
}
|
|
2402
|
+
else {
|
|
2403
|
+
redirectHeaders[key] = [existing, value];
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
res.writeHead(result.redirectStatus ?? 307, redirectHeaders);
|
|
2372
2408
|
res.end();
|
|
2373
2409
|
return;
|
|
2374
2410
|
}
|
|
@@ -2438,7 +2474,10 @@ hydrate();
|
|
|
2438
2474
|
const handled = await handleApiRoute(server, req, res, resolvedUrl, apiRoutes);
|
|
2439
2475
|
if (handled)
|
|
2440
2476
|
return;
|
|
2441
|
-
// No API route matched —
|
|
2477
|
+
// No API route matched — if app dir exists, let the RSC plugin handle it
|
|
2478
|
+
// (app/api/* route handlers live there). Otherwise hard-404.
|
|
2479
|
+
if (hasAppDir)
|
|
2480
|
+
return next();
|
|
2442
2481
|
res.statusCode = 404;
|
|
2443
2482
|
res.end("404 - API route not found");
|
|
2444
2483
|
return;
|
|
@@ -2479,7 +2518,10 @@ hydrate();
|
|
|
2479
2518
|
return;
|
|
2480
2519
|
}
|
|
2481
2520
|
}
|
|
2482
|
-
// No fallback matched
|
|
2521
|
+
// No fallback matched - if app dir exists, let the RSC plugin handle it,
|
|
2522
|
+
// otherwise render via the pages SSR handler (will 404 for unknown routes).
|
|
2523
|
+
if (hasAppDir)
|
|
2524
|
+
return next();
|
|
2483
2525
|
await handler(req, res, resolvedUrl, mwStatus);
|
|
2484
2526
|
}
|
|
2485
2527
|
catch (e) {
|