Skip to content

Commit 2d5924f

Browse files
feat: configure export conditions properly (#12136)
feat: nuke rollup into oblivion in favor of tsup feat: add ESM build for architect, express and node packages chore: update HMR test to ignore warning log feat: add module-sync export condition fix: react-router should not reference itself, that's weird (use tsconfig paths) chore: update e2e test warning assertion chore: add vite ignore comment for dynamic import fix: update optimizeDeps chore: add wireit for caching chore: add cache to workflows --------- Co-authored-by: Matt Brophy <[email protected]>
1 parent 5c7cc02 commit 2d5924f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1481
-1590
lines changed

.github/workflows/shared-build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
node-version-file: ".nvmrc"
2323
cache: "pnpm"
2424

25+
- uses: google/wireit@setup-github-actions-caching/v2
26+
2527
- name: Disable GitHub Actions Annotations
2628
run: |
2729
echo "::remove-matcher owner=tsc::"

.github/workflows/shared-integration.yml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
node-version: ${{ matrix.node }}
4646
cache: "pnpm"
4747

48+
- uses: google/wireit@setup-github-actions-caching/v2
49+
4850
- name: Disable GitHub Actions Annotations
4951
run: |
5052
echo "::remove-matcher owner=tsc::"

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
cache: pnpm
4646
check-latest: true
4747

48+
- uses: google/wireit@setup-github-actions-caching/v2
49+
4850
- name: Disable GitHub Actions Annotations
4951
run: |
5052
echo "::remove-matcher owner=tsc::"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ node_modules/
2222
/packages/*/dist/
2323
/packages/*/LICENSE.md
2424

25+
.wireit
2526
.eslintcache
2627
.tmp
2728
/.env

build.utils.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export function createBanner(packageName: string, version: string) {
2+
return `/**
3+
* ${packageName} v${version}
4+
*
5+
* Copyright (c) Remix Software Inc.
6+
*
7+
* This source code is licensed under the MIT license found in the
8+
* LICENSE.md file in the root directory of this source tree.
9+
*
10+
* @license MIT
11+
*/`;
12+
}

integration/helpers/playwright-fixture.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import cp from "node:child_process";
22
import type { Page, Response, Request } from "@playwright/test";
33
import { test } from "@playwright/test";
4-
import cheerio from "cheerio";
4+
import { load } from "cheerio";
55
import prettier from "prettier";
66

7+
let cheerio = load("");
8+
79
import type { AppFixture } from "./create-fixture.js";
810

911
export class PlaywrightFixture {
@@ -239,7 +241,7 @@ export function selectHtml(source: string, selector: string) {
239241
return prettyHtml(cheerio.html(el)).trim();
240242
}
241243

242-
export function prettyHtml(source: string): string {
244+
export function prettyHtml(source: string) {
243245
return prettier.format(source, { parser: "html" });
244246
}
245247

integration/vite-spa-mode-test.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,15 @@ test.describe("SPA Mode", () => {
567567
expect(await page.locator("[data-root]").textContent()).toBe("Root");
568568
expect(await page.locator("[data-index]").textContent()).toBe("Index");
569569

570-
// Hydrates without issues
571-
expect(logs).toEqual([]);
570+
// Hydrates without issues - this message is expected due to the nested <Routes>
571+
expect(logs).toEqual([
572+
'You rendered descendant <Routes> (or called `useRoutes()`) at "/" ' +
573+
'(under <Route path="">) but the parent route path has no trailing "*". ' +
574+
"This means if you navigate deeper, the parent won't match anymore and " +
575+
"therefore the child routes will never render." +
576+
"\n\n" +
577+
'Please change the parent <Route path=""> to <Route path="/*">.',
578+
]);
572579
});
573580

574581
test("wraps default root HydrateFallback in user-provided Layout", async ({

package.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@remix-run/react-router",
33
"private": true,
44
"scripts": {
5-
"build": "rollup -c",
5+
"build": "pnpm run --filter=\"./packages/**/*\" build",
66
"clean": "git clean -fdX .",
77
"clean:build": "git clean -fdx -e node_modules .",
88
"clean:integration": "node ./integration/helpers/cleanup.mjs",
@@ -57,10 +57,6 @@
5757
"@octokit/rest": "^18.12.0",
5858
"@playwright/test": "^1.33.0",
5959
"@remix-run/changelog-github": "^0.0.5",
60-
"@rollup/plugin-babel": "^5.3.1",
61-
"@rollup/plugin-node-resolve": "^11.0.1",
62-
"@rollup/plugin-replace": "^4.0.0",
63-
"@rollup/plugin-typescript": "^8.5.0",
6460
"@testing-library/jest-dom": "5.17.0",
6561
"@testing-library/react": "^13.4.0",
6662
"@testing-library/user-event": "^14.5.2",
@@ -104,10 +100,6 @@
104100
"remark-gfm": "3.0.1",
105101
"remark-parse": "^10.0.1",
106102
"remark-stringify": "^10.0.2",
107-
"rollup": "^2.79.1",
108-
"rollup-plugin-copy": "^3.4.0",
109-
"rollup-plugin-prettier": "^2.3.0",
110-
"rollup-plugin-terser": "^7.0.2",
111103
"semver": "^7.5.4",
112104
"tslib": "^2.6.2",
113105
"type-fest": "^2.19.0",

packages/react-router-architect/package.json

+31-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,38 @@
1515
"typings": "dist/index.d.ts",
1616
"exports": {
1717
".": {
18-
"types": "./dist/index.d.ts",
19-
"default": "./dist/index.js"
18+
"node": {
19+
"types": "./dist/index.d.ts",
20+
"module-sync": "./dist/index.mjs",
21+
"default": "./dist/index.js"
22+
},
23+
"import": {
24+
"types": "./dist/index.d.mts",
25+
"default": "./dist/index.mjs"
26+
},
27+
"default": {
28+
"types": "./dist/index.d.ts",
29+
"default": "./dist/index.js"
30+
}
2031
},
2132
"./package.json": "./package.json"
2233
},
2334
"scripts": {
24-
"tsc": "tsc"
35+
"build": "wireit"
36+
},
37+
"wireit": {
38+
"build": {
39+
"command": "tsup",
40+
"files": [
41+
"sessions/**",
42+
"*.ts",
43+
"tsconfig.json",
44+
"package.json"
45+
],
46+
"output": [
47+
"dist/**"
48+
]
49+
}
2550
},
2651
"dependencies": {
2752
"@architect/functions": "^5.2.0",
@@ -35,7 +60,9 @@
3560
"react": "^18.2.0",
3661
"react-dom": "^18.2.0",
3762
"react-router": "workspace:*",
38-
"typescript": "^5.1.0"
63+
"tsup": "^8.3.0",
64+
"typescript": "^5.1.6",
65+
"wireit": "0.14.9"
3966
},
4067
"peerDependencies": {
4168
"@react-router/node": "workspace:^",

packages/react-router-architect/rollup.config.js

-56
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from "tsup";
2+
3+
// @ts-ignore - out of scope
4+
import { createBanner } from "../../build.utils.js";
5+
6+
import pkg from "./package.json";
7+
8+
const entry = ["index.ts"];
9+
10+
export default defineConfig([
11+
{
12+
clean: true,
13+
entry,
14+
format: ["cjs", "esm"],
15+
outDir: "dist",
16+
dts: true,
17+
banner: {
18+
js: createBanner(pkg.name, pkg.version),
19+
},
20+
},
21+
]);

packages/react-router-cloudflare/package.json

+27-5
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,45 @@
1515
"typings": "dist/index.d.ts",
1616
"exports": {
1717
".": {
18-
"types": "./dist/index.d.ts",
19-
"default": "./dist/index.js"
18+
"import": {
19+
"types": "./dist/index.d.mts",
20+
"default": "./dist/index.mjs"
21+
},
22+
"default": {
23+
"types": "./dist/index.d.ts",
24+
"default": "./dist/index.js"
25+
}
2026
},
2127
"./package.json": "./package.json"
2228
},
2329
"scripts": {
24-
"build": "rollup -c",
25-
"tsc": "tsc"
30+
"build": "wireit"
31+
},
32+
"wireit": {
33+
"build": {
34+
"command": "tsup",
35+
"files": [
36+
"sessions/**",
37+
"*.ts",
38+
"tsconfig.json",
39+
"package.json"
40+
],
41+
"output": [
42+
"dist/**"
43+
]
44+
}
2645
},
2746
"devDependencies": {
2847
"@cloudflare/workers-types": "^4.20230518.0",
2948
"react-router": "workspace:*",
30-
"typescript": "^5.1.0"
49+
"tsup": "^8.3.0",
50+
"typescript": "^5.1.6",
51+
"wireit": "0.14.9"
3152
},
3253
"peerDependencies": {
3354
"@cloudflare/workers-types": "^4.0.0",
3455
"react-router": "workspace:^",
56+
"tsup": "^8.3.0",
3557
"typescript": "^5.1.0"
3658
},
3759
"peerDependenciesMeta": {

packages/react-router-cloudflare/rollup.config.js

-55
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from "tsup";
2+
3+
// @ts-ignore - out of scope
4+
import { createBanner } from "../../build.utils.js";
5+
6+
import pkg from "./package.json";
7+
8+
const entry = ["index.ts"];
9+
10+
export default defineConfig([
11+
{
12+
clean: true,
13+
entry,
14+
format: ["cjs", "esm"],
15+
outDir: "dist",
16+
dts: true,
17+
banner: {
18+
js: createBanner(pkg.name, pkg.version),
19+
},
20+
},
21+
]);

0 commit comments

Comments
 (0)