Skip to content

Commit

Permalink
Merge branch 'v2' into brophdawg11/remove-catch-boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Mar 17, 2023
2 parents 7cbe2f2 + 9506d4e commit d8fa0b4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 65 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-readers-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": major
---

remove `browserBuildDirectory` config
5 changes: 5 additions & 0 deletions .changeset/tame-moons-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": major
---

remove `serverBuildDirectory` config
57 changes: 5 additions & 52 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ export interface AppConfig {
*/
assetsBuildDirectory?: string;

/**
* The path to the browser build, relative to remix.config.js. Defaults to
* "public/build".
*
* @deprecated Use `{@link AppConfig.assetsBuildDirectory}` instead
*/
browserBuildDirectory?: string;

/**
* The URL prefix of the browser build with a trailing slash. Defaults to
* `"/build/"`. This is the path the browser will use to find assets.
Expand Down Expand Up @@ -116,14 +108,6 @@ export interface AppConfig {
*/
server?: string;

/**
* The path to the server build, relative to `remix.config.js`. Defaults to
* "build".
*
* @deprecated Use {@link AppConfig.serverBuildPath} instead.
*/
serverBuildDirectory?: string;

/**
* The path to the server build file, relative to `remix.config.js`. This file
* should end in a `.js` extension and should be deployed to your server.
Expand Down Expand Up @@ -376,7 +360,10 @@ export async function readConfig(
}
}

let serverBuildPath = resolveServerBuildPath(rootDirectory, appConfig);
let serverBuildPath = path.resolve(
rootDirectory,
appConfig.serverBuildPath ?? "build/index.js"
);
let serverBuildTargetEntryModule = `export * from ${JSON.stringify(
serverBuildVirtualModule.id
)};`;
Expand Down Expand Up @@ -484,14 +471,8 @@ export async function readConfig(
? path.resolve(appDirectory, userEntryServerFile)
: path.resolve(defaultsDirectory, entryServerFile);

if (appConfig.browserBuildDirectory) {
warnOnce(browserBuildDirectoryWarning, "browserBuildDirectory");
}

let assetsBuildDirectory =
appConfig.assetsBuildDirectory ||
appConfig.browserBuildDirectory ||
path.join("public", "build");
appConfig.assetsBuildDirectory || path.join("public", "build");

let absoluteAssetsBuildDirectory = path.resolve(
rootDirectory,
Expand Down Expand Up @@ -643,41 +624,13 @@ export function findConfig(
return undefined;
}

const resolveServerBuildPath = (
rootDirectory: string,
appConfig: AppConfig
) => {
let serverBuildPath = "build/index.js";

// retain deprecated behavior for now
if (appConfig.serverBuildDirectory) {
warnOnce(serverBuildDirectoryWarning, "serverBuildDirectory");

serverBuildPath = path.join(appConfig.serverBuildDirectory, "index.js");
}

if (appConfig.serverBuildPath) {
serverBuildPath = appConfig.serverBuildPath;
}

return path.resolve(rootDirectory, serverBuildPath);
};

// @ts-expect-error available in node 12+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat#browser_compatibility
let listFormat = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});

export let browserBuildDirectoryWarning =
"⚠️ DEPRECATED: The `browserBuildDirectory` config option is deprecated. " +
"Use `assetsBuildDirectory` instead.";

export let serverBuildDirectoryWarning =
"⚠️ DEPRECATED: The `serverBuildDirectory` config option is deprecated. " +
"Use `serverBuildPath` instead.";

export let serverBuildTargetWarning =
"⚠️ DEPRECATED: The `serverBuildTarget` config option is deprecated. Use a " +
"combination of `publicPath`, `serverBuildPath`, `serverConditions`, " +
Expand Down
33 changes: 20 additions & 13 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ export function Meta() {
let routeModule = routeModules[routeId];
let routeMeta: MetaDescriptor[] | undefined = [];

let match: MetaMatch = {
id: routeId,
data,
meta: [],
params: _match.params,
pathname: _match.pathname,
handle: _match.route.handle,
};
matches[i] = match;

if (routeModule?.meta) {
routeMeta =
typeof routeModule.meta === "function"
Expand All @@ -518,35 +528,32 @@ export function Meta() {
location,
matches,
})
: Array.isArray(routeModule.meta)
? [...routeModule.meta]
: routeModule.meta;
} else if (leafMeta) {
// We only assign the route's meta to the nearest leaf if there is no meta
// export in the route. The meta function may return a falsey value which
// is effectively the same as an empty array.
routeMeta = leafMeta;
routeMeta = [...leafMeta];
}

routeMeta = routeMeta || [];
if (!Array.isArray(routeMeta)) {
throw new Error(
"The route at " +
"The `v2_meta` API is enabled in the Remix config, but the route at " +
_match.route.path +
" returns an invalid value. All route meta functions must " +
" returns an invalid value. In v2, all route meta functions must " +
"return an array of meta objects." +
"\n\nTo reference the meta function API, see https://remix.run/route/meta"
// TODO: Add link to the docs once they are written
// "\n\nTo reference future flags and the v2 meta API, see https://remix.run/file-conventions/remix-config#future-v2-meta." +
"\n\nTo reference the v1 meta function API, see https://remix.run/route/meta"
);
}

let match: MetaMatch = {
id: routeId,
data,
meta: routeMeta,
params: _match.params,
pathname: _match.pathname,
handle: _match.route.handle,
};
match.meta = routeMeta;
matches[i] = match;
meta = routeMeta;
meta = [...routeMeta];
leafMeta = meta;
}

Expand Down

0 comments on commit d8fa0b4

Please sign in to comment.