Skip to content

Commit e0a67ed

Browse files
committed
chore: re-enable development warnings
1 parent da617bb commit e0a67ed

File tree

6 files changed

+72
-52
lines changed

6 files changed

+72
-52
lines changed

jest/jest.config.shared.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ module.exports = {
2424
"\\.[jt]sx?$": require.resolve("./transform"),
2525
},
2626
watchPathIgnorePatterns: [...ignorePatterns, "\\/node_modules\\/"],
27+
globals: {
28+
__DEV__: true,
29+
},
2730
};

packages/react-router-dev/vite/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = (_config) => {
858858
"react-router/dom",
859859
"react-router-dom",
860860
],
861+
conditions: viteCommand === "build" ? [] : ["development"],
861862
},
862863
base: viteUserConfig.base,
863864

packages/react-router/lib/components.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ import {
6262
import type { ViewTransition } from "./dom/global";
6363
import { warnOnce } from "./server-runtime/warnings";
6464

65-
// TODO: Let's get this back to using an import map and development/production
66-
// condition once we get the rollup build replaced
67-
const ENABLE_DEV_WARNINGS = true;
65+
// Provided by the build system
66+
declare const __DEV__: boolean;
67+
const ENABLE_DEV_WARNINGS = __DEV__;
6868

6969
/**
7070
* @private

packages/react-router/lib/hooks.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ import {
5050
} from "./router/utils";
5151
import type { SerializeFrom } from "./types";
5252

53-
// TODO: Let's get this back to using an import map and development/production
54-
// condition once we get the rollup build replaced
55-
const ENABLE_DEV_WARNINGS = true;
53+
// Provided by the build system
54+
declare const __DEV__: boolean;
55+
const ENABLE_DEV_WARNINGS = __DEV__;
5656

5757
/**
5858
Resolves a URL against the current location.

packages/react-router/package.json

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,53 @@
1818
"license": "MIT",
1919
"author": "Remix Software <[email protected]>",
2020
"sideEffects": false,
21-
"types": "./dist/index.d.ts",
22-
"main": "./dist/index.js",
23-
"unpkg": "./dist/umd/react-router.production.min.js",
24-
"module": "./dist/index.mjs",
21+
"types": "./dist/production/index.d.ts",
22+
"main": "./dist/production/index.js",
23+
"module": "./dist/production/index.mjs",
2524
"exports": {
2625
".": {
2726
"node": {
28-
"types": "./dist/index.d.ts",
29-
"module-sync": "./dist/index.mjs",
30-
"default": "./dist/index.js"
27+
"types": "./dist/production/index.d.ts",
28+
"development": {
29+
"module-sync": "./dist/development/index.mjs",
30+
"default": "./dist/development/index.js"
31+
},
32+
"module-sync": "./dist/production/index.mjs",
33+
"default": "./dist/production/index.js"
3134
},
3235
"import": {
33-
"types": "./dist/index.d.mts",
34-
"default": "./dist/index.mjs"
36+
"types": "./dist/production/index.d.mts",
37+
"development": "./dist/development/index.mjs",
38+
"default": "./dist/production/index.mjs"
3539
},
3640
"default": {
37-
"types": "./dist/index.d.ts",
38-
"default": "./dist/index.js"
41+
"types": "./dist/production/index.d.ts",
42+
"development": "./dist/development/index.js",
43+
"default": "./dist/production/index.js"
3944
}
4045
},
4146
"./types": {
42-
"types": "./dist/lib/types.d.ts"
47+
"types": "./dist/production/lib/types.d.ts"
4348
},
4449
"./dom": {
4550
"node": {
46-
"types": "./dist/dom-export.d.ts",
47-
"module-sync": "./dist/dom-export.mjs",
48-
"default": "./dist/dom-export.js"
51+
"types": "./dist/production/dom-export.d.ts",
52+
"development": {
53+
"module-sync": "./dist/development/dom-export.mjs",
54+
"default": "./dist/development/dom-export.js"
55+
},
56+
"module-sync": "./dist/production/dom-export.mjs",
57+
"default": "./dist/production/dom-export.js"
4958
},
5059
"import": {
51-
"types": "./dist/dom-export.d.mts",
52-
"default": "./dist/dom-export.mjs"
60+
"types": "./dist/production/dom-export.d.mts",
61+
"development": "./dist/development/dom-export.mjs",
62+
"default": "./dist/production/dom-export.mjs"
5363
},
5464
"default": {
55-
"types": "./dist/dom-export.d.ts",
56-
"default": "./dist/dom-export.js"
65+
"types": "./dist/production/dom-export.d.ts",
66+
"development": "./dist/development/dom-export.js",
67+
"default": "./dist/production/dom-export.js"
5768
}
5869
},
5970
"./package.json": "./package.json"

packages/react-router/tsup.config.ts

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,37 @@ import pkg from "./package.json";
77

88
const entry = ["index.ts", "dom-export.ts", "lib/types.ts"];
99

10-
export default defineConfig([
11-
{
12-
clean: false,
13-
entry,
14-
format: ["cjs"],
15-
outDir: "dist",
16-
dts: true,
17-
banner: {
18-
js: createBanner(pkg.name, pkg.version),
10+
const config = (enableDevWarnings: boolean) =>
11+
defineConfig([
12+
{
13+
clean: false,
14+
entry,
15+
format: ["cjs"],
16+
outDir: enableDevWarnings ? "dist/development" : "dist/production",
17+
dts: true,
18+
banner: {
19+
js: createBanner(pkg.name, pkg.version),
20+
},
21+
define: {
22+
"import.meta.hot": "undefined",
23+
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
24+
__DEV__: JSON.stringify(enableDevWarnings),
25+
},
1926
},
20-
define: {
21-
"import.meta.hot": "undefined",
22-
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
27+
{
28+
clean: false,
29+
entry,
30+
format: ["esm"],
31+
outDir: enableDevWarnings ? "dist/development" : "dist/production",
32+
dts: true,
33+
banner: {
34+
js: createBanner(pkg.name, pkg.version),
35+
},
36+
define: {
37+
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
38+
__DEV__: JSON.stringify(enableDevWarnings),
39+
},
2340
},
24-
},
25-
{
26-
clean: false,
27-
entry,
28-
format: ["esm"],
29-
outDir: "dist",
30-
dts: true,
31-
banner: {
32-
js: createBanner(pkg.name, pkg.version),
33-
},
34-
define: {
35-
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
36-
},
37-
},
38-
]);
41+
]);
42+
43+
export default defineConfig([...config(false), ...config(true)]);

0 commit comments

Comments
 (0)