one 1.15.10 → 1.16.0
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/dist/cjs/cli/build.cjs +98 -58
- package/dist/cjs/cli/build.native.js +106 -63
- package/dist/cjs/cli/build.native.js.map +1 -1
- package/dist/cjs/cli/buildPage.cjs +3 -3
- package/dist/cjs/cli/buildPage.native.js +3 -3
- package/dist/cjs/cli/buildPage.native.js.map +1 -1
- package/dist/cjs/constants.cjs +2 -0
- package/dist/cjs/constants.native.js +2 -0
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/createAPIRoute.native.js.map +1 -1
- package/dist/cjs/createApp.cjs +2 -6
- package/dist/cjs/createHandleRequest.cjs +2 -2
- package/dist/cjs/createHandleRequest.native.js +2 -2
- package/dist/cjs/createHandleRequest.native.js.map +1 -1
- package/dist/cjs/hooks.cjs +5 -1
- package/dist/cjs/hooks.native.js +7 -1
- package/dist/cjs/hooks.native.js.map +1 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +10 -7
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +13 -10
- package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.cjs +23 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js +26 -0
- package/dist/cjs/metro-config/getViteMetroPluginOptions.test.native.js.map +1 -0
- package/dist/cjs/router/Route.cjs +21 -1
- package/dist/cjs/router/Route.native.js +22 -1
- package/dist/cjs/router/Route.native.js.map +1 -1
- package/dist/cjs/router/interceptRoutes.cjs +6 -6
- package/dist/cjs/router/interceptRoutes.native.js +6 -6
- package/dist/cjs/router/interceptRoutes.native.js.map +1 -1
- package/dist/cjs/router/params.cjs +46 -0
- package/dist/cjs/router/params.native.js +70 -0
- package/dist/cjs/router/params.native.js.map +1 -0
- package/dist/cjs/router/useScreens.cjs +3 -0
- package/dist/cjs/router/useScreens.native.js +2 -0
- package/dist/cjs/router/useScreens.native.js.map +1 -1
- package/dist/cjs/serve-worker.native.js.map +1 -1
- package/dist/cjs/server/getServerManifest.cjs +6 -6
- package/dist/cjs/server/getServerManifest.native.js +6 -6
- package/dist/cjs/server/getServerManifest.native.js.map +1 -1
- package/dist/cjs/server/oneServe.cjs +9 -5
- package/dist/cjs/server/oneServe.native.js +9 -5
- package/dist/cjs/server/oneServe.native.js.map +1 -1
- package/dist/cjs/server/workerHandler.cjs +2 -2
- package/dist/cjs/server/workerHandler.native.js +2 -2
- package/dist/cjs/server/workerHandler.native.js.map +1 -1
- package/dist/cjs/skewProtection.cjs +48 -7
- package/dist/cjs/skewProtection.native.js +48 -7
- package/dist/cjs/skewProtection.native.js.map +1 -1
- package/dist/cjs/useLoader.cjs +67 -69
- package/dist/cjs/useLoader.native.js +113 -117
- package/dist/cjs/useLoader.native.js.map +1 -1
- package/dist/cjs/utils/dynamicImport.cjs +3 -1
- package/dist/cjs/utils/dynamicImport.native.js +22 -1
- package/dist/cjs/utils/dynamicImport.native.js.map +1 -1
- package/dist/cjs/utils/toAbsolute.cjs +5 -2
- package/dist/cjs/utils/toAbsolute.native.js +6 -1
- package/dist/cjs/utils/toAbsolute.native.js.map +1 -1
- package/dist/cjs/utils/workerImport.cjs +1 -1
- package/dist/cjs/utils/workerImport.native.js +1 -1
- package/dist/cjs/utils/workerImport.native.js.map +1 -1
- package/dist/cjs/views/RootErrorBoundary.cjs +114 -117
- package/dist/cjs/views/RootErrorBoundary.native.js +126 -146
- package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
- package/dist/cjs/views/Try.cjs +17 -18
- package/dist/cjs/views/Try.native.js +28 -42
- package/dist/cjs/views/Try.native.js.map +1 -1
- package/dist/cjs/vite/plugins/criticalCSSPlugin.cjs +2 -1
- package/dist/cjs/vite/plugins/criticalCSSPlugin.native.js +2 -1
- package/dist/cjs/vite/plugins/criticalCSSPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/criticalCSSPlugin.test.cjs +26 -20
- package/dist/cjs/vite/plugins/criticalCSSPlugin.test.native.js +28 -20
- package/dist/cjs/vite/plugins/criticalCSSPlugin.test.native.js.map +1 -1
- package/dist/cjs/vite/plugins/imageDataPlugin.cjs +3 -2
- package/dist/cjs/vite/plugins/imageDataPlugin.native.js +3 -2
- package/dist/cjs/vite/plugins/imageDataPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/imageDataPlugin.test.cjs +34 -69
- package/dist/cjs/vite/plugins/imageDataPlugin.test.native.js +34 -69
- package/dist/cjs/vite/plugins/imageDataPlugin.test.native.js.map +1 -1
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +20 -2
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +23 -2
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.cjs +21 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.native.js +28 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.test.native.js.map +1 -0
- package/dist/cjs/vite/resolveResponse.cjs +7 -2
- package/dist/cjs/vite/resolveResponse.native.js +7 -2
- package/dist/cjs/vite/resolveResponse.native.js.map +1 -1
- package/dist/esm/cli/build.mjs +100 -60
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +108 -65
- package/dist/esm/cli/build.native.js.map +1 -1
- package/dist/esm/cli/buildPage.mjs +4 -4
- package/dist/esm/cli/buildPage.mjs.map +1 -1
- package/dist/esm/cli/buildPage.native.js +4 -4
- package/dist/esm/cli/buildPage.native.js.map +1 -1
- package/dist/esm/constants.mjs +2 -1
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +2 -1
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/createAPIRoute.mjs.map +1 -1
- package/dist/esm/createAPIRoute.native.js.map +1 -1
- package/dist/esm/createApp.mjs +2 -6
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/createHandleRequest.mjs +2 -2
- package/dist/esm/createHandleRequest.mjs.map +1 -1
- package/dist/esm/createHandleRequest.native.js +2 -2
- package/dist/esm/createHandleRequest.native.js.map +1 -1
- package/dist/esm/hooks.mjs +5 -1
- package/dist/esm/hooks.mjs.map +1 -1
- package/dist/esm/hooks.native.js +7 -1
- package/dist/esm/hooks.native.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +9 -7
- package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +12 -10
- package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs +24 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.mjs.map +1 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js +24 -0
- package/dist/esm/metro-config/getViteMetroPluginOptions.test.native.js.map +1 -0
- package/dist/esm/router/Route.mjs +21 -1
- package/dist/esm/router/Route.mjs.map +1 -1
- package/dist/esm/router/Route.native.js +22 -1
- package/dist/esm/router/Route.native.js.map +1 -1
- package/dist/esm/router/interceptRoutes.mjs +7 -7
- package/dist/esm/router/interceptRoutes.mjs.map +1 -1
- package/dist/esm/router/interceptRoutes.native.js +7 -7
- package/dist/esm/router/interceptRoutes.native.js.map +1 -1
- package/dist/esm/router/params.mjs +21 -0
- package/dist/esm/router/params.mjs.map +1 -0
- package/dist/esm/router/params.native.js +42 -0
- package/dist/esm/router/params.native.js.map +1 -0
- package/dist/esm/router/useScreens.mjs +3 -0
- package/dist/esm/router/useScreens.mjs.map +1 -1
- package/dist/esm/router/useScreens.native.js +2 -0
- package/dist/esm/router/useScreens.native.js.map +1 -1
- package/dist/esm/serve-worker.mjs.map +1 -1
- package/dist/esm/serve-worker.native.js.map +1 -1
- package/dist/esm/server/getServerManifest.mjs +6 -6
- package/dist/esm/server/getServerManifest.mjs.map +1 -1
- package/dist/esm/server/getServerManifest.native.js +6 -6
- package/dist/esm/server/getServerManifest.native.js.map +1 -1
- package/dist/esm/server/oneServe.mjs +11 -7
- package/dist/esm/server/oneServe.mjs.map +1 -1
- package/dist/esm/server/oneServe.native.js +11 -7
- package/dist/esm/server/oneServe.native.js.map +1 -1
- package/dist/esm/server/workerHandler.mjs +2 -2
- package/dist/esm/server/workerHandler.mjs.map +1 -1
- package/dist/esm/server/workerHandler.native.js +2 -2
- package/dist/esm/server/workerHandler.native.js.map +1 -1
- package/dist/esm/skewProtection.mjs +48 -8
- package/dist/esm/skewProtection.mjs.map +1 -1
- package/dist/esm/skewProtection.native.js +48 -8
- package/dist/esm/skewProtection.native.js.map +1 -1
- package/dist/esm/useLoader.mjs +64 -66
- package/dist/esm/useLoader.mjs.map +1 -1
- package/dist/esm/useLoader.native.js +112 -116
- package/dist/esm/useLoader.native.js.map +1 -1
- package/dist/esm/utils/dynamicImport.mjs +1 -1
- package/dist/esm/utils/dynamicImport.mjs.map +1 -1
- package/dist/esm/utils/dynamicImport.native.js +20 -1
- package/dist/esm/utils/dynamicImport.native.js.map +1 -1
- package/dist/esm/utils/toAbsolute.mjs +3 -1
- package/dist/esm/utils/toAbsolute.mjs.map +1 -1
- package/dist/esm/utils/toAbsolute.native.js +5 -1
- package/dist/esm/utils/toAbsolute.native.js.map +1 -1
- package/dist/esm/utils/workerImport.mjs +2 -2
- package/dist/esm/utils/workerImport.mjs.map +1 -1
- package/dist/esm/utils/workerImport.native.js +2 -2
- package/dist/esm/utils/workerImport.native.js.map +1 -1
- package/dist/esm/views/RootErrorBoundary.mjs +114 -117
- package/dist/esm/views/RootErrorBoundary.mjs.map +1 -1
- package/dist/esm/views/RootErrorBoundary.native.js +126 -146
- package/dist/esm/views/RootErrorBoundary.native.js.map +1 -1
- package/dist/esm/views/Try.mjs +17 -18
- package/dist/esm/views/Try.mjs.map +1 -1
- package/dist/esm/views/Try.native.js +28 -42
- package/dist/esm/views/Try.native.js.map +1 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.mjs +2 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.native.js +2 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.test.mjs +26 -20
- package/dist/esm/vite/plugins/criticalCSSPlugin.test.mjs.map +1 -1
- package/dist/esm/vite/plugins/criticalCSSPlugin.test.native.js +28 -20
- package/dist/esm/vite/plugins/criticalCSSPlugin.test.native.js.map +1 -1
- package/dist/esm/vite/plugins/imageDataPlugin.mjs +4 -3
- package/dist/esm/vite/plugins/imageDataPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/imageDataPlugin.native.js +4 -3
- package/dist/esm/vite/plugins/imageDataPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/imageDataPlugin.test.mjs +34 -69
- package/dist/esm/vite/plugins/imageDataPlugin.test.mjs.map +1 -1
- package/dist/esm/vite/plugins/imageDataPlugin.test.native.js +34 -69
- package/dist/esm/vite/plugins/imageDataPlugin.test.native.js.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +19 -3
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +22 -3
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.test.mjs +22 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.test.mjs.map +1 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.test.native.js +26 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.test.native.js.map +1 -0
- package/dist/esm/vite/resolveResponse.mjs +7 -2
- package/dist/esm/vite/resolveResponse.mjs.map +1 -1
- package/dist/esm/vite/resolveResponse.native.js +7 -2
- package/dist/esm/vite/resolveResponse.native.js.map +1 -1
- package/expo-plugin.cjs +1 -0
- package/package.json +15 -10
- package/react-native-commands.cjs +1 -0
- package/src/cli/build.ts +156 -99
- package/src/cli/buildPage.ts +4 -4
- package/src/constants.ts +15 -0
- package/src/createAPIRoute.ts +35 -2
- package/src/createApp.tsx +2 -6
- package/src/createHandleRequest.ts +6 -2
- package/src/hooks.tsx +9 -1
- package/src/index.ts +8 -1
- package/src/metro-config/getViteMetroPluginOptions.test.ts +34 -0
- package/src/metro-config/getViteMetroPluginOptions.ts +14 -11
- package/src/router/Route.tsx +52 -2
- package/src/router/interceptRoutes.ts +7 -7
- package/src/router/params.ts +32 -0
- package/src/router/useScreens.tsx +18 -0
- package/src/serve-worker.ts +4 -2
- package/src/server/getServerManifest.ts +11 -7
- package/src/server/oneServe.ts +12 -14
- package/src/server/workerHandler.ts +13 -2
- package/src/skewProtection.ts +45 -5
- package/src/useLoader.ts +6 -4
- package/src/utils/dynamicImport.ts +2 -2
- package/src/utils/toAbsolute.ts +5 -0
- package/src/utils/workerImport.ts +2 -2
- package/src/views/RootErrorBoundary.tsx +18 -0
- package/src/views/Try.tsx +18 -0
- package/src/vite/plugins/criticalCSSPlugin.test.ts +34 -24
- package/src/vite/plugins/criticalCSSPlugin.ts +3 -2
- package/src/vite/plugins/imageDataPlugin.test.ts +39 -83
- package/src/vite/plugins/imageDataPlugin.ts +5 -4
- package/src/vite/plugins/sourceInspectorPlugin.test.ts +40 -0
- package/src/vite/plugins/sourceInspectorPlugin.ts +30 -2
- package/src/vite/resolveResponse.ts +6 -2
- package/types/cli/build.d.ts.map +1 -1
- package/types/constants.d.ts +9 -0
- package/types/constants.d.ts.map +1 -1
- package/types/createAPIRoute.d.ts +28 -3
- package/types/createAPIRoute.d.ts.map +1 -1
- package/types/createApp.d.ts.map +1 -1
- package/types/createHandleRequest.d.ts +1 -1
- package/types/createHandleRequest.d.ts.map +1 -1
- package/types/headless-server.d.ts +1 -1
- package/types/hooks.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/metro-config/getViteMetroPluginOptions.d.ts +5 -0
- package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
- package/types/metro-config/getViteMetroPluginOptions.test.d.ts +2 -0
- package/types/metro-config/getViteMetroPluginOptions.test.d.ts.map +1 -0
- package/types/router/Route.d.ts +1 -0
- package/types/router/Route.d.ts.map +1 -1
- package/types/router/params.d.ts +3 -0
- package/types/router/params.d.ts.map +1 -0
- package/types/router/useScreens.d.ts.map +1 -1
- package/types/serve-worker.d.ts +5 -3
- package/types/serve-worker.d.ts.map +1 -1
- package/types/server/getServerManifest.d.ts.map +1 -1
- package/types/server/oneServe.d.ts.map +1 -1
- package/types/server/workerHandler.d.ts +1 -1
- package/types/server/workerHandler.d.ts.map +1 -1
- package/types/skewProtection.d.ts +1 -0
- package/types/skewProtection.d.ts.map +1 -1
- package/types/useLoader.d.ts.map +1 -1
- package/types/utils/dynamicImport.d.ts +2 -0
- package/types/utils/dynamicImport.d.ts.map +1 -1
- package/types/utils/toAbsolute.d.ts +3 -0
- package/types/utils/toAbsolute.d.ts.map +1 -1
- package/types/views/RootErrorBoundary.d.ts.map +1 -1
- package/types/views/Try.d.ts.map +1 -1
- package/types/vite/plugins/criticalCSSPlugin.d.ts.map +1 -1
- package/types/vite/plugins/imageDataPlugin.d.ts.map +1 -1
- package/types/vite/plugins/sourceInspectorPlugin.d.ts +2 -0
- package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -1
- package/types/vite/plugins/sourceInspectorPlugin.test.d.ts +2 -0
- package/types/vite/plugins/sourceInspectorPlugin.test.d.ts.map +1 -0
- package/types/vite/resolveResponse.d.ts +1 -1
- package/types/vite/resolveResponse.d.ts.map +1 -1
|
@@ -33,10 +33,13 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
33
33
|
}), mod);
|
|
34
34
|
var sourceInspectorPlugin_exports = {};
|
|
35
35
|
__export(sourceInspectorPlugin_exports, {
|
|
36
|
+
getSourceInspectorPath: () => getSourceInspectorPath,
|
|
37
|
+
resolveEditorFilePath: () => resolveEditorFilePath,
|
|
36
38
|
sourceInspectorPlugin: () => sourceInspectorPlugin
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(sourceInspectorPlugin_exports);
|
|
39
41
|
var import_node_child_process = require("node:child_process");
|
|
42
|
+
var import_node_fs = require("node:fs");
|
|
40
43
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
41
44
|
var import_oxc_parser = require("oxc-parser");
|
|
42
45
|
var import_vite = require("vite");
|
|
@@ -95,10 +98,25 @@ async function findJsxElements(code, filename) {
|
|
|
95
98
|
walk(result.program);
|
|
96
99
|
return locations.sort((a, b) => b.insertOffset - a.insertOffset);
|
|
97
100
|
}
|
|
101
|
+
function getSourceInspectorPath(filePath, cwd = process.cwd()) {
|
|
102
|
+
const normalizedFilePath = (0, import_vite.normalizePath)(filePath);
|
|
103
|
+
const normalizedCwd = (0, import_vite.normalizePath)(cwd);
|
|
104
|
+
if (normalizedFilePath === normalizedCwd) {
|
|
105
|
+
return "/";
|
|
106
|
+
}
|
|
107
|
+
if (normalizedFilePath.startsWith(`${normalizedCwd}/`)) {
|
|
108
|
+
return normalizedFilePath.slice(normalizedCwd.length);
|
|
109
|
+
}
|
|
110
|
+
return normalizedFilePath;
|
|
111
|
+
}
|
|
112
|
+
function resolveEditorFilePath(filePath, cwd = process.cwd(), fileExists = import_node_fs.existsSync) {
|
|
113
|
+
const projectPath = import_node_path.default.join(cwd, filePath);
|
|
114
|
+
return fileExists(projectPath) ? projectPath : filePath;
|
|
115
|
+
}
|
|
98
116
|
async function injectSourceToJsx(code, id) {
|
|
99
117
|
const [filePath] = id.split("?");
|
|
100
118
|
if (!filePath) return;
|
|
101
|
-
const location = filePath
|
|
119
|
+
const location = getSourceInspectorPath(filePath);
|
|
102
120
|
if (!code.includes("<") || !code.includes(">")) {
|
|
103
121
|
return;
|
|
104
122
|
}
|
|
@@ -139,7 +157,7 @@ function openInEditor(editor, filePath, line, column) {
|
|
|
139
157
|
}
|
|
140
158
|
return;
|
|
141
159
|
}
|
|
142
|
-
const fullPath =
|
|
160
|
+
const fullPath = resolveEditorFilePath(filePath);
|
|
143
161
|
const l = line || "1";
|
|
144
162
|
const c = column || "1";
|
|
145
163
|
const buildArgs = editorArgs[resolved];
|
|
@@ -35,10 +35,13 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
35
35
|
}), mod);
|
|
36
36
|
var sourceInspectorPlugin_exports = {};
|
|
37
37
|
__export(sourceInspectorPlugin_exports, {
|
|
38
|
+
getSourceInspectorPath: () => getSourceInspectorPath,
|
|
39
|
+
resolveEditorFilePath: () => resolveEditorFilePath,
|
|
38
40
|
sourceInspectorPlugin: () => sourceInspectorPlugin
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(sourceInspectorPlugin_exports);
|
|
41
43
|
var import_child_process = require("child_process");
|
|
44
|
+
var import_fs = require("fs");
|
|
42
45
|
var import_path = __toESM(require("path"), 1);
|
|
43
46
|
var import_oxc_parser = require("oxc-parser");
|
|
44
47
|
var import_vite = require("vite");
|
|
@@ -147,10 +150,28 @@ async function findJsxElements(code, filename) {
|
|
|
147
150
|
return b.insertOffset - a.insertOffset;
|
|
148
151
|
});
|
|
149
152
|
}
|
|
153
|
+
function getSourceInspectorPath(filePath) {
|
|
154
|
+
var cwd = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd();
|
|
155
|
+
var normalizedFilePath = (0, import_vite.normalizePath)(filePath);
|
|
156
|
+
var normalizedCwd = (0, import_vite.normalizePath)(cwd);
|
|
157
|
+
if (normalizedFilePath === normalizedCwd) {
|
|
158
|
+
return "/";
|
|
159
|
+
}
|
|
160
|
+
if (normalizedFilePath.startsWith(`${normalizedCwd}/`)) {
|
|
161
|
+
return normalizedFilePath.slice(normalizedCwd.length);
|
|
162
|
+
}
|
|
163
|
+
return normalizedFilePath;
|
|
164
|
+
}
|
|
165
|
+
function resolveEditorFilePath(filePath) {
|
|
166
|
+
var cwd = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.cwd(),
|
|
167
|
+
fileExists = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : import_fs.existsSync;
|
|
168
|
+
var projectPath = import_path.default.join(cwd, filePath);
|
|
169
|
+
return fileExists(projectPath) ? projectPath : filePath;
|
|
170
|
+
}
|
|
150
171
|
async function injectSourceToJsx(code, id) {
|
|
151
172
|
var [filePath] = id.split("?");
|
|
152
173
|
if (!filePath) return;
|
|
153
|
-
var location = filePath
|
|
174
|
+
var location = getSourceInspectorPath(filePath);
|
|
154
175
|
if (!code.includes("<") || !code.includes(">")) {
|
|
155
176
|
return;
|
|
156
177
|
}
|
|
@@ -232,7 +253,7 @@ function openInEditor(editor, filePath, line, column) {
|
|
|
232
253
|
}
|
|
233
254
|
return;
|
|
234
255
|
}
|
|
235
|
-
var fullPath =
|
|
256
|
+
var fullPath = resolveEditorFilePath(filePath);
|
|
236
257
|
var l = line || "1";
|
|
237
258
|
var c = column || "1";
|
|
238
259
|
var buildArgs = editorArgs[resolved];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sourceInspectorPlugin_exports","__export","sourceInspectorPlugin","module","exports","import_child_process","require","import_path","__toESM","import_oxc_parser","import_vite","_type_of","obj","Symbol","constructor","findJsxElements","code","filename","result","parse","errors","length","locations","getJsxName","node","type","name","_node_property","object","property","getLocation","offset","before","slice","lines","split","line","column","walk","tagName","endsWith","_node_attributes","hasSourceAttr","attributes","some","attr","_attr_name","nameEnd","end","loc","start","push","insertOffset","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","keys","iterator","_step","next","done","key","Array","isArray","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","child","err","return","program","sort","a","b","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sourceInspectorPlugin_exports","__export","getSourceInspectorPath","resolveEditorFilePath","sourceInspectorPlugin","module","exports","import_child_process","require","import_fs","import_path","__toESM","import_oxc_parser","import_vite","_type_of","obj","Symbol","constructor","findJsxElements","code","filename","result","parse","errors","length","locations","getJsxName","node","type","name","_node_property","object","property","getLocation","offset","before","slice","lines","split","line","column","walk","tagName","endsWith","_node_attributes","hasSourceAttr","attributes","some","attr","_attr_name","nameEnd","end","loc","start","push","insertOffset","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","keys","iterator","_step","next","done","key","Array","isArray","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","child","err","return","program","sort","a","b","filePath","cwd","arguments","process","normalizedFilePath","normalizePath","normalizedCwd","startsWith","fileExists","existsSync","projectPath","default","join","injectSourceToJsx","id","location","includes","jsxLocations","jsx","sourceAttr","map","editorWarned","editorArgs","f","l","c","cursor","codium","vscodium","zed","subl","webstorm","idea","vim","nvim","emacs"],"sources":["../../../../src/vite/plugins/sourceInspectorPlugin.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAA,CAAAK,6BAAsB;AACtB,IAAAO,oBAA2B,GAAAC,OAAA;AAC3B,IAAAC,SAAA,GAAAD,OAAiB;AACjB,IAAAE,WAAA,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A,EAAAC,CAAA;IACE,QAAuD,GAAAF,CAAA,IAAAC,CAAA,IACzDC,CAAA;EACM;EAERK,IAAA,WAAAA,CACDP,CAAA,EAAAC,CAAA,EAAAC,CAAA;IAED,QACE,GAAAF,CAAA,IAAAC,CAAA,IAAAC,CAAA,GAEA;EAAuD;EACxDM,QAAA,EACH,SAAAA,CAACR,CAAA,EAAAC,CAAA,EAAAC,CAAA;IAAA,OACF,SACF,EAEDD,CAAA,EACE,UAAK,EACHC,CAAA,EAAYF,CAAA,CAGd;EACE;EACAS,IAAA,WAAAA,CAAAT,CAAM,EAAAC,CAAA,EAAAC,CAAA;IAEN,QACE,UACAD,CAAA,EACA,YAAAC,CAAA,EAIFF,CAAA,CACA;EACA;EACAU,GAAA,WAAAA,CAAAV,CAAA,EAAMC,CAAA;IAEN,QAEA,IAAAA,CAAA,IACAD,CAAA,CAAY;EAEZ;EACAW,IAAA,WAAAA,CAAIX,CAAA,EAAAC,CAAA;IACJ,QAA+B,IACjCA,CAAA,IAAAD,CAAA,CACD;EACH;EAEJY,KAAA,WAAAA,CAAAZ,CAAA,EAAAC,CAAA,EAAAC,CAAA;IACF,Q","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_sourceInspectorPlugin = require("./sourceInspectorPlugin.cjs");
|
|
3
|
+
(0, import_vitest.describe)("sourceInspectorPlugin helpers", () => {
|
|
4
|
+
(0, import_vitest.describe)("getSourceInspectorPath", () => {
|
|
5
|
+
(0, import_vitest.it)("keeps project files relative to the current cwd", () => {
|
|
6
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo/packages/one/src/App.tsx", "/repo")).toBe("/packages/one/src/App.tsx");
|
|
7
|
+
});
|
|
8
|
+
(0, import_vitest.it)("does not strip matching path prefixes from files outside cwd", () => {
|
|
9
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo-other/packages/one/src/App.tsx", "/repo")).toBe("/repo-other/packages/one/src/App.tsx");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
(0, import_vitest.describe)("resolveEditorFilePath", () => {
|
|
13
|
+
(0, import_vitest.it)("resolves project-relative source paths against cwd", () => {
|
|
14
|
+
const fileExists = filePath => filePath === "/repo/packages/one/src/App.tsx";
|
|
15
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/packages/one/src/App.tsx", "/repo", fileExists)).toBe("/repo/packages/one/src/App.tsx");
|
|
16
|
+
});
|
|
17
|
+
(0, import_vitest.it)("preserves absolute source paths for files outside cwd", () => {
|
|
18
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/Users/n8/shared/ui/Button.tsx", "/repo/apps/site", () => false)).toBe("/Users/n8/shared/ui/Button.tsx");
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_sourceInspectorPlugin = require("./sourceInspectorPlugin.native.js");
|
|
5
|
+
(0, import_vitest.describe)("sourceInspectorPlugin helpers", function () {
|
|
6
|
+
(0, import_vitest.describe)("getSourceInspectorPath", function () {
|
|
7
|
+
(0, import_vitest.it)("keeps project files relative to the current cwd", function () {
|
|
8
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo/packages/one/src/App.tsx", "/repo")).toBe("/packages/one/src/App.tsx");
|
|
9
|
+
});
|
|
10
|
+
(0, import_vitest.it)("does not strip matching path prefixes from files outside cwd", function () {
|
|
11
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.getSourceInspectorPath)("/repo-other/packages/one/src/App.tsx", "/repo")).toBe("/repo-other/packages/one/src/App.tsx");
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
(0, import_vitest.describe)("resolveEditorFilePath", function () {
|
|
15
|
+
(0, import_vitest.it)("resolves project-relative source paths against cwd", function () {
|
|
16
|
+
var fileExists = function (filePath) {
|
|
17
|
+
return filePath === "/repo/packages/one/src/App.tsx";
|
|
18
|
+
};
|
|
19
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/packages/one/src/App.tsx", "/repo", fileExists)).toBe("/repo/packages/one/src/App.tsx");
|
|
20
|
+
});
|
|
21
|
+
(0, import_vitest.it)("preserves absolute source paths for files outside cwd", function () {
|
|
22
|
+
(0, import_vitest.expect)((0, import_sourceInspectorPlugin.resolveEditorFilePath)("/Users/n8/shared/ui/Button.tsx", "/repo/apps/site", function () {
|
|
23
|
+
return false;
|
|
24
|
+
})).toBe("/Users/n8/shared/ui/Button.tsx");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=sourceInspectorPlugin.test.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_sourceInspectorPlugin","describe","it","expect","getSourceInspectorPath","toBe","fileExists","filePath","resolveEditorFilePath"],"sources":["../../../../src/vite/plugins/sourceInspectorPlugin.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AAEA,IAAAA,aAAA,GAAAC,OAAA,SAA8D;AAAA,IAE9DC,4BAAS,GAAAD,OAAA,oCAAuC;AAC9C,IAAAD,aAAA,CAAAG,QAAA,iCAAmC,cAAM;EACvC,IAAAH,aAAA,CAAAG,QAAG;IACD,IAAAH,aAAA,CAAAI,EAAA,mDAAO;MAAmE,EACxE,EAAAJ,aAAA,CAAAK,MAAA,MAAAH,4BAAA,CAAAI,sBAAA,8CAAAC,IAAA;IAAA,EACF;IACF,CAAC,GAAAP,aAAA,CAAAI,EAAA;MAED,IAAAJ,aAAA,CAAAK,MAAG,MAAAH,4BAAA,CAAAI,sBAAA,wCAAsE,YAAAC,IAAA;IACvE;EAAA;EACwE,IACxEP,aAAO,CAAAG,QAAA,yBAAsC;IAC/C,CAAC,GAAAH,aAAA,CAAAI,EAAA;MACF,IAAAI,UAAA,YAAAA,CAAAC,QAAA;QAED,OAAAA,QAAA,qCAAkC;MAChC;MACE,IAAAT,aAAM,CAAAK,MAAc,MAAAH,4BACL,CAAAQ,qBAAA,wCAAAF,UAAA,GAAAD,IAAA;IAEf;IAAA,IAAAP,aACE,CAAAI,EAAA,yDAAsB,cAA6B;MACrD,EAAE,EAAAJ,aAAK,CAAAK,MAAA,MAAAH,4BAAgC,CAAAQ,qBAAA;QACxC;MAED,IAAAH,IAAA,iCAAG;IACD;EAAA;AACE","ignoreList":[]}
|
|
@@ -74,7 +74,7 @@ function withRequestContext(fn) {
|
|
|
74
74
|
}
|
|
75
75
|
return fn();
|
|
76
76
|
}
|
|
77
|
-
function resolveAPIEndpoint(runEndpoint, request, params) {
|
|
77
|
+
function resolveAPIEndpoint(runEndpoint, request, params, env, executionCtx) {
|
|
78
78
|
return resolveResponse(async () => {
|
|
79
79
|
const imported = await runEndpoint();
|
|
80
80
|
const requestType = request.method || "GET";
|
|
@@ -83,8 +83,13 @@ function resolveAPIEndpoint(runEndpoint, request, params) {
|
|
|
83
83
|
console.warn(`No handler found for request ${requestType}`);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
+
const worker = env !== void 0 || executionCtx !== void 0 ? {
|
|
87
|
+
env,
|
|
88
|
+
executionCtx
|
|
89
|
+
} : void 0;
|
|
86
90
|
return await handler(request, {
|
|
87
|
-
params
|
|
91
|
+
params,
|
|
92
|
+
worker
|
|
88
93
|
});
|
|
89
94
|
});
|
|
90
95
|
}
|
|
@@ -88,7 +88,7 @@ function withRequestContext(fn) {
|
|
|
88
88
|
}
|
|
89
89
|
return fn();
|
|
90
90
|
}
|
|
91
|
-
function resolveAPIEndpoint(runEndpoint, request, params) {
|
|
91
|
+
function resolveAPIEndpoint(runEndpoint, request, params, env, executionCtx) {
|
|
92
92
|
return resolveResponse(async function () {
|
|
93
93
|
var imported = await runEndpoint();
|
|
94
94
|
var requestType = request.method || "GET";
|
|
@@ -97,8 +97,13 @@ function resolveAPIEndpoint(runEndpoint, request, params) {
|
|
|
97
97
|
console.warn(`No handler found for request ${requestType}`);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
+
var worker = env !== void 0 || executionCtx !== void 0 ? {
|
|
101
|
+
env,
|
|
102
|
+
executionCtx
|
|
103
|
+
} : void 0;
|
|
100
104
|
return await handler(request, {
|
|
101
|
-
params
|
|
105
|
+
params,
|
|
106
|
+
worker
|
|
102
107
|
});
|
|
103
108
|
});
|
|
104
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","resolveResponse_exports","__export","resolveAPIEndpoint","resolveResponse","withRequestContext","module","exports","import_isResponse","require","import_one_server_only","_instanceof","left","right","Symbol","hasInstance","_type_of","obj","constructor","_nextId","createId","_id","getResponse","store","requestAsyncLocalStore","globalThis","id","response","run","getResponseWithAddedHeaders","err","isResponse","runWithAsyncLocalContext","id2","response2","fn","runEndpoint","request","params","imported","requestType","method","handler","default","console","warn","_globalThis___vxrnasyncHeadersCache","cache","asyncHeadersCache","asyncHeaders","get","Response","cloned","clone","headers","Headers","mergeHeaders","body"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","resolveResponse_exports","__export","resolveAPIEndpoint","resolveResponse","withRequestContext","module","exports","import_isResponse","require","import_one_server_only","_instanceof","left","right","Symbol","hasInstance","_type_of","obj","constructor","_nextId","createId","_id","getResponse","store","requestAsyncLocalStore","globalThis","id","response","run","getResponseWithAddedHeaders","err","isResponse","runWithAsyncLocalContext","id2","response2","fn","runEndpoint","request","params","env","executionCtx","imported","requestType","method","handler","default","console","warn","worker","_globalThis___vxrnasyncHeadersCache","cache","asyncHeadersCache","asyncHeaders","get","Response","cloned","clone","headers","Headers","mergeHeaders","body"],"sources":["../../../src/vite/resolveResponse.ts"],"s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AAAuB,mCAA4B;EAAW,IAAAC,KACzC,IAAAD,mCAAA,GAAAxB,UAAA,yCAAAwB,mCAAA,cAAAA,mCAAA,GAAAvC,sBAAA,CAAAyC,iBAAA;EACA,IAAAC,YAAA,GAAWF,KAAI,CAAAG,GAAA,CAAA3B,EAAA,CAAS;EAA4B,IAAA0B,YACtD;IAAA,IACF;MACF,IAAAzC,WAAc,CAAAgB,QAAA,EAAA2B,QAAA;QACZ,IAAAC,MAAQ,GAAM5B,QAAA,CAAA6B,KAAA;QAChB,IAAAC,OAAA,OAAAC,OAAA;QACF,IAAAhD,sBAAA,CAAAiD,YAAA,EAAAF,OAAA,EAAAF,MAAA,CAAAE,OAAA;QAEA,CAAO,GAAA/C,sBAAA,CAAAiD,YAAA,EAAAF,OAAA,EAAAL,YAAA;QACTzB,QAAA,OAAA2B,QAAA,CAAAC,MAAA,CAAAK,IAAA","ignoreList":[]}
|
package/dist/esm/cli/build.mjs
CHANGED
|
@@ -4,14 +4,14 @@ import Path, { join, relative, resolve } from "node:path";
|
|
|
4
4
|
import { resolvePath } from "@vxrn/resolve";
|
|
5
5
|
import FSExtra from "fs-extra";
|
|
6
6
|
import MicroMatch from "micromatch";
|
|
7
|
-
import { mergeConfig, build as viteBuild } from "vite";
|
|
7
|
+
import { createBuilder, mergeConfig, normalizePath, build as viteBuild } from "vite";
|
|
8
8
|
import { fillOptions, getOptimizeDeps, rollupRemoveUnusedImportsPlugin, build as vxrnBuild } from "vxrn";
|
|
9
9
|
import * as constants from "../constants.mjs";
|
|
10
10
|
import { setServerGlobals } from "../server/setServerGlobals.mjs";
|
|
11
11
|
import { getPathnameFromFilePath } from "../utils/getPathnameFromFilePath.mjs";
|
|
12
12
|
import { getRouterRootFromOneOptions } from "../utils/getRouterRootFromOneOptions.mjs";
|
|
13
13
|
import { isRolldown } from "../utils/isRolldown.mjs";
|
|
14
|
-
import { toAbsolute } from "../utils/toAbsolute.mjs";
|
|
14
|
+
import { toAbsolute, toAbsoluteUrl } from "../utils/toAbsolute.mjs";
|
|
15
15
|
import { buildVercelOutputDirectory } from "../vercel/build/buildVercelOutputDirectory.mjs";
|
|
16
16
|
import { getManifest } from "../vite/getManifest.mjs";
|
|
17
17
|
import { loadUserOneOptions } from "../vite/loadConfig.mjs";
|
|
@@ -283,10 +283,30 @@ async function build(args) {
|
|
|
283
283
|
rolldownOptions: _rolldownOptions,
|
|
284
284
|
...optimizeDepsNoRolldown
|
|
285
285
|
} = optimizeDeps;
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
const serverOpts = oneOptions.build?.server;
|
|
287
|
+
const isUnified = typeof serverOpts === "object" && serverOpts !== null && serverOpts.unified === true;
|
|
288
|
+
let baseForApi = isUnified ? clonePluginHooks(vxrnOutput.serverBuildConfig ?? vxrnOutput.webBuildConfig) : clonePluginHooks(vxrnOutput.webBuildConfig);
|
|
289
|
+
if (isUnified) {
|
|
290
|
+
const clone = {
|
|
291
|
+
...baseForApi,
|
|
292
|
+
build: baseForApi.build ? {
|
|
293
|
+
...baseForApi.build
|
|
294
|
+
} : void 0,
|
|
295
|
+
plugins: baseForApi.plugins ? baseForApi.plugins.filter(p => p && typeof p === "object" && p.name !== "omit-api-routes") : void 0
|
|
296
|
+
};
|
|
297
|
+
if (clone.build && clone.build.rolldownOptions) {
|
|
298
|
+
const ro = {
|
|
299
|
+
...clone.build.rolldownOptions
|
|
300
|
+
};
|
|
301
|
+
delete ro.input;
|
|
302
|
+
clone.build.rolldownOptions = ro;
|
|
303
|
+
}
|
|
304
|
+
if (clone.build) {
|
|
305
|
+
delete clone.build.outDir;
|
|
306
|
+
}
|
|
307
|
+
baseForApi = clone;
|
|
308
|
+
}
|
|
309
|
+
const apiBuildConfig = mergeConfig(baseForApi, {
|
|
290
310
|
configFile: false,
|
|
291
311
|
appType: "custom",
|
|
292
312
|
optimizeDeps: optimizeDepsNoRolldown,
|
|
@@ -311,13 +331,13 @@ async function build(args) {
|
|
|
311
331
|
const mergedConfig = mergeConfig(apiBuildConfig, {
|
|
312
332
|
appType: "custom",
|
|
313
333
|
configFile: false,
|
|
314
|
-
// plugins: [
|
|
315
|
-
// nodeExternals({
|
|
316
|
-
// exclude: optimizeDeps.include,
|
|
317
|
-
// }) as any,
|
|
318
|
-
// ],
|
|
319
334
|
define: vxrnOutput.processEnvDefines,
|
|
320
|
-
ssr: {
|
|
335
|
+
ssr: isUnified ? {
|
|
336
|
+
// in unified mode let the base (serverBuildConfig) set ssr.noExternal
|
|
337
|
+
// — default is now ['react', 'react-dom'] instead of `true`, so
|
|
338
|
+
// rolldown can externalize the rest.
|
|
339
|
+
optimizeDeps: optimizeDepsNoRolldown
|
|
340
|
+
} : {
|
|
321
341
|
noExternal: true,
|
|
322
342
|
external: ["react", "react-dom"],
|
|
323
343
|
optimizeDeps: optimizeDepsNoRolldown
|
|
@@ -349,7 +369,12 @@ async function build(args) {
|
|
|
349
369
|
// prevents it from shaking out the exports
|
|
350
370
|
preserveEntrySignatures: "strict",
|
|
351
371
|
input,
|
|
352
|
-
|
|
372
|
+
// in unified mode, inherit externals from serverBuildConfig (user
|
|
373
|
+
// ssr.external / rolldownOptions.external). the legacy path resets
|
|
374
|
+
// them to [] so per-route files bundle everything.
|
|
375
|
+
...(isUnified ? {} : {
|
|
376
|
+
external: []
|
|
377
|
+
}),
|
|
353
378
|
output: {
|
|
354
379
|
entryFileNames: "[name]",
|
|
355
380
|
exports: "auto",
|
|
@@ -398,14 +423,14 @@ async function build(args) {
|
|
|
398
423
|
if (middlewareBuildInfo) {
|
|
399
424
|
for (const middleware of manifest.middlewareRoutes) {
|
|
400
425
|
const absoluteRoot = resolve(process.cwd(), options.root);
|
|
401
|
-
const fullPath = join(absoluteRoot, routerRoot, middleware.file);
|
|
426
|
+
const fullPath = normalizePath(join(absoluteRoot, routerRoot, middleware.file));
|
|
402
427
|
const outChunks = middlewareBuildInfo.output.filter(x => x.type === "chunk");
|
|
403
428
|
const chunk = outChunks.find(x => x.facadeModuleId === fullPath);
|
|
404
429
|
if (!chunk) throw new Error(`internal err finding middleware`);
|
|
405
430
|
builtMiddlewares[middleware.file] = join(outDir, "middlewares", chunk.fileName);
|
|
406
431
|
}
|
|
407
432
|
}
|
|
408
|
-
globalThis["require"] = createRequire(
|
|
433
|
+
globalThis["require"] = createRequire(import.meta.dirname + "/");
|
|
409
434
|
const assets = [];
|
|
410
435
|
const builtRoutes = [];
|
|
411
436
|
const sitemapData = [];
|
|
@@ -448,7 +473,7 @@ async function build(args) {
|
|
|
448
473
|
const id = output.facadeModuleId || "";
|
|
449
474
|
const file = Path.basename(id);
|
|
450
475
|
if (file.startsWith("_layout") && id.includes(`/${routerRoot}/`)) {
|
|
451
|
-
const relativePath = relative(process.cwd(), id).replace(`${routerRoot}/`, "");
|
|
476
|
+
const relativePath = normalizePath(relative(process.cwd(), id)).replace(`${routerRoot}/`, "");
|
|
452
477
|
const contextKey = `./${relativePath}`;
|
|
453
478
|
layoutServerPaths.set(contextKey, output.fileName);
|
|
454
479
|
}
|
|
@@ -499,7 +524,7 @@ async function build(args) {
|
|
|
499
524
|
if (!foundRoute.file) {
|
|
500
525
|
continue;
|
|
501
526
|
}
|
|
502
|
-
const routeModulePath = join(resolve(process.cwd(), options.root), routerRoot, foundRoute.file.slice(2));
|
|
527
|
+
const routeModulePath = normalizePath(join(resolve(process.cwd(), options.root), routerRoot, foundRoute.file.slice(2)));
|
|
503
528
|
const serverFileName = moduleIdToServerChunk.get(routeModulePath);
|
|
504
529
|
if (!serverFileName) {
|
|
505
530
|
if (foundRoute.type === "spa") {
|
|
@@ -641,7 +666,7 @@ async function build(args) {
|
|
|
641
666
|
const serverJsPath = join(`${outDir}/server`, serverFileName);
|
|
642
667
|
let exported;
|
|
643
668
|
try {
|
|
644
|
-
exported = await import(
|
|
669
|
+
exported = await import(toAbsoluteUrl(serverJsPath));
|
|
645
670
|
} catch (err) {
|
|
646
671
|
console.error(`Error importing page (original error)`, err);
|
|
647
672
|
throw new Error(`Error importing page: ${serverJsPath}`, {
|
|
@@ -783,9 +808,17 @@ async function build(args) {
|
|
|
783
808
|
}));
|
|
784
809
|
}
|
|
785
810
|
const buildInfo = builtRoutes.find(x => x.routeFile === route.file);
|
|
786
|
-
if (built.middlewares
|
|
811
|
+
if (built.middlewares) {
|
|
787
812
|
for (const [index, mw] of built.middlewares.entries()) {
|
|
788
|
-
|
|
813
|
+
const viaBuildInfo = buildInfo?.middlewares?.[index];
|
|
814
|
+
if (viaBuildInfo) {
|
|
815
|
+
mw.contextKey = viaBuildInfo;
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
const viaMiddlewareMap = builtMiddlewares[mw.contextKey];
|
|
819
|
+
if (viaMiddlewareMap) {
|
|
820
|
+
mw.contextKey = viaMiddlewareMap;
|
|
821
|
+
}
|
|
789
822
|
}
|
|
790
823
|
}
|
|
791
824
|
if (buildInfo) {
|
|
@@ -861,6 +894,11 @@ async function build(args) {
|
|
|
861
894
|
}
|
|
862
895
|
case "cloudflare":
|
|
863
896
|
{
|
|
897
|
+
const workerSrcDir = join(options.root, outDir);
|
|
898
|
+
const getWorkerSourceImportPath = routeFile => {
|
|
899
|
+
const importPath = normalizePath(relative(workerSrcDir, join(options.root, routerRoot, routeFile)));
|
|
900
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
901
|
+
};
|
|
864
902
|
const pageRouteMap = [];
|
|
865
903
|
const apiRouteMap = [];
|
|
866
904
|
const middlewareRouteMap = [];
|
|
@@ -872,13 +910,12 @@ async function build(args) {
|
|
|
872
910
|
}
|
|
873
911
|
for (const route of buildInfoForWriting.manifest.apiRoutes) {
|
|
874
912
|
if (route.file) {
|
|
875
|
-
const
|
|
876
|
-
const importPath = `./api/${apiFileName}.js`;
|
|
913
|
+
const importPath = getWorkerSourceImportPath(route.file);
|
|
877
914
|
apiRouteMap.push(` '${route.page}': () => import('${importPath}')`);
|
|
878
915
|
}
|
|
879
916
|
}
|
|
880
|
-
for (const [, builtPath] of Object.entries(builtMiddlewares)) {
|
|
881
|
-
const importPath =
|
|
917
|
+
for (const [sourceFile, builtPath] of Object.entries(builtMiddlewares)) {
|
|
918
|
+
const importPath = getWorkerSourceImportPath(sourceFile);
|
|
882
919
|
middlewareRouteMap.push(` '${builtPath}': () => import('${importPath}')`);
|
|
883
920
|
}
|
|
884
921
|
const workerSrcPath = join(options.root, outDir, "_worker-src.js");
|
|
@@ -936,7 +973,7 @@ export default {
|
|
|
936
973
|
}
|
|
937
974
|
|
|
938
975
|
try {
|
|
939
|
-
const response = await server.fetch(request)
|
|
976
|
+
const response = await server.fetch(request, env, ctx)
|
|
940
977
|
|
|
941
978
|
// no route matched or 404 \u2192 try static assets
|
|
942
979
|
if (!response || response.status === 404) {
|
|
@@ -960,38 +997,34 @@ export default {
|
|
|
960
997
|
}
|
|
961
998
|
`;
|
|
962
999
|
await FSExtra.writeFile(workerSrcPath, workerCode);
|
|
1000
|
+
const projectName = await getCloudflareProjectName(options.root);
|
|
1001
|
+
const userWranglerConfig = await loadUserWranglerConfig(options.root);
|
|
1002
|
+
const wranglerInputConfig = createCloudflareWranglerConfig(projectName, userWranglerConfig?.config);
|
|
1003
|
+
wranglerInputConfig.main = relative(join(options.root, outDir), workerSrcPath);
|
|
1004
|
+
const wranglerInputPath = join(options.root, outDir, "_wrangler.input.jsonc");
|
|
1005
|
+
await FSExtra.writeFile(wranglerInputPath, `${JSON.stringify(wranglerInputConfig, null, 2)}
|
|
1006
|
+
`);
|
|
963
1007
|
console.info("\n [cloudflare] Bundling worker...");
|
|
964
|
-
|
|
1008
|
+
const {
|
|
1009
|
+
cloudflare
|
|
1010
|
+
} = await import("@cloudflare/vite-plugin");
|
|
1011
|
+
const builder = await createBuilder({
|
|
965
1012
|
root: options.root,
|
|
966
1013
|
mode: "production",
|
|
967
1014
|
logLevel: "warn",
|
|
968
|
-
|
|
969
|
-
outDir,
|
|
970
|
-
emptyOutDir: false,
|
|
971
|
-
// Use SSR mode with node target for proper Node.js module resolution
|
|
972
|
-
ssr: workerSrcPath,
|
|
973
|
-
rolldownOptions: {
|
|
974
|
-
external: [
|
|
975
|
-
// React Native dev tools - not needed in production
|
|
976
|
-
"@react-native/dev-middleware", "@react-native/debugger-shell", "metro", "metro-core", "metro-runtime",
|
|
977
|
-
// Native modules that can't run in workers
|
|
978
|
-
/\.node$/],
|
|
979
|
-
output: {
|
|
980
|
-
entryFileNames: "worker.js",
|
|
981
|
-
format: "es",
|
|
982
|
-
// Keep dynamic imports separate for lazy loading
|
|
983
|
-
inlineDynamicImports: false
|
|
984
|
-
}
|
|
985
|
-
},
|
|
986
|
-
minify: true,
|
|
987
|
-
target: "esnext"
|
|
988
|
-
},
|
|
1015
|
+
configFile: false,
|
|
989
1016
|
define: {
|
|
990
1017
|
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
991
|
-
"process.env.VITE_ENVIRONMENT": JSON.stringify("ssr")
|
|
1018
|
+
"process.env.VITE_ENVIRONMENT": JSON.stringify("ssr"),
|
|
1019
|
+
"process.env.ONE_CACHE_KEY": JSON.stringify(constants.CACHE_KEY)
|
|
992
1020
|
},
|
|
1021
|
+
plugins: [cloudflare({
|
|
1022
|
+
configPath: wranglerInputPath,
|
|
1023
|
+
viteEnvironment: {
|
|
1024
|
+
name: "worker"
|
|
1025
|
+
}
|
|
1026
|
+
})],
|
|
993
1027
|
resolve: {
|
|
994
|
-
conditions: ["workerd", "worker", "node", "module", "default"],
|
|
995
1028
|
alias: [
|
|
996
1029
|
// rolldown can't parse react-native's Flow syntax; alias to react-native-web for ssr
|
|
997
1030
|
{
|
|
@@ -1008,22 +1041,29 @@ export default {
|
|
|
1008
1041
|
replacement: resolvePath("@vxrn/safe-area", options.root)
|
|
1009
1042
|
}]
|
|
1010
1043
|
},
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1044
|
+
build: {
|
|
1045
|
+
outDir,
|
|
1046
|
+
emptyOutDir: false,
|
|
1047
|
+
rolldownOptions: {
|
|
1048
|
+
// Match the main web build behavior so RN packages that import
|
|
1049
|
+
// native-only symbols from react-native can still bundle against
|
|
1050
|
+
// the react-native-web alias in the worker graph.
|
|
1051
|
+
shimMissingExports: true
|
|
1052
|
+
}
|
|
1014
1053
|
}
|
|
1015
1054
|
});
|
|
1055
|
+
const workerEnv = builder.environments.worker;
|
|
1056
|
+
if (!workerEnv) {
|
|
1057
|
+
throw new Error('[one] plugin did not register "worker" environment');
|
|
1058
|
+
}
|
|
1059
|
+
await builder.build(workerEnv);
|
|
1016
1060
|
await FSExtra.remove(workerSrcPath);
|
|
1017
|
-
|
|
1018
|
-
const userWranglerConfig = await loadUserWranglerConfig(options.root);
|
|
1019
|
-
const wranglerConfig = createCloudflareWranglerConfig(projectName, userWranglerConfig?.config);
|
|
1061
|
+
await FSExtra.remove(wranglerInputPath);
|
|
1020
1062
|
if (userWranglerConfig) {
|
|
1021
|
-
console.info(` [cloudflare] Merging ${relative(options.root, userWranglerConfig.path)} into ${outDir}/wrangler.
|
|
1063
|
+
console.info(` [cloudflare] Merging ${relative(options.root, userWranglerConfig.path)} into ${outDir}/worker/wrangler.json`);
|
|
1022
1064
|
}
|
|
1023
|
-
|
|
1024
|
-
`);
|
|
1025
|
-
postBuildLogs.push(`Cloudflare worker bundled at ${outDir}/worker.js`);
|
|
1026
|
-
postBuildLogs.push(`To deploy: cd ${outDir} && wrangler deploy`);
|
|
1065
|
+
postBuildLogs.push(`Cloudflare worker bundled at ${outDir}/worker/index.js`);
|
|
1066
|
+
postBuildLogs.push(`To deploy: cd ${outDir}/worker && wrangler deploy`);
|
|
1027
1067
|
break;
|
|
1028
1068
|
}
|
|
1029
1069
|
}
|