Skip to content

Commit a6664f3

Browse files
pokeytrillium
authored andcommitted
Fix hot reload for dependencies of cursorless-org
1 parent f793231 commit a6664f3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/cursorless-org/next.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
import mdx from "@next/mdx";
2+
import { readFileSync } from "fs";
3+
import { join, dirname } from "path";
4+
import { fileURLToPath } from "url";
5+
26
const withMDX = mdx({
37
options: {
48
providerImportSource: "@mdx-js/react",
59
},
610
});
711

12+
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
14+
/**
15+
* The names of the packages that come from the same monorepo as this package.
16+
* We want these to be transpiled by Next.js because we are directly importing
17+
* the source typescript files from these packages.
18+
*/
19+
const references = JSON.parse(
20+
readFileSync(join(__dirname, "tsconfig.json"), "utf-8"),
21+
).references.map(({ path }) => {
22+
return JSON.parse(
23+
readFileSync(join(__dirname, path, "package.json"), "utf-8"),
24+
).name;
25+
});
26+
827
/** @type {import('next').NextConfig} */
928
const nextConfig = {
1029
webpack(config) {
@@ -14,11 +33,20 @@ const nextConfig = {
1433
use: ["@svgr/webpack"],
1534
});
1635

36+
config.plugins.push({
37+
apply(compiler) {
38+
compiler.hooks.afterEnvironment.tap("NextEntryPlugin", () => {
39+
compiler.options.resolve.conditionNames.push("cursorless:bundler");
40+
});
41+
},
42+
});
43+
1744
return config;
1845
},
1946
experimental: {
2047
mdxRs: true,
2148
},
49+
transpilePackages: references,
2250
reactStrictMode: true,
2351
};
2452

0 commit comments

Comments
 (0)