Skip to content

Commit e7e394d

Browse files
committed
Merge branch 'release-initial'
2 parents 654ff4d + cbb24cd commit e7e394d

File tree

9 files changed

+108
-42
lines changed

9 files changed

+108
-42
lines changed

.changeset/fast-bats-fold.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/v1-meta/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `@remix-run/v1-meta`
2+
3+
## 0.1.0
4+
5+
### Minor Changes
6+
7+
- Initial release ([`e15dfbb`](https://github.com/remix-run/v1-compat-utils/commit/e15dfbbe9d5f59e9200a3aa52ece65c024b2109f))

packages/v1-meta/README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
# V1 Meta
22

33
```tsx
4-
import { metaV1 } from "@remix-run/v1-meta";
4+
import { metaV1, getMatchesData } from "@remix-run/v1-meta";
55

6-
export function meta(args) {
6+
export const meta = (args) => {
7+
// In the v1 API, `meta` received a `parentsData` argument, which is an
8+
// object keyed by each parent route ID containing the data returned by
9+
// that route's `loader` function. This argument is removed from the
10+
// v2 API. `getMatchesData` will construct an object with the same
11+
// signature, allowing you to easily refactor your code.
12+
let matchesData = getMatchesData(args);
13+
let rootData = matchesData["root"];
14+
15+
// This function will construct an array of `V2_MetaDescriptor` objects.
16+
// It will use the same heuristics as Remix v1 to merge the parent
17+
// route's meta values with the data you provide.
718
return metaV1(args, {
819
title: "My App",
920
description: "My App Description",
1021
});
11-
// return [
12-
// { charSet: "utf-8" }, // inherited!
13-
// { title: "My App" },
14-
// { name: "description", content: "My App Description" },
15-
// ];
16-
}
22+
23+
// output:
24+
return [
25+
// This is inherited from the parent route!
26+
{ charSet: "utf-8" },
27+
// If your parent has a title it will be overridden!
28+
{ title: "My App" },
29+
{ name: "description", content: "My App Description" },
30+
];
31+
};
1732
```

packages/v1-meta/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/v1-meta",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"homepage": "https://remix.run",
55
"bugs": {
66
"url": "https://github.com/remix-run/v1-compat-utils/issues"
@@ -33,5 +33,12 @@
3333
"peerDependencies": {
3434
"@remix-run/react": "^1.15.0",
3535
"@remix-run/server-runtime": "^1.15.0"
36-
}
36+
},
37+
"files": [
38+
"dist",
39+
"src",
40+
"CHANGELOG.md",
41+
"LICENSE",
42+
"README.md"
43+
]
3744
}

packages/v1-meta/src/index.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
V2_MetaArgs as MetaArgs,
33
V2_MetaDescriptor as MetaDescriptor,
44
} from "@remix-run/react";
5-
import type { LoaderFunction } from "@remix-run/server-runtime";
5+
import type { LoaderFunction, SerializeFrom } from "@remix-run/server-runtime";
66

77
function metaV1<
88
Loader extends LoaderFunction | unknown = unknown,
@@ -90,6 +90,38 @@ function fromMetaData(metaData: V1_MetaDescriptor): MetaDescriptor[] {
9090
return meta;
9191
}
9292

93+
function getMatchesData<
94+
Loader extends unknown = unknown,
95+
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
96+
>(args: MetaArgs<Loader, MatchLoaders>) {
97+
let { matches } = args;
98+
return matches.reduce(
99+
(data, match) => {
100+
return {
101+
...data,
102+
[match.id]: match.data,
103+
};
104+
},
105+
{} as {
106+
[K in keyof MatchLoaders]: MatchLoaders[K] extends LoaderFunction
107+
? SerializeFrom<MatchLoaders[K]>
108+
: unknown;
109+
}
110+
);
111+
}
112+
113+
export interface V2_MetaMatch<
114+
RouteId extends string = string,
115+
Loader extends LoaderFunction | unknown = unknown
116+
> {
117+
id: RouteId;
118+
pathname: string;
119+
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : unknown;
120+
handle?: unknown;
121+
params: {};
122+
meta: MetaDescriptor[];
123+
}
124+
93125
function getMetaKey(metaDescriptor: MetaDescriptor) {
94126
if ("title" in metaDescriptor && metaDescriptor.title != null) {
95127
return "title";
@@ -155,5 +187,5 @@ interface V1_MetaDescriptor {
155187
| Array<Record<string, string> | string>;
156188
}
157189

158-
export { fromMetaData, metaV1, mergeMeta };
190+
export { fromMetaData, getMatchesData, metaV1, mergeMeta };
159191
export type { V1_MetaDescriptor };
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `@remix-run/v1-route-convention`
2+
3+
## 0.1.0
4+
5+
### Minor Changes
6+
7+
- Initial release ([`e15dfbb`](https://github.com/remix-run/v1-compat-utils/commit/e15dfbbe9d5f59e9200a3aa52ece65c024b2109f))

packages/v1-route-convention/README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44
// remix.config.js
55
const { createRoutesFromFolders } = require("@remix-run/v1-route-convention");
66

7-
// tell Remix to ignore everything in the routes directory
8-
// we'll let `createRoutesFromFolders` take care of that
9-
exports.ignoredRouteFiles = ["**/*"];
10-
exports.routes = (defineRoutes) => createRoutesFromFolders(defineRoutes);
11-
```
12-
13-
> **Note**
14-
> If you're already using `ignoredRouteFiles` you can move that to the plugin to keep using it
15-
16-
```diff
17-
// remix.config.js
18-
const { createRoutesFromFolders } = require("@remix-run/v1-route-convention");
19-
20-
- exports.ignoredRouteFiles = ["**/.*"];
21-
+ exports.ignoredRouteFiles = ["**/*"];
22-
+ exports.routes = (defineRoutes) => createRoutesFromFolders(defineRoutes, {
23-
+ ignoredFilePatterns: ["**/.*"]
24-
+ });
7+
/** @type {import('@remix-run/dev').AppConfig} */
8+
module.exports = {
9+
// Tell Remix to ignore everything in the routes directory.
10+
// We'll let `createRoutesFromFolders` take care of that.
11+
ignoredRouteFiles: ["**/*"],
12+
routes: (defineRoutes) => {
13+
// `createRoutesFromFolders` will create routes for all files in the
14+
// routes directory using the same default conventions as Remix v1.
15+
return createRoutesFromFolders(defineRoutes, {
16+
// If you're already using `ignoredRouteFiles` in your Remix config,
17+
// you can move them to `ignoredFilePatterns` in the plugin's options.
18+
ignoredFilePatterns: ["**/.*", "**/*.css"],
19+
});
20+
},
21+
};
2522
```

packages/v1-route-convention/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/v1-route-convention",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"homepage": "https://remix.run",
55
"bugs": {
66
"url": "https://github.com/remix-run/v1-compat-utils/issues"
@@ -31,5 +31,12 @@
3131
},
3232
"peerDependencies": {
3333
"@remix-run/dev": "^1.15.0"
34-
}
34+
},
35+
"files": [
36+
"dist",
37+
"src",
38+
"CHANGELOG.md",
39+
"LICENSE",
40+
"README.md"
41+
]
3542
}

scripts/remove-prerelease-changelogs.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const STABLE_HEADING_REGEXP = /^\d+\.\d+\.\d+$/i;
1515
main();
1616

1717
async function main() {
18-
// if (isPrereleaseMode()) {
19-
// console.log("🚫 Skipping changelog removal in prerelease mode");
20-
// return;
21-
// }
18+
if (isPrereleaseMode()) {
19+
console.log("🚫 Skipping changelog removal in prerelease mode");
20+
return;
21+
}
2222
await removePreReleaseChangelogs();
2323
console.log("✅ Removed pre-release changelogs");
2424
}

0 commit comments

Comments
 (0)