@react-router/dev 0.0.0-experimental-49eef6a01 → 0.0.0-experimental-a26b992a1
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.
- package/bin.js +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/detectPackageManager.js +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -6
- package/dist/cli/run.js +1 -1
- package/dist/cli/useJavascript.js +1 -1
- package/dist/colors.js +1 -1
- package/dist/config/defaults/entry.client.tsx +1 -1
- package/dist/config/format.js +1 -1
- package/dist/config/routes.d.ts +77 -50
- package/dist/config/routes.js +175 -43
- package/dist/invariant.js +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +23 -0
- package/dist/vite/babel.d.ts +10 -10
- package/dist/vite/babel.js +1 -1
- package/dist/vite/build.js +2 -2
- package/dist/vite/cloudflare-dev-proxy.d.ts +7 -1
- package/dist/vite/cloudflare-dev-proxy.js +23 -7
- package/dist/vite/cloudflare.d.ts +1 -0
- package/dist/vite/cloudflare.js +19 -0
- package/dist/vite/combine-urls.d.ts +1 -0
- package/dist/vite/combine-urls.js +20 -0
- package/dist/{config.d.ts → vite/config.d.ts} +15 -27
- package/dist/{config.js → vite/config.js} +62 -45
- package/dist/vite/dev.js +1 -1
- package/dist/vite/import-vite-esm-sync.js +1 -1
- package/dist/vite/node-adapter.js +1 -1
- package/dist/vite/plugin.d.ts +6 -3
- package/dist/vite/plugin.js +145 -121
- package/dist/vite/profiler.js +1 -1
- package/dist/vite/remove-exports.d.ts +2 -2
- package/dist/vite/remove-exports.js +113 -243
- package/dist/vite/resolve-file-url.js +1 -1
- package/dist/vite/static/refresh-utils.cjs +7 -26
- package/dist/vite/styles.d.ts +3 -2
- package/dist/vite/styles.js +23 -2
- package/dist/vite/vmod.js +1 -1
- package/dist/vite/with-props.d.ts +4 -0
- package/dist/vite/with-props.js +151 -0
- package/dist/vite.d.ts +2 -0
- package/dist/{cli.js → vite.js} +7 -8
- package/package.json +21 -12
- package/dist/config/findConfig.d.ts +0 -1
- package/dist/config/findConfig.js +0 -32
- package/dist/config/flatRoutes.d.ts +0 -14
- package/dist/config/flatRoutes.js +0 -418
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -23
- package/dist/vite/define-route.d.ts +0 -5
- package/dist/vite/define-route.js +0 -207
- package/dist/vite/index.d.ts +0 -3
- package/dist/vite/index.js +0 -31
- /package/dist/{cli.d.ts → vite/combine-urls-test.d.ts} +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-49eef6a01
|
|
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$1 = require('@babel/core');
|
|
16
|
-
var babelDeadCodeElimination = require('babel-dead-code-elimination');
|
|
17
|
-
var babel = require('./babel.js');
|
|
18
|
-
var t = require('@babel/types');
|
|
19
|
-
var parser = require('@babel/parser');
|
|
20
|
-
|
|
21
|
-
function _interopNamespace(e) {
|
|
22
|
-
if (e && e.__esModule) return e;
|
|
23
|
-
var n = Object.create(null);
|
|
24
|
-
if (e) {
|
|
25
|
-
Object.keys(e).forEach(function (k) {
|
|
26
|
-
if (k !== 'default') {
|
|
27
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () { return e[k]; }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
n["default"] = e;
|
|
36
|
-
return Object.freeze(n);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var babel__namespace = /*#__PURE__*/_interopNamespace(babel$1);
|
|
40
|
-
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
41
|
-
|
|
42
|
-
function transform(code, id, options = {}) {
|
|
43
|
-
if (options !== null && options !== void 0 && options.ssr) return code;
|
|
44
|
-
let ast = parse(code);
|
|
45
|
-
let refs = babelDeadCodeElimination.findReferencedIdentifiers(ast);
|
|
46
|
-
let markedForRemoval = [];
|
|
47
|
-
assertDefineRouteOnlyAfterExportDefault(ast);
|
|
48
|
-
babel.traverse(ast, {
|
|
49
|
-
ExportDefaultDeclaration(path) {
|
|
50
|
-
let analysis = analyzeRouteExport(path);
|
|
51
|
-
for (let [key, fieldPath] of Object.entries(analysis)) {
|
|
52
|
-
if (["headers", "serverLoader", "serverAction"].includes(key)) {
|
|
53
|
-
if (!fieldPath) continue;
|
|
54
|
-
markedForRemoval.push(fieldPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
markedForRemoval.forEach(path => path.remove());
|
|
60
|
-
babelDeadCodeElimination.deadCodeElimination(ast, refs);
|
|
61
|
-
return babel.generate(ast, {
|
|
62
|
-
sourceMaps: true,
|
|
63
|
-
sourceFileName: id
|
|
64
|
-
}, code);
|
|
65
|
-
}
|
|
66
|
-
function parseFields(code) {
|
|
67
|
-
let fields = [];
|
|
68
|
-
let ast = parse(code);
|
|
69
|
-
assertDefineRouteOnlyAfterExportDefault(ast);
|
|
70
|
-
babel.traverse(ast, {
|
|
71
|
-
ExportDefaultDeclaration(path) {
|
|
72
|
-
let analysis = analyzeRouteExport(path);
|
|
73
|
-
fields = Object.keys(analysis);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return fields;
|
|
77
|
-
}
|
|
78
|
-
function analyzeRouteExport(path) {
|
|
79
|
-
let route = path.node.declaration;
|
|
80
|
-
// export default {...}
|
|
81
|
-
if (t__namespace.isObjectExpression(route)) {
|
|
82
|
-
let routePath = path.get("declaration");
|
|
83
|
-
return analyzeRoute(routePath);
|
|
84
|
-
}
|
|
85
|
-
// export default defineRoute({...})
|
|
86
|
-
if (t__namespace.isCallExpression(route)) {
|
|
87
|
-
let routePath = path.get("declaration");
|
|
88
|
-
if (!isDefineRoute(routePath.get("callee"))) {
|
|
89
|
-
throw routePath.buildCodeFrameError("Default export of a route module must be either a literal object or a call to `defineRoute`");
|
|
90
|
-
}
|
|
91
|
-
if (routePath.node.arguments.length !== 1) {
|
|
92
|
-
throw routePath.buildCodeFrameError("`defineRoute` must take exactly one argument");
|
|
93
|
-
}
|
|
94
|
-
let arg = routePath.node.arguments[0];
|
|
95
|
-
let argPath = routePath.get("arguments.0");
|
|
96
|
-
if (!t__namespace.isObjectExpression(arg)) {
|
|
97
|
-
throw argPath.buildCodeFrameError("`defineRoute` argument must be a literal object");
|
|
98
|
-
}
|
|
99
|
-
return analyzeRoute(argPath);
|
|
100
|
-
}
|
|
101
|
-
throw path.get("declaration").buildCodeFrameError("Default export of a route module must be either a literal object or a call to `defineRoute`");
|
|
102
|
-
}
|
|
103
|
-
function analyzeRoute(path) {
|
|
104
|
-
let analysis = {};
|
|
105
|
-
for (let [i, property] of path.node.properties.entries()) {
|
|
106
|
-
// spread: defineRoute({ ...dynamic })
|
|
107
|
-
if (!t__namespace.isObjectProperty(property) && !t__namespace.isObjectMethod(property)) {
|
|
108
|
-
let propertyPath = path.get(`properties.${i}`);
|
|
109
|
-
throw propertyPath.buildCodeFrameError("Properties cannot be spread into route");
|
|
110
|
-
}
|
|
111
|
-
// defineRoute({ [dynamic]: ... })
|
|
112
|
-
let propertyPath = path.get(`properties.${i}`);
|
|
113
|
-
if (property.computed || !t__namespace.isIdentifier(property.key)) {
|
|
114
|
-
throw propertyPath.buildCodeFrameError("Route cannot have computed keys");
|
|
115
|
-
}
|
|
116
|
-
// defineRoute({ params: [...] })
|
|
117
|
-
let key = property.key.name;
|
|
118
|
-
if (key === "params") {
|
|
119
|
-
let paramsPath = propertyPath;
|
|
120
|
-
if (t__namespace.isObjectMethod(paramsPath.node)) {
|
|
121
|
-
throw paramsPath.buildCodeFrameError("Route params must be a literal array");
|
|
122
|
-
}
|
|
123
|
-
if (!t__namespace.isArrayExpression(paramsPath.node.value)) {
|
|
124
|
-
throw paramsPath.buildCodeFrameError("Route params must be a literal array");
|
|
125
|
-
}
|
|
126
|
-
for (let [i, element] of paramsPath.node.value.elements.entries()) {
|
|
127
|
-
if (!t__namespace.isStringLiteral(element)) {
|
|
128
|
-
let elementPath = paramsPath.get(`value.elements.${i}`);
|
|
129
|
-
throw elementPath.buildCodeFrameError("Route param must be a literal string");
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
analysis[key] = propertyPath;
|
|
134
|
-
}
|
|
135
|
-
return analysis;
|
|
136
|
-
}
|
|
137
|
-
function assertNotImported(code) {
|
|
138
|
-
let ast = parse(code);
|
|
139
|
-
babel.traverse(ast, {
|
|
140
|
-
Identifier(path) {
|
|
141
|
-
if (isDefineRoute(path)) {
|
|
142
|
-
throw path.buildCodeFrameError("`defineRoute` cannot be used outside of route modules");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function parse(source) {
|
|
148
|
-
let ast = parser.parse(source, {
|
|
149
|
-
sourceType: "module",
|
|
150
|
-
plugins: ["jsx", ["typescript", {}]]
|
|
151
|
-
});
|
|
152
|
-
// Workaround for `path.buildCodeFrameError`
|
|
153
|
-
// See:
|
|
154
|
-
// - https://github.com/babel/babel/issues/11889
|
|
155
|
-
// - https://github.com/babel/babel/issues/11350#issuecomment-606169054
|
|
156
|
-
// @ts-expect-error `@types/babel__core` is missing types for `File`
|
|
157
|
-
new babel__namespace.File({
|
|
158
|
-
filename: undefined
|
|
159
|
-
}, {
|
|
160
|
-
code: source,
|
|
161
|
-
ast
|
|
162
|
-
});
|
|
163
|
-
return ast;
|
|
164
|
-
}
|
|
165
|
-
function assertDefineRouteOnlyAfterExportDefault(ast) {
|
|
166
|
-
babel.traverse(ast, {
|
|
167
|
-
Identifier(path) {
|
|
168
|
-
if (!isDefineRoute(path)) return;
|
|
169
|
-
if (t__namespace.isImportSpecifier(path.parent)) return;
|
|
170
|
-
if (!t__namespace.isCallExpression(path.parent)) {
|
|
171
|
-
throw path.buildCodeFrameError("`defineRoute` must be a function call immediately after `export default`");
|
|
172
|
-
}
|
|
173
|
-
if (!t__namespace.isExportDefaultDeclaration(path.parentPath.parent)) {
|
|
174
|
-
throw path.buildCodeFrameError("`defineRoute` must be a function call immediately after `export default`");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function isDefineRoute(path) {
|
|
180
|
-
if (!t__namespace.isIdentifier(path.node)) return false;
|
|
181
|
-
let binding = path.scope.getBinding(path.node.name);
|
|
182
|
-
if (!binding) return false;
|
|
183
|
-
return isCanonicallyImportedAs(binding, {
|
|
184
|
-
imported: "defineRoute",
|
|
185
|
-
source: "react-router"
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function isCanonicallyImportedAs(binding, {
|
|
189
|
-
source: sourceName,
|
|
190
|
-
imported: importedName
|
|
191
|
-
}) {
|
|
192
|
-
// import source
|
|
193
|
-
if (!t__namespace.isImportDeclaration(binding === null || binding === void 0 ? void 0 : binding.path.parent)) return false;
|
|
194
|
-
if (binding.path.parent.source.value !== sourceName) return false;
|
|
195
|
-
// import specifier
|
|
196
|
-
if (!t__namespace.isImportSpecifier(binding === null || binding === void 0 ? void 0 : binding.path.node)) return false;
|
|
197
|
-
let {
|
|
198
|
-
imported
|
|
199
|
-
} = binding.path.node;
|
|
200
|
-
if (!t__namespace.isIdentifier(imported)) return false;
|
|
201
|
-
if (imported.name !== importedName) return false;
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
exports.assertNotImported = assertNotImported;
|
|
206
|
-
exports.parseFields = parseFields;
|
|
207
|
-
exports.transform = transform;
|
package/dist/vite/index.d.ts
DELETED
package/dist/vite/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-49eef6a01
|
|
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
|
-
require('react-router');
|
|
16
|
-
require('wrangler');
|
|
17
|
-
require('node:events');
|
|
18
|
-
require('node:stream');
|
|
19
|
-
require('set-cookie-parser');
|
|
20
|
-
require('@react-router/node');
|
|
21
|
-
|
|
22
|
-
const vitePlugin = (...args) => {
|
|
23
|
-
let {
|
|
24
|
-
reactRouterVitePlugin
|
|
25
|
-
} =
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
27
|
-
require("./plugin");
|
|
28
|
-
return reactRouterVitePlugin(...args);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.vitePlugin = vitePlugin;
|
|
File without changes
|