Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve config directory relative to flat output file structure #12187

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/serious-beds-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-router/dev": patch
---

resolve config directory relative to flat output file structure
7 changes: 6 additions & 1 deletion packages/react-router-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ export async function generateEntry(
return;
}

let defaultsDirectory = path.resolve(__dirname, "..", "config", "defaults");
let defaultsDirectory = path.resolve(
path.dirname(require.resolve("@react-router/dev/package.json")),
"dist",
"config",
"defaults"
);
let defaultEntryClient = path.resolve(defaultsDirectory, "entry.client.tsx");

let defaultEntryServer = path.resolve(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dev/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const entry = [
"typescript/plugin.ts",
];

const external = ["./static/refresh-utils.cjs"];
const external = ["./static/refresh-utils.cjs", /^(?!\.)/];

export default defineConfig([
{
Expand Down
7 changes: 6 additions & 1 deletion packages/react-router-dev/vite/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,12 @@ export async function resolveEntryFiles({
}) {
let { appDirectory } = reactRouterConfig;

let defaultsDirectory = path.resolve(__dirname, "..", "config", "defaults");
let defaultsDirectory = path.resolve(
path.dirname(require.resolve("@react-router/dev/package.json")),
"dist",
"config",
"defaults"
);

let userEntryClientFile = findEntry(appDirectory, "entry.client");
let userEntryServerFile = findEntry(appDirectory, "entry.server");
Expand Down
7 changes: 6 additions & 1 deletion packages/react-router-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ export let getServerBuildDirectory = (ctx: ReactRouterPluginContext) =>
let getClientBuildDirectory = (reactRouterConfig: ResolvedReactRouterConfig) =>
path.join(reactRouterConfig.buildDirectory, "client");

let defaultEntriesDir = path.resolve(__dirname, "..", "config", "defaults");
let defaultEntriesDir = path.resolve(
path.dirname(require.resolve("@react-router/dev/package.json")),
"dist",
"config",
"defaults"
);
let defaultEntries = fse
.readdirSync(defaultEntriesDir)
.map((filename) => path.join(defaultEntriesDir, filename));
Expand Down
6 changes: 0 additions & 6 deletions packages/react-router/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export default defineConfig([
format: ["cjs"],
outDir: "dist",
dts: true,
external: [
/*.*/
],
banner: {
js: createBanner(pkg.name, pkg.version),
},
Expand All @@ -31,9 +28,6 @@ export default defineConfig([
format: ["esm"],
outDir: "dist",
dts: true,
external: [
/*.*/
],
banner: {
js: createBanner(pkg.name, pkg.version),
},
Expand Down
Loading