@farming-labs/next 0.0.59 → 0.0.60

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.
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { jsx } from "react/jsx-runtime";
4
- import docsConfig from "@/docs.config";
4
+ import docsConfig from "@farming-labs/next-internal-docs-config";
5
5
  import { DocsClientHooks } from "@farming-labs/theme/client-hooks";
6
6
 
7
7
  //#region src/client-callbacks.tsx
package/dist/config.mjs CHANGED
@@ -90,6 +90,7 @@ const FILE_EXTS = [
90
90
  "jsx",
91
91
  "js"
92
92
  ];
93
+ const INTERNAL_DOCS_CONFIG_ALIAS = "@farming-labs/next-internal-docs-config";
93
94
  function hasFile(root, baseName) {
94
95
  return FILE_EXTS.some((ext) => existsSync(join(root, `${baseName}.${ext}`)));
95
96
  }
@@ -112,6 +113,13 @@ function readDocsEntry(root) {
112
113
  }
113
114
  return "docs";
114
115
  }
116
+ function readDocsConfigPath(root) {
117
+ for (const ext of FILE_EXTS) {
118
+ const relativePath = `docs.config.${ext}`;
119
+ if (existsSync(join(root, relativePath))) return relativePath;
120
+ }
121
+ return "docs.config.ts";
122
+ }
115
123
  /** Read the OG endpoint from docs.config.ts[x] (returns undefined if not set). */
116
124
  function readOgEndpoint(root) {
117
125
  for (const ext of FILE_EXTS) {
@@ -181,6 +189,9 @@ function extractObjectLiteral(content, key) {
181
189
  }
182
190
  function withDocs(nextConfig = {}) {
183
191
  const root = process.cwd();
192
+ const docsConfigPath = readDocsConfigPath(root);
193
+ const docsConfigAbsolutePath = join(root, docsConfigPath);
194
+ const docsConfigRelativeAlias = docsConfigPath.startsWith("./") || docsConfigPath.startsWith("../") ? docsConfigPath : `./${docsConfigPath}`;
184
195
  if (!hasFile(root, "mdx-components")) writeFileSync(join(root, "mdx-components.tsx"), MDX_COMPONENTS_TEMPLATE);
185
196
  const entry = readDocsEntry(root);
186
197
  const appDir = getNextAppDir(root);
@@ -228,6 +239,23 @@ function withDocs(nextConfig = {}) {
228
239
  if (userExts) {
229
240
  for (const ext of ["md", "mdx"]) if (!userExts.includes(ext)) userExts.push(ext);
230
241
  } else nextConfig.pageExtensions = defaultExts;
242
+ const existingTurbopack = nextConfig.turbopack ?? {};
243
+ const existingResolveAlias = existingTurbopack.resolveAlias ?? {};
244
+ nextConfig.turbopack = {
245
+ ...existingTurbopack,
246
+ resolveAlias: {
247
+ ...existingResolveAlias,
248
+ [INTERNAL_DOCS_CONFIG_ALIAS]: docsConfigRelativeAlias
249
+ }
250
+ };
251
+ const userWebpack = nextConfig.webpack;
252
+ nextConfig.webpack = (config, options) => {
253
+ const resolvedConfig = userWebpack ? userWebpack(config, options) : config;
254
+ resolvedConfig.resolve ??= {};
255
+ resolvedConfig.resolve.alias ??= {};
256
+ resolvedConfig.resolve.alias[INTERNAL_DOCS_CONFIG_ALIAS] = docsConfigAbsolutePath;
257
+ return resolvedConfig;
258
+ };
231
259
  return withMDX(nextConfig);
232
260
  }
233
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/next",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
5
5
  "keywords": [
6
6
  "docs",
@@ -79,8 +79,8 @@
79
79
  "tsdown": "^0.20.3",
80
80
  "typescript": "^5.9.3",
81
81
  "vitest": "^3.2.4",
82
- "@farming-labs/docs": "0.0.59",
83
- "@farming-labs/theme": "0.0.59"
82
+ "@farming-labs/docs": "0.0.60",
83
+ "@farming-labs/theme": "0.0.60"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@farming-labs/docs": ">=0.0.1",