imprensa 0.1.1 → 0.1.2
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.mjs +23 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -474,8 +474,20 @@ const CONFIG_STUB = fileURLToPath(new URL("./docs/config.mjs", import.meta.url))
|
|
|
474
474
|
const ICONS_ENTRY = fileURLToPath(new URL("./components/icons.mjs", import.meta.url));
|
|
475
475
|
const IMPRENSA_PRERENDER_ENTRY = path.resolve(fileURLToPath(new URL("./core/prerender-core.mjs", import.meta.url)));
|
|
476
476
|
const IMPRENSA_CLIENT_RUNTIME = path.resolve(fileURLToPath(new URL("./core/client-runtime.mjs", import.meta.url)));
|
|
477
|
+
/** Published bundle still references __IMPRENSA_* until the Vite plugin rewrites them. */
|
|
478
|
+
const MDX_DIST_BUNDLE = path.join(fileURLToPath(new URL("../../..", import.meta.url)), "dist/docs/mdx.mjs");
|
|
477
479
|
function isMdxConfigTarget(id) {
|
|
478
|
-
|
|
480
|
+
const normalized = id.split("?")[0] ?? id;
|
|
481
|
+
return normalized === MDX_RUNTIME_CONFIG || normalized.endsWith("/imprensa/src/docs/mdx/runtime-config.ts") || normalized === MDX_SOURCE || normalized.endsWith("/imprensa/src/docs/mdx.ts") || normalized === MDX_DIST_BUNDLE || normalized.endsWith("/imprensa/dist/docs/mdx.mjs");
|
|
482
|
+
}
|
|
483
|
+
function injectedMdxRuntimeConfig(options) {
|
|
484
|
+
const { contentDir, repo, repoBranch, repoPath, headDefaults } = options;
|
|
485
|
+
return `export const contentDir = ${JSON.stringify(normalizeContentDir(contentDir))};
|
|
486
|
+
export const imprensaRepo = ${JSON.stringify(repo)};
|
|
487
|
+
export const imprensaRepoBranch = ${JSON.stringify(repoBranch)};
|
|
488
|
+
export const imprensaRepoPath = ${JSON.stringify(repoPath)};
|
|
489
|
+
export const mdxRawSources = ${JSON.stringify(collectRawMdxSources(process.cwd(), contentDir))};
|
|
490
|
+
export const headDefaults = ${JSON.stringify(headDefaults ?? null)};`;
|
|
479
491
|
}
|
|
480
492
|
function isAppPageFile(file, root) {
|
|
481
493
|
const relative = path.relative(path.join(root, "src/pages"), file).replace(/\\/g, "/");
|
|
@@ -597,12 +609,15 @@ export const shikiThemes = ${JSON.stringify(shikiThemes)};`;
|
|
|
597
609
|
};
|
|
598
610
|
}
|
|
599
611
|
if (!isMdxConfigTarget(id)) return;
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
612
|
+
const injected = injectedMdxRuntimeConfig({
|
|
613
|
+
contentDir,
|
|
614
|
+
repo,
|
|
615
|
+
repoBranch,
|
|
616
|
+
repoPath,
|
|
617
|
+
headDefaults
|
|
618
|
+
});
|
|
619
|
+
if (code.includes(MDX_CONFIG_MARKER)) return code.replace(MDX_CONFIG_MARKER, injected);
|
|
620
|
+
if (/__IMPRENSA_CONTENT_DIR__/.test(code)) return code.replace(/\/\/#region src\/docs\/mdx\/runtime-config\.ts[\s\S]*?\/\/#endregion/, `//#region src/docs/mdx/runtime-config.ts\n${injected}\n//#endregion`);
|
|
606
621
|
},
|
|
607
622
|
handleHotUpdate(ctx) {
|
|
608
623
|
if (!isAppPageFile(ctx.file, ctx.server.config.root)) return;
|
|
@@ -621,6 +636,7 @@ export const headDefaults = ${JSON.stringify(headDefaults ?? null)};`);
|
|
|
621
636
|
sonner = createRequire(path.join(root, "package.json")).resolve("sonner");
|
|
622
637
|
} catch {}
|
|
623
638
|
return {
|
|
639
|
+
optimizeDeps: { exclude: ["imprensa/mdx"] },
|
|
624
640
|
server: { watch: { usePolling: true } },
|
|
625
641
|
build: { rolldownOptions: { output: { codeSplitting: { groups: [{
|
|
626
642
|
name: "imprensa-search",
|