@react-router/dev 0.0.0-experimental-c0856287f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +1773 -0
  2. package/LICENSE.md +23 -0
  3. package/README.md +13 -0
  4. package/dist/cli/commands.d.ts +12 -0
  5. package/dist/cli/commands.js +174 -0
  6. package/dist/cli/detectPackageManager.d.ts +10 -0
  7. package/dist/cli/detectPackageManager.js +39 -0
  8. package/dist/cli/index.d.ts +1 -0
  9. package/dist/cli/index.js +19 -0
  10. package/dist/cli/run.d.ts +5 -0
  11. package/dist/cli/run.js +180 -0
  12. package/dist/cli/useJavascript.d.ts +4 -0
  13. package/dist/cli/useJavascript.js +66 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.js +21 -0
  16. package/dist/colors.d.ts +17 -0
  17. package/dist/colors.js +49 -0
  18. package/dist/config/defaults/entry.client.tsx +12 -0
  19. package/dist/config/defaults/entry.dev.d.ts +2 -0
  20. package/dist/config/defaults/entry.dev.ts +13 -0
  21. package/dist/config/defaults/entry.server.cloudflare.tsx +55 -0
  22. package/dist/config/defaults/entry.server.deno.tsx +55 -0
  23. package/dist/config/defaults/entry.server.node.tsx +155 -0
  24. package/dist/config/defaults/entry.server.spa.tsx +20 -0
  25. package/dist/config/flat-routes.d.ts +14 -0
  26. package/dist/config/flat-routes.js +418 -0
  27. package/dist/config/format.d.ts +5 -0
  28. package/dist/config/format.js +68 -0
  29. package/dist/config/routes.d.ts +98 -0
  30. package/dist/config/routes.js +93 -0
  31. package/dist/config/serverModes.d.ts +9 -0
  32. package/dist/config/serverModes.js +28 -0
  33. package/dist/config.d.ts +75 -0
  34. package/dist/config.js +152 -0
  35. package/dist/index.d.ts +4 -0
  36. package/dist/index.js +23 -0
  37. package/dist/invariant.d.ts +2 -0
  38. package/dist/invariant.js +22 -0
  39. package/dist/manifest.d.ts +28 -0
  40. package/dist/vite/babel.d.ts +20 -0
  41. package/dist/vite/babel.js +49 -0
  42. package/dist/vite/build.d.ts +15 -0
  43. package/dist/vite/build.js +271 -0
  44. package/dist/vite/cloudflare-proxy-plugin.d.ts +15 -0
  45. package/dist/vite/cloudflare-proxy-plugin.js +82 -0
  46. package/dist/vite/dev.d.ts +15 -0
  47. package/dist/vite/dev.js +81 -0
  48. package/dist/vite/import-vite-esm-sync.d.ts +4 -0
  49. package/dist/vite/import-vite-esm-sync.js +28 -0
  50. package/dist/vite/index.d.ts +4 -0
  51. package/dist/vite/index.js +30 -0
  52. package/dist/vite/node-adapter.d.ts +6 -0
  53. package/dist/vite/node-adapter.js +78 -0
  54. package/dist/vite/plugin.d.ts +165 -0
  55. package/dist/vite/plugin.js +1178 -0
  56. package/dist/vite/profiler.d.ts +5 -0
  57. package/dist/vite/profiler.js +55 -0
  58. package/dist/vite/remove-exports-test.d.ts +1 -0
  59. package/dist/vite/remove-exports.d.ts +2 -0
  60. package/dist/vite/remove-exports.js +278 -0
  61. package/dist/vite/resolve-file-url.d.ts +3 -0
  62. package/dist/vite/resolve-file-url.js +53 -0
  63. package/dist/vite/static/refresh-utils.cjs +185 -0
  64. package/dist/vite/styles.d.ts +13 -0
  65. package/dist/vite/styles.js +176 -0
  66. package/dist/vite/vmod.d.ts +3 -0
  67. package/dist/vite/vmod.js +21 -0
  68. package/package.json +107 -0
package/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) React Training LLC 2015-2019
4
+ Copyright (c) Remix Software Inc. 2020-2021
5
+ Copyright (c) Shopify Inc. 2022-2023
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Welcome to Remix!
2
+
3
+ [Remix](https://remix.run) is a web framework that helps you build better websites with React.
4
+
5
+ To get started, open a new shell and run:
6
+
7
+ ```sh
8
+ npx create-remix@latest
9
+ ```
10
+
11
+ Then follow the prompts you see in your terminal.
12
+
13
+ For more information about Remix, [visit remix.run](https://remix.run)!
@@ -0,0 +1,12 @@
1
+ import type { ViteDevOptions } from "../vite/dev";
2
+ import type { ViteBuildOptions } from "../vite/build";
3
+ export declare function routes(reactRouterRoot?: string, flags?: {
4
+ config?: string;
5
+ json?: boolean;
6
+ }): Promise<void>;
7
+ export declare function build(root?: string, options?: ViteBuildOptions): Promise<void>;
8
+ export declare function dev(root: string, options?: ViteDevOptions): Promise<void>;
9
+ export declare function generateEntry(entry: string, reactRouterRoot: string, flags?: {
10
+ typescript?: boolean;
11
+ config?: string;
12
+ }): Promise<void>;
@@ -0,0 +1,174 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var path = require('node:path');
16
+ var fse = require('fs-extra');
17
+ var PackageJson = require('@npmcli/package-json');
18
+ var exitHook = require('exit-hook');
19
+ var colors = require('../colors.js');
20
+ var format = require('../config/format.js');
21
+ var plugin = require('../vite/plugin.js');
22
+ var useJavascript = require('./useJavascript.js');
23
+ var profiler = require('../vite/profiler.js');
24
+
25
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
+
27
+ function _interopNamespace(e) {
28
+ if (e && e.__esModule) return e;
29
+ var n = Object.create(null);
30
+ if (e) {
31
+ Object.keys(e).forEach(function (k) {
32
+ if (k !== 'default') {
33
+ var d = Object.getOwnPropertyDescriptor(e, k);
34
+ Object.defineProperty(n, k, d.get ? d : {
35
+ enumerable: true,
36
+ get: function () { return e[k]; }
37
+ });
38
+ }
39
+ });
40
+ }
41
+ n["default"] = e;
42
+ return Object.freeze(n);
43
+ }
44
+
45
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
46
+ var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
47
+ var PackageJson__default = /*#__PURE__*/_interopDefaultLegacy(PackageJson);
48
+ var exitHook__default = /*#__PURE__*/_interopDefaultLegacy(exitHook);
49
+
50
+ async function routes(reactRouterRoot, flags = {}) {
51
+ let ctx = await plugin.loadPluginContext({
52
+ root: reactRouterRoot,
53
+ configFile: flags.config
54
+ });
55
+ if (!ctx) {
56
+ console.error(colors.red("React Router Vite plugin not found in Vite config"));
57
+ process.exit(1);
58
+ }
59
+ let format$1 = flags.json ? "json" : "jsx";
60
+ console.log(format.formatRoutes(ctx.reactRouterConfig.routes, format$1));
61
+ }
62
+ async function build(root, options = {}) {
63
+ if (!root) {
64
+ root = process.env.REACT_ROUTER_ROOT || process.cwd();
65
+ }
66
+ let {
67
+ build
68
+ } = await import('../vite/build.js');
69
+ if (options.profile) {
70
+ await profiler.start();
71
+ }
72
+ try {
73
+ await build(root, options);
74
+ } finally {
75
+ await profiler.stop(console.info);
76
+ }
77
+ }
78
+ async function dev(root, options = {}) {
79
+ let {
80
+ dev
81
+ } = await import('../vite/dev.js');
82
+ if (options.profile) {
83
+ await profiler.start();
84
+ }
85
+ exitHook__default["default"](() => profiler.stop(console.info));
86
+ await dev(root, options);
87
+ // keep `react-router dev` alive by waiting indefinitely
88
+ await new Promise(() => {});
89
+ }
90
+ let clientEntries = ["entry.client.tsx", "entry.client.js", "entry.client.jsx"];
91
+ let serverEntries = ["entry.server.tsx", "entry.server.js", "entry.server.jsx"];
92
+ let entries = ["entry.client", "entry.server"];
93
+ let conjunctionListFormat = new Intl.ListFormat("en", {
94
+ style: "long",
95
+ type: "conjunction"
96
+ });
97
+ let disjunctionListFormat = new Intl.ListFormat("en", {
98
+ style: "long",
99
+ type: "disjunction"
100
+ });
101
+ async function generateEntry(entry, reactRouterRoot, flags = {}) {
102
+ let ctx = await plugin.loadPluginContext({
103
+ root: reactRouterRoot,
104
+ configFile: flags.config
105
+ });
106
+ let rootDirectory = ctx.rootDirectory;
107
+ let appDirectory = ctx.reactRouterConfig.appDirectory;
108
+ // if no entry passed, attempt to create both
109
+ if (!entry) {
110
+ await generateEntry("entry.client", reactRouterRoot, flags);
111
+ await generateEntry("entry.server", reactRouterRoot, flags);
112
+ return;
113
+ }
114
+ if (!entries.includes(entry)) {
115
+ let entriesArray = Array.from(entries);
116
+ let list = conjunctionListFormat.format(entriesArray);
117
+ console.error(colors.error(`Invalid entry file. Valid entry files are ${list}`));
118
+ return;
119
+ }
120
+ let pkgJson = await PackageJson__default["default"].load(rootDirectory);
121
+ let deps = pkgJson.content.dependencies ?? {};
122
+ let serverRuntime = deps["@react-router/deno"] ? "deno" : deps["@react-router/cloudflare"] ? "cloudflare" : deps["@react-router/node"] ? "node" : undefined;
123
+ if (!serverRuntime) {
124
+ let serverRuntimes = ["@react-router/deno", "@react-router/cloudflare", "@react-router/node"];
125
+ let formattedList = disjunctionListFormat.format(serverRuntimes);
126
+ console.error(colors.error(`Could not determine server runtime. Please install one of the following: ${formattedList}`));
127
+ return;
128
+ }
129
+ let defaultsDirectory = path__namespace.resolve(__dirname, "..", "config", "defaults");
130
+ let defaultEntryClient = path__namespace.resolve(defaultsDirectory, "entry.client.tsx");
131
+ let defaultEntryServer = path__namespace.resolve(defaultsDirectory, (ctx === null || ctx === void 0 ? void 0 : ctx.reactRouterConfig.ssr) === false && (ctx === null || ctx === void 0 ? void 0 : ctx.reactRouterConfig.future.unstable_singleFetch) !== true ? `entry.server.spa.tsx` : `entry.server.${serverRuntime}.tsx`);
132
+ let isServerEntry = entry === "entry.server";
133
+ let contents = isServerEntry ? await createServerEntry(rootDirectory, appDirectory, defaultEntryServer) : await createClientEntry(rootDirectory, appDirectory, defaultEntryClient);
134
+ let useTypeScript = flags.typescript ?? true;
135
+ let outputExtension = useTypeScript ? "tsx" : "jsx";
136
+ let outputEntry = `${entry}.${outputExtension}`;
137
+ let outputFile = path__namespace.resolve(appDirectory, outputEntry);
138
+ if (!useTypeScript) {
139
+ let javascript = useJavascript.transpile(contents, {
140
+ cwd: rootDirectory,
141
+ filename: isServerEntry ? defaultEntryServer : defaultEntryClient
142
+ });
143
+ await fse__default["default"].writeFile(outputFile, javascript, "utf-8");
144
+ } else {
145
+ await fse__default["default"].writeFile(outputFile, contents, "utf-8");
146
+ }
147
+ console.log(colors.blue(`Entry file ${entry} created at ${path__namespace.relative(rootDirectory, outputFile)}.`));
148
+ }
149
+ async function checkForEntry(rootDirectory, appDirectory, entries) {
150
+ for (let entry of entries) {
151
+ let entryPath = path__namespace.resolve(appDirectory, entry);
152
+ let exists = await fse__default["default"].pathExists(entryPath);
153
+ if (exists) {
154
+ let relative = path__namespace.relative(rootDirectory, entryPath);
155
+ console.error(colors.error(`Entry file ${relative} already exists.`));
156
+ return process.exit(1);
157
+ }
158
+ }
159
+ }
160
+ async function createServerEntry(rootDirectory, appDirectory, inputFile) {
161
+ await checkForEntry(rootDirectory, appDirectory, serverEntries);
162
+ let contents = await fse__default["default"].readFile(inputFile, "utf-8");
163
+ return contents;
164
+ }
165
+ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
166
+ await checkForEntry(rootDirectory, appDirectory, clientEntries);
167
+ let contents = await fse__default["default"].readFile(inputFile, "utf-8");
168
+ return contents;
169
+ }
170
+
171
+ exports.build = build;
172
+ exports.dev = dev;
173
+ exports.generateEntry = generateEntry;
174
+ exports.routes = routes;
@@ -0,0 +1,10 @@
1
+ type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
2
+ /**
3
+ * Determine which package manager the user prefers.
4
+ *
5
+ * npm, pnpm and Yarn set the user agent environment variable
6
+ * that can be used to determine which package manager ran
7
+ * the command.
8
+ */
9
+ export declare const detectPackageManager: () => PackageManager | undefined;
10
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ /**
16
+ * Determine which package manager the user prefers.
17
+ *
18
+ * npm, pnpm and Yarn set the user agent environment variable
19
+ * that can be used to determine which package manager ran
20
+ * the command.
21
+ */
22
+ const detectPackageManager = () => {
23
+ let {
24
+ npm_config_user_agent
25
+ } = process.env;
26
+ if (!npm_config_user_agent) return undefined;
27
+ try {
28
+ let pkgManager = npm_config_user_agent.split("/")[0];
29
+ if (pkgManager === "npm") return "npm";
30
+ if (pkgManager === "pnpm") return "pnpm";
31
+ if (pkgManager === "yarn") return "yarn";
32
+ if (pkgManager === "bun") return "bun";
33
+ return undefined;
34
+ } catch {
35
+ return undefined;
36
+ }
37
+ };
38
+
39
+ exports.detectPackageManager = detectPackageManager;
@@ -0,0 +1 @@
1
+ export { run } from "./run";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var run = require('./run.js');
16
+
17
+
18
+
19
+ exports.run = run.run;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Programmatic interface for running the react-router CLI with the given command line
3
+ * arguments.
4
+ */
5
+ export declare function run(argv?: string[]): Promise<void>;
@@ -0,0 +1,180 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var arg = require('arg');
16
+ var semver = require('semver');
17
+ var colors = require('../colors.js');
18
+ var commands = require('./commands.js');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ var arg__default = /*#__PURE__*/_interopDefaultLegacy(arg);
23
+ var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
24
+
25
+ const helpText = `
26
+ ${colors.logoBlue("react-router")}
27
+
28
+ ${colors.heading("Usage")}:
29
+ $ react-router build [${colors.arg("projectDir")}]
30
+ $ react-router dev [${colors.arg("projectDir")}]
31
+ $ react-router routes [${colors.arg("projectDir")}]
32
+
33
+ ${colors.heading("Options")}:
34
+ --help, -h Print this help message and exit
35
+ --version, -v Print the CLI version and exit
36
+ --no-color Disable ANSI colors in console output
37
+ \`build\` Options:
38
+ --assetsInlineLimit Static asset base64 inline threshold in bytes (default: 4096) (number)
39
+ --clearScreen Allow/disable clear screen when logging (boolean)
40
+ --config, -c Use specified config file (string)
41
+ --emptyOutDir Force empty outDir when it's outside of root (boolean)
42
+ --logLevel, -l Info | warn | error | silent (string)
43
+ --minify Enable/disable minification, or specify minifier to use (default: "esbuild") (boolean | "terser" | "esbuild")
44
+ --mode, -m Set env mode (string)
45
+ --profile Start built-in Node.js inspector
46
+ --sourcemapClient Output source maps for client build (default: false) (boolean | "inline" | "hidden")
47
+ --sourcemapServer Output source maps for server build (default: false) (boolean | "inline" | "hidden")
48
+ \`dev\` Options:
49
+ --clearScreen Allow/disable clear screen when logging (boolean)
50
+ --config, -c Use specified config file (string)
51
+ --cors Enable CORS (boolean)
52
+ --force Force the optimizer to ignore the cache and re-bundle (boolean)
53
+ --host Specify hostname (string)
54
+ --logLevel, -l Info | warn | error | silent (string)
55
+ --mode, -m Set env mode (string)
56
+ --open Open browser on startup (boolean | string)
57
+ --port Specify port (number)
58
+ --profile Start built-in Node.js inspector
59
+ --strictPort Exit if specified port is already in use (boolean)
60
+ \`routes\` Options:
61
+ --config, -c Use specified Vite config file (string)
62
+ --json Print the routes as JSON
63
+ \`reveal\` Options:
64
+ --config, -c Use specified Vite config file (string)
65
+ --no-typescript Generate plain JavaScript files
66
+
67
+ ${colors.heading("Build your project")}:
68
+
69
+ $ react-router build
70
+
71
+ ${colors.heading("Run your project locally in development")}:
72
+
73
+ $ react-router dev
74
+
75
+ ${colors.heading("Show all routes in your app")}:
76
+
77
+ $ react-router routes
78
+ $ react-router routes my-app
79
+ $ react-router routes --json
80
+ $ react-router routes --config vite.react-router.config.ts
81
+
82
+ ${colors.heading("Reveal the used entry point")}:
83
+
84
+ $ react-router reveal entry.client
85
+ $ react-router reveal entry.server
86
+ $ react-router reveal entry.client --no-typescript
87
+ $ react-router reveal entry.server --no-typescript
88
+ $ react-router reveal entry.server --config vite.react-router.config.ts
89
+ `;
90
+ /**
91
+ * Programmatic interface for running the react-router CLI with the given command line
92
+ * arguments.
93
+ */
94
+ async function run(argv = process.argv.slice(2)) {
95
+ // Check the node version
96
+ let versions = process.versions;
97
+ if (versions && versions.node && semver__default["default"].major(versions.node) < 18) {
98
+ throw new Error(`️🚨 Oops, Node v${versions.node} detected. react-router requires a Node version greater than 18.`);
99
+ }
100
+ let isBooleanFlag = arg => {
101
+ let index = argv.indexOf(arg);
102
+ let nextArg = argv[index + 1];
103
+ return !nextArg || nextArg.startsWith("-");
104
+ };
105
+ let args = arg__default["default"]({
106
+ "--force": Boolean,
107
+ "--help": Boolean,
108
+ "-h": "--help",
109
+ "--json": Boolean,
110
+ "--token": String,
111
+ "--typescript": Boolean,
112
+ "--no-typescript": Boolean,
113
+ "--version": Boolean,
114
+ "-v": "--version",
115
+ "--port": Number,
116
+ "-p": "--port",
117
+ "--config": String,
118
+ "-c": "--config",
119
+ "--assetsInlineLimit": Number,
120
+ "--clearScreen": Boolean,
121
+ "--cors": Boolean,
122
+ "--emptyOutDir": Boolean,
123
+ "--host": isBooleanFlag("--host") ? Boolean : String,
124
+ "--logLevel": String,
125
+ "-l": "--logLevel",
126
+ "--minify": String,
127
+ "--mode": String,
128
+ "-m": "--mode",
129
+ "--open": isBooleanFlag("--open") ? Boolean : String,
130
+ "--strictPort": Boolean,
131
+ "--profile": Boolean,
132
+ "--sourcemapClient": isBooleanFlag("--sourcemapClient") ? Boolean : String,
133
+ "--sourcemapServer": isBooleanFlag("--sourcemapServer") ? Boolean : String
134
+ }, {
135
+ argv
136
+ });
137
+ let input = args._;
138
+ let flags = Object.entries(args).reduce((acc, [key, value]) => {
139
+ key = key.replace(/^--/, "");
140
+ acc[key] = value;
141
+ return acc;
142
+ }, {});
143
+ if (flags.help) {
144
+ console.log(helpText);
145
+ return;
146
+ }
147
+ if (flags.version) {
148
+ let version = require("../package.json").version;
149
+ console.log(version);
150
+ return;
151
+ }
152
+ flags.interactive = flags.interactive ?? require.main === module;
153
+ if (args["--no-typescript"]) {
154
+ flags.typescript = false;
155
+ }
156
+ let command = input[0];
157
+ // Note: Keep each case in this switch statement small.
158
+ switch (command) {
159
+ case "routes":
160
+ await commands.routes(input[1], flags);
161
+ break;
162
+ case "build":
163
+ await commands.build(input[1], flags);
164
+ break;
165
+ case "reveal":
166
+ {
167
+ // TODO: simplify getting started guide
168
+ await commands.generateEntry(input[1], input[2], flags);
169
+ break;
170
+ }
171
+ case "dev":
172
+ await commands.dev(input[1], flags);
173
+ break;
174
+ default:
175
+ // `react-router ./my-project` is shorthand for `react-router dev ./my-project`
176
+ await commands.dev(input[0], flags);
177
+ }
178
+ }
179
+
180
+ exports.run = run;
@@ -0,0 +1,4 @@
1
+ export declare function transpile(tsx: string, options?: {
2
+ cwd?: string;
3
+ filename?: string;
4
+ }): string;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var babel = require('@babel/core');
16
+ var babelPluginSyntaxJSX = require('@babel/plugin-syntax-jsx');
17
+ var babelPresetTypeScript = require('@babel/preset-typescript');
18
+ var prettier = require('prettier');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ function _interopNamespace(e) {
23
+ if (e && e.__esModule) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n["default"] = e;
37
+ return Object.freeze(n);
38
+ }
39
+
40
+ var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
41
+ var babelPluginSyntaxJSX__default = /*#__PURE__*/_interopDefaultLegacy(babelPluginSyntaxJSX);
42
+ var babelPresetTypeScript__default = /*#__PURE__*/_interopDefaultLegacy(babelPresetTypeScript);
43
+ var prettier__default = /*#__PURE__*/_interopDefaultLegacy(prettier);
44
+
45
+ function transpile(tsx, options = {}) {
46
+ let mjs = babel__namespace.transformSync(tsx, {
47
+ compact: false,
48
+ cwd: options.cwd,
49
+ filename: options.filename,
50
+ plugins: [babelPluginSyntaxJSX__default["default"]],
51
+ presets: [[babelPresetTypeScript__default["default"], {
52
+ jsx: "preserve"
53
+ }]],
54
+ retainLines: true
55
+ });
56
+ if (!mjs || !mjs.code) throw new Error("Could not parse TypeScript");
57
+ /**
58
+ * Babel's `compact` and `retainLines` options are both bad at formatting code.
59
+ * Use Prettier for nicer formatting.
60
+ */
61
+ return prettier__default["default"].format(mjs.code, {
62
+ parser: "babel"
63
+ });
64
+ }
65
+
66
+ exports.transpile = transpile;
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @react-router/dev v0.0.0-experimental-c0856287f
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
+ 'use strict';
13
+
14
+ var index = require('./index');
15
+
16
+ index.cli.run().then(() => {
17
+ process.exit(0);
18
+ }, error => {
19
+ if (error) console.error(error);
20
+ process.exit(1);
21
+ });
@@ -0,0 +1,17 @@
1
+ import chalk from "chalk";
2
+ export declare const heading: chalk.Chalk | (<T>(x: T) => T);
3
+ export declare const arg: chalk.Chalk | (<T>(x: T) => T);
4
+ export declare const error: chalk.Chalk | (<T>(x: T) => T);
5
+ export declare const warning: chalk.Chalk | (<T>(x: T) => T);
6
+ export declare const hint: chalk.Chalk | (<T>(x: T) => T);
7
+ export declare const logoBlue: chalk.Chalk | (<T>(x: T) => T);
8
+ export declare const logoGreen: chalk.Chalk | (<T>(x: T) => T);
9
+ export declare const logoYellow: chalk.Chalk | (<T>(x: T) => T);
10
+ export declare const logoPink: chalk.Chalk | (<T>(x: T) => T);
11
+ export declare const logoRed: chalk.Chalk | (<T>(x: T) => T);
12
+ export declare const bold: chalk.Chalk | (<T>(x: T) => T);
13
+ export declare const blue: chalk.Chalk | (<T>(x: T) => T);
14
+ export declare const cyan: chalk.Chalk | (<T>(x: T) => T);
15
+ export declare const gray: chalk.Chalk | (<T>(x: T) => T);
16
+ export declare const red: chalk.Chalk | (<T>(x: T) => T);
17
+ export declare const yellow: chalk.Chalk | (<T>(x: T) => T);
package/dist/colors.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-c0856287f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var chalk = require('chalk');
16
+
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
20
+
21
+ // https://no-color.org/
22
+ const useColor = chalk__default["default"].supportsColor && !process.env.NO_COLOR;
23
+ const identity = x => x;
24
+ const safe = style => useColor ? style : identity;
25
+ const heading = safe(chalk__default["default"].underline);
26
+ const arg = safe(chalk__default["default"].yellowBright);
27
+ const error = safe(chalk__default["default"].red);
28
+ safe(chalk__default["default"].yellow);
29
+ safe(chalk__default["default"].blue);
30
+ const logoBlue = safe(chalk__default["default"].blueBright);
31
+ safe(chalk__default["default"].greenBright);
32
+ safe(chalk__default["default"].yellowBright);
33
+ safe(chalk__default["default"].magentaBright);
34
+ safe(chalk__default["default"].redBright);
35
+ // raw styles
36
+ safe(chalk__default["default"].bold);
37
+ // raw colors
38
+ const blue = safe(chalk__default["default"].blue);
39
+ safe(chalk__default["default"].cyan);
40
+ safe(chalk__default["default"].gray);
41
+ const red = safe(chalk__default["default"].red);
42
+ safe(chalk__default["default"].yellow);
43
+
44
+ exports.arg = arg;
45
+ exports.blue = blue;
46
+ exports.error = error;
47
+ exports.heading = heading;
48
+ exports.logoBlue = logoBlue;
49
+ exports.red = red;
@@ -0,0 +1,12 @@
1
+ import { startTransition, StrictMode } from "react";
2
+ import { hydrateRoot } from "react-dom/client";
3
+ import { HydratedRouter } from "react-router";
4
+
5
+ startTransition(() => {
6
+ hydrateRoot(
7
+ document,
8
+ <StrictMode>
9
+ <HydratedRouter />
10
+ </StrictMode>
11
+ );
12
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => void;
2
+ export default _default;