Skip to content

Commit

Permalink
fix(remix-run/vite): loosen route export restrictions (#8420)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Dalgleish <mark.john.dalgleish@gmail.com>
  • Loading branch information
pcattori and markdalgleish committed Jan 9, 2024
1 parent b9e8eab commit dc8f9bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 101 deletions.
69 changes: 0 additions & 69 deletions integration/vite-route-exports-test.ts

This file was deleted.

32 changes: 0 additions & 32 deletions packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ const supportedRemixConfigKeys = [
type SupportedRemixConfigKey = typeof supportedRemixConfigKeys[number];
type SupportedRemixConfig = Pick<RemixUserConfig, SupportedRemixConfigKey>;

const ROUTE_EXPORTS = new Set([
"ErrorBoundary",
"HydrateFallback",
"action",
"clientAction",
"clientLoader",
"default", // component
"handle",
"headers",
"links",
"loader",
"meta",
"shouldRevalidate",
]);

const SERVER_ONLY_EXPORTS = ["loader", "action", "headers"];

// We need to provide different JSDoc comments in some cases due to differences
Expand Down Expand Up @@ -1156,23 +1141,6 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
let route = getRoute(pluginConfig, id);
if (!route) return;

// check the exports, fail if unknown exists, unless id ends with .mdx
let nonRemixExports = esModuleLexer(code)[1]
.map((exp) => exp.n)
.filter((exp) => !ROUTE_EXPORTS.has(exp));
if (nonRemixExports.length > 0 && !id.endsWith(".mdx")) {
let message = [
`${nonRemixExports.length} invalid route export${
nonRemixExports.length > 1 ? "s" : ""
} in \`${route.file}\`:`,
...nonRemixExports.map((exp) => ` - \`${exp}\``),
"",
"See https://remix.run/docs/en/main/future/vite#strict-route-exports",
"",
].join("\n");
throw Error(message);
}

if (pluginConfig.isSpaMode) {
let serverOnlyExports = esModuleLexer(code)[1]
.map((exp) => exp.n)
Expand Down

0 comments on commit dc8f9bc

Please sign in to comment.