one 1.12.5 → 1.12.6-1774155963695
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/devtools/source-inspector.mjs +7 -27
- package/dist/cjs/babel-plugins/remove-server-code.cjs +42 -46
- package/dist/cjs/babel-plugins/remove-server-code.native.js +44 -84
- package/dist/cjs/babel-plugins/remove-server-code.native.js.map +1 -1
- package/dist/cjs/cli/build.cjs +12 -17
- package/dist/cjs/cli/build.native.js +12 -17
- package/dist/cjs/cli/build.native.js.map +1 -1
- package/dist/cjs/cli/securityScan.cjs +2 -1
- package/dist/cjs/cli/securityScan.native.js +2 -1
- package/dist/cjs/cli/securityScan.native.js.map +1 -1
- package/dist/cjs/createApp.cjs +2 -15
- package/dist/cjs/headless.cjs +45 -0
- package/dist/cjs/headless.native.js +54 -0
- package/dist/cjs/headless.native.js.map +1 -0
- package/dist/cjs/serve-worker.cjs +16 -23
- package/dist/cjs/serve-worker.native.js +16 -23
- package/dist/cjs/serve-worker.native.js.map +1 -1
- package/dist/cjs/server/oneServe.cjs +4 -1
- package/dist/cjs/server/oneServe.native.js +4 -1
- package/dist/cjs/server/oneServe.native.js.map +1 -1
- package/dist/cjs/server/workerHandler.cjs +492 -0
- package/dist/cjs/server/workerHandler.native.js +673 -0
- package/dist/cjs/server/workerHandler.native.js.map +1 -0
- package/dist/cjs/utils/findRootLayout.cjs +39 -0
- package/dist/cjs/utils/findRootLayout.native.js +44 -0
- package/dist/cjs/utils/findRootLayout.native.js.map +1 -0
- package/dist/cjs/vite/one.cjs +6 -2
- package/dist/cjs/vite/one.native.js +5 -2
- package/dist/cjs/vite/one.native.js.map +1 -1
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +33 -29
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +53 -44
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
- package/dist/esm/babel-plugins/remove-server-code.mjs +41 -45
- package/dist/esm/babel-plugins/remove-server-code.mjs.map +1 -1
- package/dist/esm/babel-plugins/remove-server-code.native.js +43 -83
- package/dist/esm/babel-plugins/remove-server-code.native.js.map +1 -1
- package/dist/esm/cli/build.mjs +12 -17
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +12 -17
- package/dist/esm/cli/build.native.js.map +1 -1
- package/dist/esm/cli/securityScan.mjs +2 -1
- package/dist/esm/cli/securityScan.mjs.map +1 -1
- package/dist/esm/cli/securityScan.native.js +2 -1
- package/dist/esm/cli/securityScan.native.js.map +1 -1
- package/dist/esm/createApp.mjs +2 -15
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/headless.mjs +20 -0
- package/dist/esm/headless.mjs.map +1 -0
- package/dist/esm/headless.native.js +26 -0
- package/dist/esm/headless.native.js.map +1 -0
- package/dist/esm/serve-worker.mjs +11 -7
- package/dist/esm/serve-worker.mjs.map +1 -1
- package/dist/esm/serve-worker.native.js +11 -7
- package/dist/esm/serve-worker.native.js.map +1 -1
- package/dist/esm/server/oneServe.mjs +4 -1
- package/dist/esm/server/oneServe.mjs.map +1 -1
- package/dist/esm/server/oneServe.native.js +4 -1
- package/dist/esm/server/oneServe.native.js.map +1 -1
- package/dist/esm/server/workerHandler.mjs +469 -0
- package/dist/esm/server/workerHandler.mjs.map +1 -0
- package/dist/esm/server/workerHandler.native.js +647 -0
- package/dist/esm/server/workerHandler.native.js.map +1 -0
- package/dist/esm/utils/findRootLayout.mjs +16 -0
- package/dist/esm/utils/findRootLayout.mjs.map +1 -0
- package/dist/esm/utils/findRootLayout.native.js +18 -0
- package/dist/esm/utils/findRootLayout.native.js.map +1 -0
- package/dist/esm/vite/one.mjs +6 -2
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +5 -2
- package/dist/esm/vite/one.native.js.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +34 -30
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +54 -45
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
- package/package.json +15 -11
- package/src/babel-plugins/remove-server-code.ts +117 -189
- package/src/cli/build.ts +12 -15
- package/src/cli/securityScan.ts +1 -1
- package/src/createApp.tsx +2 -38
- package/src/headless.tsx +46 -0
- package/src/serve-worker.ts +20 -22
- package/src/server/oneServe.ts +1 -1
- package/src/server/workerHandler.ts +767 -0
- package/src/utils/findRootLayout.ts +25 -0
- package/src/vite/one.ts +2 -1
- package/src/vite/plugins/sourceInspectorPlugin.ts +44 -64
- package/src/vite/types.ts +8 -0
- package/types/babel-plugins/remove-server-code.d.ts +8 -11
- package/types/babel-plugins/remove-server-code.d.ts.map +1 -1
- package/types/cli/build.d.ts.map +1 -1
- package/types/createApp.d.ts.map +1 -1
- package/types/headless.d.ts +13 -0
- package/types/headless.d.ts.map +1 -0
- package/types/serve-worker.d.ts +10 -21
- package/types/serve-worker.d.ts.map +1 -1
- package/types/server/workerHandler.d.ts +23 -0
- package/types/server/workerHandler.d.ts.map +1 -0
- package/types/utils/findRootLayout.d.ts +2 -0
- package/types/utils/findRootLayout.d.ts.map +1 -0
- package/types/vite/one.d.ts.map +1 -1
- package/types/vite/plugins/sourceInspectorPlugin.d.ts +3 -1
- package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -1
- package/types/vite/types.d.ts +7 -0
- package/types/vite/types.d.ts.map +1 -1
|
@@ -772,50 +772,30 @@
|
|
|
772
772
|
|
|
773
773
|
renderPickerList(chain)
|
|
774
774
|
|
|
775
|
-
// position picker near click,
|
|
775
|
+
// position picker near click, clamped to viewport
|
|
776
776
|
const pickerWidth = 320
|
|
777
777
|
const pickerHeight = Math.min(300, 80 + chain.length * 36)
|
|
778
778
|
const pad = 10
|
|
779
779
|
|
|
780
780
|
let left = x + 10
|
|
781
781
|
let top = y + 10
|
|
782
|
-
let flippedUp = false
|
|
783
782
|
|
|
784
|
-
// flip to left if too close to right edge
|
|
785
|
-
if (left + pickerWidth > window.innerWidth - pad) {
|
|
786
|
-
left = x - pickerWidth - 10
|
|
787
|
-
}
|
|
788
|
-
// flip up if too close to bottom
|
|
789
|
-
if (top + pickerHeight > window.innerHeight - pad) {
|
|
790
|
-
top = y - pickerHeight - 10
|
|
791
|
-
flippedUp = true
|
|
792
|
-
}
|
|
793
783
|
// clamp to viewport
|
|
794
784
|
left = Math.max(pad, Math.min(left, window.innerWidth - pickerWidth - pad))
|
|
795
785
|
top = Math.max(pad, Math.min(top, window.innerHeight - pickerHeight - pad))
|
|
796
786
|
|
|
797
|
-
//
|
|
787
|
+
// consistent layout order
|
|
798
788
|
const picker = shadow.getElementById('picker')
|
|
799
789
|
const header = picker.querySelector('.picker-header')
|
|
800
790
|
const actions = picker.querySelector('.picker-actions')
|
|
801
791
|
const pickerTabs = picker.querySelector('.picker-tabs')
|
|
802
792
|
const list = picker.querySelector('.picker-list')
|
|
803
793
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
list.style.order = '2'
|
|
810
|
-
actions.style.order = '3'
|
|
811
|
-
} else {
|
|
812
|
-
// picker is below click, put actions at top (closest to mouse)
|
|
813
|
-
picker.style.flexDirection = 'column'
|
|
814
|
-
header.style.order = '2'
|
|
815
|
-
pickerTabs.style.order = '1'
|
|
816
|
-
list.style.order = '3'
|
|
817
|
-
actions.style.order = '0'
|
|
818
|
-
}
|
|
794
|
+
picker.style.flexDirection = 'column'
|
|
795
|
+
header.style.order = '0'
|
|
796
|
+
actions.style.order = '1'
|
|
797
|
+
pickerTabs.style.order = '2'
|
|
798
|
+
list.style.order = '3'
|
|
819
799
|
|
|
820
800
|
pickerDialog.style.left = left + 'px'
|
|
821
801
|
pickerDialog.style.top = top + 'px'
|
|
@@ -34,9 +34,13 @@ __export(remove_server_code_exports, {
|
|
|
34
34
|
default: () => remove_server_code_default
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(remove_server_code_exports);
|
|
37
|
-
var
|
|
37
|
+
var import_generator = __toESM(require("@babel/generator"), 1),
|
|
38
|
+
import_parser = require("@babel/parser"),
|
|
39
|
+
import_traverse = __toESM(require("@babel/traverse"), 1),
|
|
40
|
+
t = __toESM(require("@babel/types"), 1),
|
|
38
41
|
import_babel_dead_code_elimination = require("babel-dead-code-elimination");
|
|
39
|
-
const
|
|
42
|
+
const generate = import_generator.default.default || import_generator.default,
|
|
43
|
+
traverse = import_traverse.default.default || import_traverse.default;
|
|
40
44
|
function removeServerCodePlugin(_, options) {
|
|
41
45
|
const {
|
|
42
46
|
routerRoot = "app"
|
|
@@ -45,58 +49,50 @@ function removeServerCodePlugin(_, options) {
|
|
|
45
49
|
name: "one-remove-server-code",
|
|
46
50
|
visitor: {
|
|
47
51
|
Program: {
|
|
48
|
-
|
|
52
|
+
exit(path, state) {
|
|
49
53
|
const filename = state.filename;
|
|
50
54
|
if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules")) return;
|
|
51
55
|
const code = path.toString();
|
|
52
56
|
if (/generateStaticParams|loader/.test(code)) try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
// Also remove helper functions created by babel's async-to-generator transform
|
|
77
|
-
// These are named _loader, _generateStaticParams, etc.
|
|
78
|
-
FunctionDeclaration(funcPath) {
|
|
79
|
-
if (!funcPath.node.id) return;
|
|
80
|
-
const name = funcPath.node.id.name;
|
|
81
|
-
for (const serverExport of SERVER_EXPORTS) if (name === `_${serverExport}`) {
|
|
82
|
-
let isAsyncHelper = !1;
|
|
83
|
-
funcPath.traverse({
|
|
84
|
-
Identifier(idPath) {
|
|
85
|
-
idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
|
|
57
|
+
const freshAst = (0, import_parser.parse)(code, {
|
|
58
|
+
sourceType: "module",
|
|
59
|
+
plugins: ["typescript", "jsx"]
|
|
60
|
+
}),
|
|
61
|
+
referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(freshAst),
|
|
62
|
+
removed = {
|
|
63
|
+
loader: !1,
|
|
64
|
+
generateStaticParams: !1
|
|
65
|
+
};
|
|
66
|
+
traverse(freshAst, {
|
|
67
|
+
ExportNamedDeclaration(expPath) {
|
|
68
|
+
if (expPath.node.declaration?.type === "FunctionDeclaration" && expPath.node.declaration.id) {
|
|
69
|
+
const name = expPath.node.declaration.id.name;
|
|
70
|
+
(name === "loader" || name === "generateStaticParams") && (expPath.remove(), removed[name] = !0);
|
|
71
|
+
} else if (expPath.node.declaration?.type === "VariableDeclaration") {
|
|
72
|
+
const declarators = expPath.get("declaration").get("declarations");
|
|
73
|
+
for (let i = declarators.length - 1; i >= 0; i--) {
|
|
74
|
+
const declarator = declarators[i],
|
|
75
|
+
id = declarator.node.id;
|
|
76
|
+
id.type === "Identifier" && (id.name === "loader" || id.name === "generateStaticParams") && (declarator.remove(), removed[id.name] = !0);
|
|
86
77
|
}
|
|
87
|
-
|
|
78
|
+
expPath.node.declaration?.type === "VariableDeclaration" && expPath.node.declaration.declarations.length === 0 && expPath.remove();
|
|
79
|
+
}
|
|
88
80
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(0, import_babel_dead_code_elimination.deadCodeElimination)(
|
|
81
|
+
});
|
|
82
|
+
const removedFunctions = Object.keys(removed).filter(key => removed[key]);
|
|
83
|
+
if (removedFunctions.length === 0) return;
|
|
84
|
+
(0, import_babel_dead_code_elimination.deadCodeElimination)(freshAst, referenced), removed.loader && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removed.generateStaticParams && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
|
|
85
|
+
const out = generate(freshAst, {
|
|
86
|
+
retainLines: !0
|
|
87
|
+
}),
|
|
88
|
+
finalAst = (0, import_parser.parse)(out.code, {
|
|
89
|
+
sourceType: "module",
|
|
90
|
+
plugins: ["typescript", "jsx"]
|
|
91
|
+
});
|
|
92
|
+
path.node.body = finalAst.program.body, path.node.directives = finalAst.program.directives, process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedFunctions.length} server-only exports`);
|
|
93
93
|
} catch (error) {
|
|
94
|
-
console.warn(`[one/metro]
|
|
94
|
+
console.warn(`[one/metro] Tree shaking failed for ${filename}:`, error instanceof Error ? error.message : String(error));
|
|
95
95
|
}
|
|
96
|
-
const stubs = [];
|
|
97
|
-
removedExports.has("loader") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removedExports.has("generateStaticParams") && stubs.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
|
|
98
|
-
for (const stub of stubs) path.pushContainer("body", stub);
|
|
99
|
-
process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
}
|
|
@@ -36,12 +36,16 @@ __export(remove_server_code_exports, {
|
|
|
36
36
|
default: () => remove_server_code_default
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(remove_server_code_exports);
|
|
39
|
-
var
|
|
39
|
+
var import_generator = __toESM(require("@babel/generator"), 1),
|
|
40
|
+
import_parser = require("@babel/parser"),
|
|
41
|
+
import_traverse = __toESM(require("@babel/traverse"), 1),
|
|
42
|
+
t = __toESM(require("@babel/types"), 1),
|
|
40
43
|
import_babel_dead_code_elimination = require("babel-dead-code-elimination");
|
|
41
44
|
function _instanceof(left, right) {
|
|
42
45
|
return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
|
|
43
46
|
}
|
|
44
|
-
var
|
|
47
|
+
var generate = import_generator.default.default || import_generator.default,
|
|
48
|
+
traverse = import_traverse.default.default || import_traverse.default;
|
|
45
49
|
function removeServerCodePlugin(_, options) {
|
|
46
50
|
var {
|
|
47
51
|
routerRoot = "app"
|
|
@@ -50,97 +54,53 @@ function removeServerCodePlugin(_, options) {
|
|
|
50
54
|
name: "one-remove-server-code",
|
|
51
55
|
visitor: {
|
|
52
56
|
Program: {
|
|
53
|
-
|
|
57
|
+
exit(path, state) {
|
|
54
58
|
var filename = state.filename;
|
|
55
59
|
if (filename) {
|
|
56
60
|
var routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`);
|
|
57
61
|
if (routerRootPattern.test(filename) && !filename.includes("node_modules")) {
|
|
58
62
|
var code = path.toString();
|
|
59
63
|
if (/generateStaticParams|loader/.test(code)) try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var declarator = declaration.declarations[i];
|
|
81
|
-
if (t.isIdentifier(declarator.id)) {
|
|
82
|
-
var name1 = declarator.id.name;
|
|
83
|
-
SERVER_EXPORTS.includes(name1) && (removedExports.add(name1), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
// Also remove helper functions created by babel's async-to-generator transform
|
|
88
|
-
// These are named _loader, _generateStaticParams, etc.
|
|
89
|
-
FunctionDeclaration(funcPath) {
|
|
90
|
-
if (funcPath.node.id) {
|
|
91
|
-
var name = funcPath.node.id.name,
|
|
92
|
-
_iteratorNormalCompletion2 = !0,
|
|
93
|
-
_didIteratorError2 = !1,
|
|
94
|
-
_iteratorError2 = void 0;
|
|
95
|
-
try {
|
|
96
|
-
for (var _loop = function () {
|
|
97
|
-
var serverExport = _step2.value;
|
|
98
|
-
if (name === `_${serverExport}`) {
|
|
99
|
-
var isAsyncHelper = !1;
|
|
100
|
-
funcPath.traverse({
|
|
101
|
-
Identifier(idPath) {
|
|
102
|
-
idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
|
|
103
|
-
}
|
|
104
|
-
}), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
|
|
105
|
-
}
|
|
106
|
-
}, _iterator2 = SERVER_EXPORTS[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) _loop();
|
|
107
|
-
} catch (err) {
|
|
108
|
-
_didIteratorError2 = !0, _iteratorError2 = err;
|
|
109
|
-
} finally {
|
|
110
|
-
try {
|
|
111
|
-
!_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
|
|
112
|
-
} finally {
|
|
113
|
-
if (_didIteratorError2) throw _iteratorError2;
|
|
64
|
+
var freshAst = (0, import_parser.parse)(code, {
|
|
65
|
+
sourceType: "module",
|
|
66
|
+
plugins: ["typescript", "jsx"]
|
|
67
|
+
}),
|
|
68
|
+
referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(freshAst),
|
|
69
|
+
removed = {
|
|
70
|
+
loader: !1,
|
|
71
|
+
generateStaticParams: !1
|
|
72
|
+
};
|
|
73
|
+
traverse(freshAst, {
|
|
74
|
+
ExportNamedDeclaration(expPath) {
|
|
75
|
+
var _expPath_node_declaration, _expPath_node_declaration1;
|
|
76
|
+
if (((_expPath_node_declaration = expPath.node.declaration) === null || _expPath_node_declaration === void 0 ? void 0 : _expPath_node_declaration.type) === "FunctionDeclaration" && expPath.node.declaration.id) {
|
|
77
|
+
var name = expPath.node.declaration.id.name;
|
|
78
|
+
(name === "loader" || name === "generateStaticParams") && (expPath.remove(), removed[name] = !0);
|
|
79
|
+
} else if (((_expPath_node_declaration1 = expPath.node.declaration) === null || _expPath_node_declaration1 === void 0 ? void 0 : _expPath_node_declaration1.type) === "VariableDeclaration") {
|
|
80
|
+
for (var _expPath_node_declaration2, decl = expPath.get("declaration"), declarators = decl.get("declarations"), i = declarators.length - 1; i >= 0; i--) {
|
|
81
|
+
var declarator = declarators[i],
|
|
82
|
+
id = declarator.node.id;
|
|
83
|
+
id.type === "Identifier" && (id.name === "loader" || id.name === "generateStaticParams") && (declarator.remove(), removed[id.name] = !0);
|
|
114
84
|
}
|
|
85
|
+
((_expPath_node_declaration2 = expPath.node.declaration) === null || _expPath_node_declaration2 === void 0 ? void 0 : _expPath_node_declaration2.type) === "VariableDeclaration" && expPath.node.declaration.declarations.length === 0 && expPath.remove();
|
|
115
86
|
}
|
|
116
87
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
} catch (err) {
|
|
135
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
136
|
-
} finally {
|
|
137
|
-
try {
|
|
138
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
139
|
-
} finally {
|
|
140
|
-
if (_didIteratorError) throw _iteratorError;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
|
|
88
|
+
});
|
|
89
|
+
var removedFunctions = Object.keys(removed).filter(function (key) {
|
|
90
|
+
return removed[key];
|
|
91
|
+
});
|
|
92
|
+
if (removedFunctions.length === 0) return;
|
|
93
|
+
(0, import_babel_dead_code_elimination.deadCodeElimination)(freshAst, referenced), removed.loader && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("loader"), [], t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])))), removed.generateStaticParams && freshAst.program.body.push(t.exportNamedDeclaration(t.functionDeclaration(t.identifier("generateStaticParams"), [], t.blockStatement([]))));
|
|
94
|
+
var out = generate(freshAst, {
|
|
95
|
+
retainLines: !0
|
|
96
|
+
}),
|
|
97
|
+
finalAst = (0, import_parser.parse)(out.code, {
|
|
98
|
+
sourceType: "module",
|
|
99
|
+
plugins: ["typescript", "jsx"]
|
|
100
|
+
});
|
|
101
|
+
path.node.body = finalAst.program.body, path.node.directives = finalAst.program.directives, process.env.DEBUG && console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedFunctions.length} server-only exports`);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.warn(`[one/metro] Tree shaking failed for ${filename}:`, _instanceof(error, Error) ? error.message : String(error));
|
|
144
104
|
}
|
|
145
105
|
}
|
|
146
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","remove_server_code_exports","__export","default","remove_server_code_default","module","exports","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","remove_server_code_exports","__export","default","remove_server_code_default","module","exports","import_generator","__toESM","require","import_parser","import_traverse","t","import_babel_dead_code_elimination","_instanceof","left","right","Symbol","hasInstance","generate","traverse","removeServerCodePlugin","_","options","routerRoot","name","visitor","Program","exit","path","state","filename","routerRootPattern","RegExp","test","includes","code","toString","freshAst","parse","sourceType","plugins","referenced","findReferencedIdentifiers","removed","loader","generateStaticParams","ExportNamedDeclaration","expPath","_expPath_node_declaration","_expPath_node_declaration1","node","declaration","type","id","remove","_expPath_node_declaration2","decl","get","declarators","i","length","declarator","declarations","removedFunctions","Object","keys","filter","key","deadCodeElimination","program","body","push","exportNamedDeclaration","functionDeclaration","identifier","blockStatement","returnStatement","stringLiteral","out","retainLines","finalAst","directives","process","env","DEBUG","console","info","error","warn","Error","message","String"],"sources":["../../../src/babel-plugins/remove-server-code.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAC;AAAA;AAeAC,MAAA,CAAAC,OAAA,GAAAV,YAA0B,CAAAK,0BAAA;AAS1B,IAAAM,gBAAkB,GAAAC,OAAA,CAAAC,OAAA,mBAChB;EAAAC,aAAA,GACID,OAAA,gBAAY;EAAAE,eAAc,GAAAH,OAAc,CAAAC,OAAA;EAAAG,CAAA,GAAAJ,OAAA,CAAAC,OAAA;EAAAI,kCAAA,GAAAJ,OAAA;AAM9C,SAASK,YAAAC,IAAA,EAAAC,KAAuB;EAC9B,OAAMA,KAAE,YAAa,OAAUC,MAAA,UAAAD,KAAA,CAAAC,MAAA,CAAAC,WAAA,MAAAF,KAAA,CAAAC,MAAA,CAAAC,WAAA,EAAAH,IAAA,IAAAA,IAAA,YAAAC,KAAA;AAE/B;AAAO,IACLG,QAAM,GAAAZ,gBAAA,CAAAJ,OAAA,CAAAA,OAAA,IAAAI,gBAAA,CAAAJ,OAAA;EAAAiB,QAAA,GAAAT,eAAA,CAAAR,OAAA,CAAAA,OAAA,IAAAQ,eAAA,CAAAR,OAAA;AAAA,SACNkB,sBAASA,CAAAC,CAAA,EAAAC,OAAA;EA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AC,IAAA,CAAA5D,CAAA,CAAA6D,sBAAA,CAAA7D,CAAA,CAAA8D,mBAAA,CAAA9D,CAAA,CAAA+D,UAAA,8BAAA/D,CAAA,CAAAgE,cAAA;gBAAA,IACCG,GAAA,GAAA5D,QAAA,CAAemB,QAAE;oBACrB0C,WAAA;kBACF;kBAAAC,QAAA,OAAAvE,aAAA,CAAA6B,KAAA,EAAAwC,GAAA,CAAA3C,IAAA;oBACFI,UAAA;oBAIIC,OAAM,GAEV,YAAY,EACZ,KAAU;kBAGZ,CAAK;gBAKDZ,IAAA,CAAAsB,IAAA,CAAAoB,IAAA,GAAAU,QAAmB,CAAAX,OAAQ,CAAAC,IAAA,EAAA1C,IAAY,CAAAsB,IAAA,CAAA+B,UAAA,GAAiBD,QAAM,CAAAX,OAAA,CAAAY,UAAA,EAAAC,OAAA,CAAAC,GAAA,CAAAC,KAAA,IAAAC,OAAA,CAAAC,IAAA,2BAAAxD,QAAA,YAAAiC,gBAAA,CAAAH,MAAA;cAChE,SAAA2B,KAAA;gBAEJF,OAAS,CAAAG,IAAO,wCAAA1D,QAAA,KAAAjB,WAAA,CAAA0E,KAAA,EAAAE,KAAA,IAAAF,KAAA,CAAAG,OAAA,GAAAC,MAAA,CAAAJ,KAAA;cACd;YAAQ;UACyC;QACM;MACvD;IACF;EACF;AACF;AACF,IACFpF,0BAAA,GAAAiB,sBAAA","ignoreList":[]}
|
package/dist/cjs/cli/build.cjs
CHANGED
|
@@ -113,7 +113,7 @@ async function build(args) {
|
|
|
113
113
|
if (!process.env.ONE_SERVER_URL && deployConfig) {
|
|
114
114
|
const url = deployConfig.url ?? (deployConfig.target === "cloudflare" ? `https://${await getCloudflareProjectName(process.cwd())}.workers.dev` : void 0);
|
|
115
115
|
url && (process.env.ONE_SERVER_URL = url, console.info(`
|
|
116
|
-
\u2601\uFE0F
|
|
116
|
+
\u2601\uFE0F ONE_SERVER_URL: ${url}
|
|
117
117
|
`));
|
|
118
118
|
}
|
|
119
119
|
const outDir = viteLoadedConfig?.config?.build?.outDir ?? "dist",
|
|
@@ -134,7 +134,7 @@ async function build(args) {
|
|
|
134
134
|
}, args),
|
|
135
135
|
bundleTime = performance.now() - buildStartTime;
|
|
136
136
|
if (console.info(`
|
|
137
|
-
\u23F1\uFE0F
|
|
137
|
+
\u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
|
|
138
138
|
`), !vxrnOutput || args.platform !== "web") return;
|
|
139
139
|
const options = await (0, import_vxrn.fillOptions)(vxrnOutput.options, {
|
|
140
140
|
mode: "prod"
|
|
@@ -508,7 +508,7 @@ async function build(args) {
|
|
|
508
508
|
workerPool && (await (0, import_workerPool.terminateWorkerPool)());
|
|
509
509
|
const staticTime = performance.now() - staticStartTime;
|
|
510
510
|
console.info(`
|
|
511
|
-
\u23F1\uFE0F
|
|
511
|
+
\u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
|
|
512
512
|
`), (0, import_buildPage.printBuildTimings)(), await moveAllFiles(staticDir, clientDir), await import_fs_extra.default.rm(staticDir, {
|
|
513
513
|
force: !0,
|
|
514
514
|
recursive: !0
|
|
@@ -644,15 +644,15 @@ ${middlewareRouteMap.join(`,
|
|
|
644
644
|
|
|
645
645
|
const buildInfo = ${JSON.stringify(buildInfoForWriting)}
|
|
646
646
|
|
|
647
|
-
let
|
|
647
|
+
let server
|
|
648
648
|
|
|
649
649
|
export default {
|
|
650
650
|
async fetch(request, env, ctx) {
|
|
651
|
-
if (!
|
|
652
|
-
|
|
651
|
+
if (!server) {
|
|
652
|
+
server = await serve(buildInfo, lazyRoutes)
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
-
//
|
|
655
|
+
// set up static HTML fetcher for this request (uses ASSETS binding)
|
|
656
656
|
if (env.ASSETS) {
|
|
657
657
|
setFetchStaticHtml(async (path) => {
|
|
658
658
|
try {
|
|
@@ -663,34 +663,31 @@ export default {
|
|
|
663
663
|
return await assetResponse.text()
|
|
664
664
|
}
|
|
665
665
|
} catch (e) {
|
|
666
|
-
//
|
|
666
|
+
// asset not found
|
|
667
667
|
}
|
|
668
668
|
return null
|
|
669
669
|
})
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
try {
|
|
673
|
-
|
|
674
|
-
const response = await app.fetch(request, env, ctx)
|
|
673
|
+
const response = await server.fetch(request)
|
|
675
674
|
|
|
676
|
-
//
|
|
675
|
+
// no route matched or 404 \u2192 try static assets
|
|
677
676
|
if (!response || response.status === 404) {
|
|
678
677
|
if (env.ASSETS) {
|
|
679
678
|
try {
|
|
680
679
|
const assetResponse = await env.ASSETS.fetch(request)
|
|
681
|
-
// If asset exists, return it
|
|
682
680
|
if (assetResponse && assetResponse.status !== 404) {
|
|
683
681
|
return assetResponse
|
|
684
682
|
}
|
|
685
683
|
} catch (e) {
|
|
686
|
-
//
|
|
684
|
+
// asset not found, continue with original response
|
|
687
685
|
}
|
|
688
686
|
}
|
|
689
687
|
}
|
|
690
688
|
|
|
691
689
|
return response
|
|
692
690
|
} finally {
|
|
693
|
-
// Clean up per-request state
|
|
694
691
|
setFetchStaticHtml(null)
|
|
695
692
|
}
|
|
696
693
|
}
|
|
@@ -783,9 +780,7 @@ export default {
|
|
|
783
780
|
`), postBuildLogs.forEach(log => {
|
|
784
781
|
console.info(` \xB7 ${log}`);
|
|
785
782
|
})), console.info(`
|
|
786
|
-
|
|
787
|
-
\u{1F49B} build complete
|
|
788
|
-
|
|
783
|
+
\u{1F49B} build complete
|
|
789
784
|
`);
|
|
790
785
|
}
|
|
791
786
|
const TRAILING_INDEX_REGEX = /\/index(\.(web))?/;
|
|
@@ -139,7 +139,7 @@ async function build(args) {
|
|
|
139
139
|
var _deployConfig_url,
|
|
140
140
|
url = (_deployConfig_url = deployConfig.url) !== null && _deployConfig_url !== void 0 ? _deployConfig_url : deployConfig.target === "cloudflare" ? `https://${await getCloudflareProjectName(process.cwd())}.workers.dev` : void 0;
|
|
141
141
|
url && (process.env.ONE_SERVER_URL = url, console.info(`
|
|
142
|
-
\u2601\uFE0F
|
|
142
|
+
\u2601\uFE0F ONE_SERVER_URL: ${url}
|
|
143
143
|
`));
|
|
144
144
|
}
|
|
145
145
|
var outDir = (_ref = viteLoadedConfig == null || (_viteLoadedConfig_config = viteLoadedConfig.config) === null || _viteLoadedConfig_config === void 0 || (_viteLoadedConfig_config_build = _viteLoadedConfig_config.build) === null || _viteLoadedConfig_config_build === void 0 ? void 0 : _viteLoadedConfig_config_build.outDir) !== null && _ref !== void 0 ? _ref : "dist",
|
|
@@ -160,7 +160,7 @@ async function build(args) {
|
|
|
160
160
|
}, args),
|
|
161
161
|
bundleTime = performance.now() - buildStartTime;
|
|
162
162
|
if (console.info(`
|
|
163
|
-
\u23F1\uFE0F
|
|
163
|
+
\u23F1\uFE0F vite bundle: ${(bundleTime / 1e3).toFixed(2)}s
|
|
164
164
|
`), !vxrnOutput || args.platform !== "web") return;
|
|
165
165
|
var options = await (0, import_vxrn.fillOptions)(vxrnOutput.options, {
|
|
166
166
|
mode: "prod"
|
|
@@ -775,7 +775,7 @@ async function build(args) {
|
|
|
775
775
|
workerPool && (await (0, import_workerPool.terminateWorkerPool)());
|
|
776
776
|
var staticTime = performance.now() - staticStartTime;
|
|
777
777
|
console.info(`
|
|
778
|
-
\u23F1\uFE0F
|
|
778
|
+
\u23F1\uFE0F static routes: ${(staticTime / 1e3).toFixed(2)}s (${builtRoutes.length} pages)
|
|
779
779
|
`), (0, import_buildPage.printBuildTimings)(), await moveAllFiles(staticDir, clientDir), await import_fs_extra.default.rm(staticDir, {
|
|
780
780
|
force: !0,
|
|
781
781
|
recursive: !0
|
|
@@ -1012,15 +1012,15 @@ ${middlewareRouteMap.join(`,
|
|
|
1012
1012
|
|
|
1013
1013
|
const buildInfo = ${JSON.stringify(buildInfoForWriting)}
|
|
1014
1014
|
|
|
1015
|
-
let
|
|
1015
|
+
let server
|
|
1016
1016
|
|
|
1017
1017
|
export default {
|
|
1018
1018
|
async fetch(request, env, ctx) {
|
|
1019
|
-
if (!
|
|
1020
|
-
|
|
1019
|
+
if (!server) {
|
|
1020
|
+
server = await serve(buildInfo, lazyRoutes)
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
-
//
|
|
1023
|
+
// set up static HTML fetcher for this request (uses ASSETS binding)
|
|
1024
1024
|
if (env.ASSETS) {
|
|
1025
1025
|
setFetchStaticHtml(async (path) => {
|
|
1026
1026
|
try {
|
|
@@ -1031,34 +1031,31 @@ export default {
|
|
|
1031
1031
|
return await assetResponse.text()
|
|
1032
1032
|
}
|
|
1033
1033
|
} catch (e) {
|
|
1034
|
-
//
|
|
1034
|
+
// asset not found
|
|
1035
1035
|
}
|
|
1036
1036
|
return null
|
|
1037
1037
|
})
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
1040
|
try {
|
|
1041
|
-
|
|
1042
|
-
const response = await app.fetch(request, env, ctx)
|
|
1041
|
+
const response = await server.fetch(request)
|
|
1043
1042
|
|
|
1044
|
-
//
|
|
1043
|
+
// no route matched or 404 \u2192 try static assets
|
|
1045
1044
|
if (!response || response.status === 404) {
|
|
1046
1045
|
if (env.ASSETS) {
|
|
1047
1046
|
try {
|
|
1048
1047
|
const assetResponse = await env.ASSETS.fetch(request)
|
|
1049
|
-
// If asset exists, return it
|
|
1050
1048
|
if (assetResponse && assetResponse.status !== 404) {
|
|
1051
1049
|
return assetResponse
|
|
1052
1050
|
}
|
|
1053
1051
|
} catch (e) {
|
|
1054
|
-
//
|
|
1052
|
+
// asset not found, continue with original response
|
|
1055
1053
|
}
|
|
1056
1054
|
}
|
|
1057
1055
|
}
|
|
1058
1056
|
|
|
1059
1057
|
return response
|
|
1060
1058
|
} finally {
|
|
1061
|
-
// Clean up per-request state
|
|
1062
1059
|
setFetchStaticHtml(null)
|
|
1063
1060
|
}
|
|
1064
1061
|
}
|
|
@@ -1152,9 +1149,7 @@ export default {
|
|
|
1152
1149
|
`), postBuildLogs.forEach(function (log) {
|
|
1153
1150
|
console.info(` \xB7 ${log}`);
|
|
1154
1151
|
})), console.info(`
|
|
1155
|
-
|
|
1156
|
-
\u{1F49B} build complete
|
|
1157
|
-
|
|
1152
|
+
\u{1F49B} build complete
|
|
1158
1153
|
`);
|
|
1159
1154
|
}
|
|
1160
1155
|
var TRAILING_INDEX_REGEX = /\/index(\.(web))?/;
|