one 1.2.45 → 1.2.46

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 (28) hide show
  1. package/dist/cjs/babel-plugins/remove-server-code.cjs +105 -0
  2. package/dist/cjs/babel-plugins/remove-server-code.js +125 -0
  3. package/dist/cjs/babel-plugins/remove-server-code.js.map +6 -0
  4. package/dist/cjs/babel-plugins/remove-server-code.native.js +153 -0
  5. package/dist/cjs/babel-plugins/remove-server-code.native.js.map +1 -0
  6. package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +8 -3
  7. package/dist/cjs/metro-config/getViteMetroPluginOptions.js +9 -1
  8. package/dist/cjs/metro-config/getViteMetroPluginOptions.js.map +1 -1
  9. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +8 -3
  10. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  11. package/dist/esm/babel-plugins/remove-server-code.js +102 -0
  12. package/dist/esm/babel-plugins/remove-server-code.js.map +6 -0
  13. package/dist/esm/babel-plugins/remove-server-code.mjs +71 -0
  14. package/dist/esm/babel-plugins/remove-server-code.mjs.map +1 -0
  15. package/dist/esm/babel-plugins/remove-server-code.native.js +116 -0
  16. package/dist/esm/babel-plugins/remove-server-code.native.js.map +1 -0
  17. package/dist/esm/metro-config/getViteMetroPluginOptions.js +9 -1
  18. package/dist/esm/metro-config/getViteMetroPluginOptions.js.map +1 -1
  19. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +7 -2
  20. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
  21. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +7 -2
  22. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  23. package/package.json +14 -9
  24. package/src/babel-plugins/remove-server-code.ts +227 -0
  25. package/src/metro-config/getViteMetroPluginOptions.ts +10 -2
  26. package/types/babel-plugins/remove-server-code.d.ts +23 -0
  27. package/types/babel-plugins/remove-server-code.d.ts.map +1 -0
  28. package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
@@ -0,0 +1,105 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var remove_server_code_exports = {};
33
+ __export(remove_server_code_exports, {
34
+ default: () => remove_server_code_default
35
+ });
36
+ module.exports = __toCommonJS(remove_server_code_exports);
37
+ var t = __toESM(require("@babel/types"), 1),
38
+ import_babel_dead_code_elimination = require("babel-dead-code-elimination");
39
+ const SERVER_EXPORTS = ["loader", "generateStaticParams"];
40
+ function removeServerCodePlugin(_, options) {
41
+ const {
42
+ routerRoot = "app"
43
+ } = options;
44
+ return {
45
+ name: "one-remove-server-code",
46
+ visitor: {
47
+ Program: {
48
+ enter(path, state) {
49
+ const filename = state.filename;
50
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules")) return;
51
+ const code = path.toString();
52
+ if (/generateStaticParams|loader/.test(code)) try {
53
+ state.referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(path.node);
54
+ } catch (error) {
55
+ console.warn(`[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`, error instanceof Error ? error.message : String(error));
56
+ }
57
+ },
58
+ exit(path, state) {
59
+ const filename = state.filename;
60
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules") || !state.referenced) return;
61
+ const removedExports = /* @__PURE__ */new Set();
62
+ if (path.traverse({
63
+ ExportNamedDeclaration(exportPath) {
64
+ const declaration = exportPath.node.declaration;
65
+ if (t.isFunctionDeclaration(declaration) && declaration.id) {
66
+ const name = declaration.id.name;
67
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
68
+ } else if (t.isVariableDeclaration(declaration)) for (let i = declaration.declarations.length - 1; i >= 0; i--) {
69
+ const declarator = declaration.declarations[i];
70
+ if (t.isIdentifier(declarator.id)) {
71
+ const name = declarator.id.name;
72
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
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());
86
+ }
87
+ }), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
88
+ }
89
+ }
90
+ }), removedExports.size === 0) return;
91
+ try {
92
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(path.node, state.referenced);
93
+ } catch (error) {
94
+ console.warn(`[one/metro] Dead code elimination failed for ${filename}:`, error instanceof Error ? error.message : String(error));
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
+ console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
100
+ }
101
+ }
102
+ }
103
+ };
104
+ }
105
+ var remove_server_code_default = removeServerCodePlugin;
@@ -0,0 +1,125 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var remove_server_code_exports = {};
24
+ __export(remove_server_code_exports, {
25
+ default: () => remove_server_code_default
26
+ });
27
+ module.exports = __toCommonJS(remove_server_code_exports);
28
+ var t = __toESM(require("@babel/types"), 1), import_babel_dead_code_elimination = require("babel-dead-code-elimination");
29
+ const SERVER_EXPORTS = ["loader", "generateStaticParams"];
30
+ function removeServerCodePlugin(_, options) {
31
+ const { routerRoot = "app" } = options;
32
+ return {
33
+ name: "one-remove-server-code",
34
+ visitor: {
35
+ Program: {
36
+ enter(path, state) {
37
+ const filename = state.filename;
38
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules"))
39
+ return;
40
+ const code = path.toString();
41
+ if (/generateStaticParams|loader/.test(code))
42
+ try {
43
+ state.referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(path.node);
44
+ } catch (error) {
45
+ console.warn(
46
+ `[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`,
47
+ error instanceof Error ? error.message : String(error)
48
+ );
49
+ }
50
+ },
51
+ exit(path, state) {
52
+ const filename = state.filename;
53
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules") || !state.referenced)
54
+ return;
55
+ const removedExports = /* @__PURE__ */ new Set();
56
+ if (path.traverse({
57
+ ExportNamedDeclaration(exportPath) {
58
+ const declaration = exportPath.node.declaration;
59
+ if (t.isFunctionDeclaration(declaration) && declaration.id) {
60
+ const name = declaration.id.name;
61
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
62
+ } else if (t.isVariableDeclaration(declaration))
63
+ for (let i = declaration.declarations.length - 1; i >= 0; i--) {
64
+ const declarator = declaration.declarations[i];
65
+ if (t.isIdentifier(declarator.id)) {
66
+ const name = declarator.id.name;
67
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
68
+ }
69
+ }
70
+ },
71
+ // Also remove helper functions created by babel's async-to-generator transform
72
+ // These are named _loader, _generateStaticParams, etc.
73
+ FunctionDeclaration(funcPath) {
74
+ if (!funcPath.node.id) return;
75
+ const name = funcPath.node.id.name;
76
+ for (const serverExport of SERVER_EXPORTS)
77
+ if (name === `_${serverExport}`) {
78
+ let isAsyncHelper = !1;
79
+ funcPath.traverse({
80
+ Identifier(idPath) {
81
+ idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
82
+ }
83
+ }), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
84
+ }
85
+ }
86
+ }), removedExports.size === 0)
87
+ return;
88
+ try {
89
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(path.node, state.referenced);
90
+ } catch (error) {
91
+ console.warn(
92
+ `[one/metro] Dead code elimination failed for ${filename}:`,
93
+ error instanceof Error ? error.message : String(error)
94
+ );
95
+ }
96
+ const stubs = [];
97
+ removedExports.has("loader") && stubs.push(
98
+ t.exportNamedDeclaration(
99
+ t.functionDeclaration(
100
+ t.identifier("loader"),
101
+ [],
102
+ t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])
103
+ )
104
+ )
105
+ ), removedExports.has("generateStaticParams") && stubs.push(
106
+ t.exportNamedDeclaration(
107
+ t.functionDeclaration(
108
+ t.identifier("generateStaticParams"),
109
+ [],
110
+ t.blockStatement([])
111
+ )
112
+ )
113
+ );
114
+ for (const stub of stubs)
115
+ path.pushContainer("body", stub);
116
+ console.info(
117
+ ` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`
118
+ );
119
+ }
120
+ }
121
+ }
122
+ };
123
+ }
124
+ var remove_server_code_default = removeServerCodePlugin;
125
+ //# sourceMappingURL=remove-server-code.js.map
@@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CAAC;AAAA,gBACD,EAAE,eAAe,CAAC,EAAE,gBAAgB,EAAE,cAAc,kBAAkB,CAAC,CAAC,CAAC;AAAA,cAC3E;AAAA,YACF;AAAA,UACF,GAGE,eAAe,IAAI,sBAAsB,KAE3C,MAAM;AAAA,YACJ,EAAE;AAAA,cACA,EAAE;AAAA,gBACA,EAAE,WAAW,sBAAsB;AAAA,gBACnC,CAAC;AAAA,gBACD,EAAE,eAAe,CAAC,CAAC;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAIF,qBAAW,QAAQ;AACjB,iBAAK,cAAc,QAAQ,IAAI;AAGjC,kBAAQ;AAAA,YACN,0BAAmB,QAAQ,YAAY,eAAe,IAAI;AAAA,UAC5D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,6BAAQ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
34
+ var remove_server_code_exports = {};
35
+ __export(remove_server_code_exports, {
36
+ default: () => remove_server_code_default
37
+ });
38
+ module.exports = __toCommonJS(remove_server_code_exports);
39
+ var t = __toESM(require("@babel/types"), 1),
40
+ import_babel_dead_code_elimination = require("babel-dead-code-elimination");
41
+ function _instanceof(left, right) {
42
+ return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
43
+ }
44
+ var SERVER_EXPORTS = ["loader", "generateStaticParams"];
45
+ function removeServerCodePlugin(_, options) {
46
+ var {
47
+ routerRoot = "app"
48
+ } = options;
49
+ return {
50
+ name: "one-remove-server-code",
51
+ visitor: {
52
+ Program: {
53
+ enter(path, state) {
54
+ var filename = state.filename;
55
+ if (filename) {
56
+ var routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`);
57
+ if (routerRootPattern.test(filename) && !filename.includes("node_modules")) {
58
+ var code = path.toString();
59
+ if (/generateStaticParams|loader/.test(code)) try {
60
+ state.referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(path.node);
61
+ } catch (error) {
62
+ console.warn(`[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`, _instanceof(error, Error) ? error.message : String(error));
63
+ }
64
+ }
65
+ }
66
+ },
67
+ exit(path, state) {
68
+ var filename = state.filename;
69
+ if (filename) {
70
+ var routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`);
71
+ if (routerRootPattern.test(filename) && !filename.includes("node_modules") && state.referenced) {
72
+ var removedExports = /* @__PURE__ */new Set();
73
+ if (path.traverse({
74
+ ExportNamedDeclaration(exportPath) {
75
+ var declaration = exportPath.node.declaration;
76
+ if (t.isFunctionDeclaration(declaration) && declaration.id) {
77
+ var name = declaration.id.name;
78
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
79
+ } else if (t.isVariableDeclaration(declaration)) for (var i = declaration.declarations.length - 1; i >= 0; i--) {
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;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }), removedExports.size !== 0) {
119
+ try {
120
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(path.node, state.referenced);
121
+ } catch (error) {
122
+ console.warn(`[one/metro] Dead code elimination failed for ${filename}:`, _instanceof(error, Error) ? error.message : String(error));
123
+ }
124
+ var stubs = [];
125
+ 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([]))));
126
+ var _iteratorNormalCompletion = !0,
127
+ _didIteratorError = !1,
128
+ _iteratorError = void 0;
129
+ try {
130
+ for (var _iterator = stubs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
131
+ var stub = _step.value;
132
+ path.pushContainer("body", stub);
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
+ console.info(` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`);
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ };
151
+ }
152
+ var remove_server_code_default = removeServerCodePlugin;
153
+ //# sourceMappingURL=remove-server-code.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","remove_server_code_exports","__export","default","remove_server_code_default","module","exports","t","__toESM","require","import_babel_dead_code_elimination","_instanceof","left","right","Symbol","hasInstance","SERVER_EXPORTS","removeServerCodePlugin","_","options","routerRoot","name","visitor","Program","enter","path","state","filename","routerRootPattern","RegExp","test","includes","code","toString","referenced","findReferencedIdentifiers","node","error","console","warn","Error","message","String","exit","removedExports","Set","traverse","ExportNamedDeclaration","exportPath","declaration","isFunctionDeclaration","id","add","remove","isVariableDeclaration","i","declarations","length","declarator","isIdentifier","name1","splice","FunctionDeclaration","funcPath","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_loop","serverExport","_step2","isAsyncHelper","Identifier","idPath","stop","_iterator2","iterator","next","done","err","return","size","deadCodeElimination","stubs","has","push","exportNamedDeclaration","functionDeclaration","identifier","blockStatement","returnStatement","stringLiteral","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","_step","stub","pushContainer"],"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;AAkBAC,MAAA,CAAAC,OAAmB,GAAAV,YAAA,CAAAK,0BACnB;AAEA,IAAAM,CAAA,GAAMC,OAAA,CAAAC,OAAiB,CAAC,cAAU;EAAAC,kCAAsB,GAAAD,OAAA;AAQxD,SAASE,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,cAAM,YACN,EAAS,sBACE;AAEL,SAAAC,sBAAiBA,CAAAC,CAAM,EAAAC,OAAA;EAcvB;IAAAC,UAXK;EAMD,CADsB,GAAAD,OAAI;EAO5B;IAIFE,IAAA,0BAAkB;IAClBC,OAAA;MAMAC,OAAA;QACEC,MAAAC,IAAA,EAAMC,KAAA;UAAuD,IAC/DC,QAAS,GAAAD,KAAO,CAAAC,QAAA;UACd,IAAAA,QAAQ;YAAA,IACNC,iBAAA,OAAAC,MAAA,WAAyCT,UAAQ;YAAA,IACjDQ,iBAAiB,CAAAE,IAAA,CAAAH,QAAc,MAAAA,QAAU,CAAAI,QAAY;cACv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A;kBACF;gBAEO,SAAAlB,GAAA","ignoreList":[]}
@@ -34,9 +34,9 @@ __export(getViteMetroPluginOptions_exports, {
34
34
  getViteMetroPluginOptions: () => getViteMetroPluginOptions
35
35
  });
36
36
  module.exports = __toCommonJS(getViteMetroPluginOptions_exports);
37
- var import_node_module = __toESM(require("node:module"), 1),
37
+ var import_micromatch = __toESM(require("micromatch"), 1),
38
+ import_node_module = __toESM(require("node:module"), 1),
38
39
  import_node_path = __toESM(require("node:path"), 1),
39
- import_micromatch = __toESM(require("micromatch"), 1),
40
40
  import_tsconfig_paths = __toESM(require("tsconfig-paths"), 1),
41
41
  import_glob_patterns = require("../router/glob-patterns.cjs");
42
42
  function getViteMetroPluginOptions({
@@ -108,7 +108,12 @@ function getViteMetroPluginOptions({
108
108
  return typeof userDefaultConfigOverrides == "function" && (config = userDefaultConfigOverrides(config)), config;
109
109
  },
110
110
  babelConfig: {
111
- plugins: [["babel-plugin-module-resolver", {
111
+ plugins: [
112
+ // Remove server-only code (loader, generateStaticParams) from route files
113
+ // This must run early to prevent server-only imports from being bundled
114
+ ["one/babel-plugin-remove-server-code", {
115
+ routerRoot: relativeRouterRoot
116
+ }], ["babel-plugin-module-resolver", {
112
117
  alias: {
113
118
  // "vite-tsconfig-paths" for Metro
114
119
  ...Object.fromEntries(Object.entries(tsconfigPathsConfigLoadResult.paths).map(([k, v]) => {
@@ -25,7 +25,7 @@ __export(getViteMetroPluginOptions_exports, {
25
25
  getViteMetroPluginOptions: () => getViteMetroPluginOptions
26
26
  });
27
27
  module.exports = __toCommonJS(getViteMetroPluginOptions_exports);
28
- var import_node_module = __toESM(require("node:module"), 1), import_node_path = __toESM(require("node:path"), 1), import_micromatch = __toESM(require("micromatch"), 1), import_tsconfig_paths = __toESM(require("tsconfig-paths"), 1), import_glob_patterns = require("../router/glob-patterns");
28
+ var import_micromatch = __toESM(require("micromatch"), 1), import_node_module = __toESM(require("node:module"), 1), import_node_path = __toESM(require("node:path"), 1), import_tsconfig_paths = __toESM(require("tsconfig-paths"), 1), import_glob_patterns = require("../router/glob-patterns");
29
29
  function getViteMetroPluginOptions({
30
30
  projectRoot,
31
31
  relativeRouterRoot,
@@ -104,6 +104,14 @@ function getViteMetroPluginOptions({
104
104
  },
105
105
  babelConfig: {
106
106
  plugins: [
107
+ // Remove server-only code (loader, generateStaticParams) from route files
108
+ // This must run early to prevent server-only imports from being bundled
109
+ [
110
+ "one/babel-plugin-remove-server-code",
111
+ {
112
+ routerRoot: relativeRouterRoot
113
+ }
114
+ ],
107
115
  [
108
116
  "babel-plugin-module-resolver",
109
117
  {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/metro-config/getViteMetroPluginOptions.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmB,oCACnB,mBAAiB,kCAEjB,oBAAe,mCACf,wBAA0B,uCAC1B,uBAGO;AAEA,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAQsC;AACpC,QAAM,gCAAgC,sBAAAA,QAAc,WAAW,WAAW;AAE1E,MAAI,8BAA8B,eAAe;AAC/C,UAAM,IAAI,MAAM,yDAAyD;AAG3E,QAAMC,WAAU,mBAAAC,QAAO,cAAc,WAAW,GAC1C,YAAYD,SAAQ,QAAQ,iCAAiC;AAAA,IACjE,OAAO,CAAC,WAAW;AAAA,EACrB,CAAC,GAEK,iBAAiBA,SAAQ,QAAQ,mBAAmB;AAAA,IACxD,OAAO,CAAC,WAAW;AAAA,EACrB,CAAC,GAEK,mCAAmC,MAAM;AAC7C,UAAM,aAAa;AAAA,MACjB,IAAI,qBAAqB,CAAC,GAAG,IAAI,CAAC,YAAY,kBAAAE,QAAG,OAAO,OAAO,CAAC;AAAA,MAChE,GAAG,0DAAqC,IAAI,CAAC,YAAY,kBAAAA,QAAG,OAAO,OAAO,CAAC;AAAA,MAC3E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E,wBAAM,MACA,EAAE,SAAS,IAAI,IACV,EAAE,QAAQ,SAAS,EAAE,IAKvB,GAAG,CAAC;AAGb,sBAAI,QAAQ,EAAE,CAAC,EAAE,QAAQ,SAAS,EAAE;AAEpC,yBAAK,MAAM,WAAW,IAAI,MACxB,QAAQ,KAAK,KAAK,KAGb,CAAC,KAAK,KAAK;AAAA,gBACpB,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,UACE;AAAA,UACA;AAAA,YACE,uCAAuC,iBAAAC,QAAK;AAAA,cAC1C,iBAAAA,QAAK,QAAQ,cAAc;AAAA,cAC3B,iBAAAA,QAAK,KAAK,aAAa,kBAAkB;AAAA,YAC3C;AAAA,YACA,6BAA6B;AAAA,YAC7B,yCAAyC;AAAA,YACzC,wBAAwB,MAAM;AAC5B,kBAAI,CAAC,UAAW;AAEhB,oBAAM,kBACJ,OAAO,aAAc,WACjB,YACA,UAAU,UAAU,UAAU,OAAO,UAAU;AACrD,kBAAK;AAEL,uBAAO,iBAAAA,QAAK;AAAA,kBACV,iBAAAA,QAAK,QAAQ,cAAc;AAAA,kBAC3B,iBAAAA,QAAK,KAAK,aAAa,eAAe;AAAA,gBACxC;AAAA,YACF,GAAG;AAAA,UACL;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
5
5
  "names": ["tsconfigPaths", "require", "module", "mm", "path"]
6
6
  }
@@ -36,9 +36,9 @@ __export(getViteMetroPluginOptions_exports, {
36
36
  getViteMetroPluginOptions: () => getViteMetroPluginOptions
37
37
  });
38
38
  module.exports = __toCommonJS(getViteMetroPluginOptions_exports);
39
- var import_module = __toESM(require("module"), 1),
39
+ var import_micromatch = __toESM(require("micromatch"), 1),
40
+ import_module = __toESM(require("module"), 1),
40
41
  import_path = __toESM(require("path"), 1),
41
- import_micromatch = __toESM(require("micromatch"), 1),
42
42
  import_tsconfig_paths = __toESM(require("tsconfig-paths"), 1),
43
43
  import_glob_patterns = require("../router/glob-patterns.native.js");
44
44
  function getViteMetroPluginOptions(param) {
@@ -125,7 +125,12 @@ function getViteMetroPluginOptions(param) {
125
125
  return typeof userDefaultConfigOverrides == "function" && (config = userDefaultConfigOverrides(config)), config;
126
126
  },
127
127
  babelConfig: {
128
- plugins: [["babel-plugin-module-resolver", {
128
+ plugins: [
129
+ // Remove server-only code (loader, generateStaticParams) from route files
130
+ // This must run early to prevent server-only imports from being bundled
131
+ ["one/babel-plugin-remove-server-code", {
132
+ routerRoot: relativeRouterRoot
133
+ }], ["babel-plugin-module-resolver", {
129
134
  alias: {
130
135
  // "vite-tsconfig-paths" for Metro
131
136
  ...Object.fromEntries(Object.entries(tsconfigPathsConfigLoadResult.paths).map(function (param2) {
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getViteMetroPluginOptions_exports","__export","getViteMetroPluginOptions","module","exports","import_module","__toESM","require","import_path","import_micromatch","import_tsconfig_paths","import_glob_patterns","param","projectRoot","relativeRouterRoot","ignoredRouteFiles","userDefaultConfigOverrides","setupFile","tsconfigPathsConfigLoadResult","default","loadConfig","resultType","Error","require2","createRequire","emptyPath","resolve","paths","metroEntryPath","routerRequireContextRegexString","excludeRes","map","pattern","makeRe","ROUTE_NATIVE_EXCLUSION_GLOB_PATTERNS","API_ROUTE_GLOB_PATTERN","supportedRegexMustStartWith","String","raw","supportedRegexMustEndWith","negativeLookaheadGroups","re","i","reSource","source","startsWith","endsWith","ignoredRouteFile","rePart","slice","length","join","defaultConfigOverrides","defaultConfig","_defaultConfig_resolver","_defaultConfig_resolver1","_defaultConfig_resolver2","config","resolver","extraNodeModules","nodeModulesPaths","absoluteBaseUrl","resolveRequest","context","moduleName","platform","_defaultConfig_resolver3","console","warn","type","filePath","test","defaultResolveRequest","res","babelConfig","plugins","alias","Object","fromEntries","entries","param2","k","v","key","replace","ONE_ROUTER_APP_ROOT_RELATIVE_TO_ENTRY","relative","dirname","ONE_ROUTER_ROOT_FOLDER_NAME","ONE_ROUTER_REQUIRE_CONTEXT_REGEX_STRING","ONE_SETUP_FILE_NATIVE","nativeSetupFile","native","ios","android"],"sources":["../../../src/metro-config/getViteMetroPluginOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,iCAAA;AAAAC,QAAA,CAAAD,iCAAA;EAAAE,yBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAmB,CAAAK,iCACnB;AASO,IAAAK,aAAS,GAAAC,OAAA,CAAAC,OAA0B;EAAAC,WAAA,GAAAF,OAAA,CAAAC,OAAA;EAAAE,iBAAA,GAAAH,OAAA,CAAAC,OAAA;EAAAG,qBAAA,GAAAJ,OAAA,CAAAC,OAAA;EAAAI,oBAAA,GAAAJ,OAAA;AAAA,SACxCL,0BAAAU,KAAA;EACA;MAAAC,WAAA;MAAAC,kBAAA;MAAAC,iBAAA;MAAAC,0BAAA;MAAAC;IAAA,IAAAL,KAAA;IAAAM,6BAAA,GAAAR,qBAAA,CAAAS,OAAA,CAAAC,UAAA,CAAAP,WAAA;EACA,IAAAK,6BAAA,CAAAG,UAAA,eACA,UAAAC,KAAA;EACA,IAAAC,QAAA,GAAAlB,aAAA,CAAAc,OAAA,CAAAK,aAAA,CAAAX,WAAA;IAAAY,SAAA,GAAAF,QAAA,CAAAG,OAAA;MASoCC,KAAA,GACpCd,WAAM;IAGJ;IAAAe,cAAgB,GAAAL,QAAA,CAAAG,OAAA;MAGlBC,KAAM,GAEJd,WAAQ;IAGgD,EACxD;IAAAgB,+BAAmB;MACpB,IAEKC,UAAA,IACJ,IAAMf,iBAAa,QAAAgB,GAAA,WAAAC,OAAA;UACjB,OAAIvB,iBAAsB,CAAAU,OAAQ,CAAAc,MAAA,CAAAD,OAAY;QAC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AAA,EAAAC,CAAA,IAAAF,MAAA;cAAAG,GAAA;gBACH,OAAAF,CAAA,CAAAnC,QAAA,SAAAmC,CAAA,CAAAG,OAAA,mBAAAH,CAAA;cACF;cAAAlF,KAAA,GAAAmF,CAAA,IAAAE,OAAA;YACF,OAAArF,KAAA,CAAA8C,UAAA,WAAA9C,KAAA,QAAAA,KAAA,MACFoF,GAAA,EACApF,KAAA,CACE;UACA;QACE;MAA4C,EACf,EACc,CAC3C,mCAC6B;QAE7BsF,qCAA8B,EAAA7E,WAAA,CAAAW,OAAA,CAAAmE,QAAA,CAAA9E,WAAA,CAAAW,OAAA,CAAAoE,OAAA,CAAA3D,cAAA,GAAApB,WAAA,CAAAW,OAAA,CAAAgC,IAAA,CAAAtC,WAAA,EAAAC,kBAAA;QAC5B0E,2BAAgB,EAAA1E,kBAAA;QAEhB2E,uCACS,EAAA5D,+BAEH;QACN6D,qBAAK;UAEL,IAAAzE,SAAO;YAAK,IACV0E,eAAA,UAAK1E,SAAQ,YAAc,GAAAA,SAAA,GAAAA,SAAA,CAAA2E,MAAA,IAAA3E,SAAA,CAAA4E,GAAA,IAAA5E,SAAA,CAAA6E,OAAA;YAAA,IAC3BH,eAAA,EACF,OAAAnF,WAAA,CAAAW,OAAA,CAAAmE,QAAA,CAAA9E,WAAA,CAAAW,OAAA,CAAAoE,OAAA,CAAA3D,cAAA,GAAApB,WAAA,CAAAW,OAAA,CAAAgC,IAAA,CAAAtC,WAAA,EAAA8E,eAAA;UACF;QACF;MACF,EACF;IAEJ;EACF","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getViteMetroPluginOptions_exports","__export","getViteMetroPluginOptions","module","exports","import_micromatch","__toESM","require","import_module","import_path","import_tsconfig_paths","import_glob_patterns","param","projectRoot","relativeRouterRoot","ignoredRouteFiles","userDefaultConfigOverrides","setupFile","tsconfigPathsConfigLoadResult","default","loadConfig","resultType","Error","require2","createRequire","emptyPath","resolve","paths","metroEntryPath","routerRequireContextRegexString","excludeRes","map","pattern","makeRe","ROUTE_NATIVE_EXCLUSION_GLOB_PATTERNS","API_ROUTE_GLOB_PATTERN","supportedRegexMustStartWith","String","raw","supportedRegexMustEndWith","negativeLookaheadGroups","re","i","reSource","source","startsWith","endsWith","ignoredRouteFile","rePart","slice","length","join","defaultConfigOverrides","defaultConfig","_defaultConfig_resolver","_defaultConfig_resolver1","_defaultConfig_resolver2","config","resolver","extraNodeModules","nodeModulesPaths","absoluteBaseUrl","resolveRequest","context","moduleName","platform","_defaultConfig_resolver3","console","warn","type","filePath","test","defaultResolveRequest","res","babelConfig","plugins","routerRoot","alias","Object","fromEntries","entries","param2","k","v","key","replace","ONE_ROUTER_APP_ROOT_RELATIVE_TO_ENTRY","relative","dirname","ONE_ROUTER_ROOT_FOLDER_NAME","ONE_ROUTER_REQUIRE_CONTEXT_REGEX_STRING","ONE_SETUP_FILE_NATIVE","nativeSetupFile","native","ios","android"],"sources":["../../../src/metro-config/getViteMetroPluginOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,iCAAA;AAAAC,QAAA,CAAAD,iCAAA;EAAAE,yBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAe,CAAAK,iCACf;AAQO,IAAAK,iBAAS,GAAAC,OAAA,CAAAC,OAA0B;EAAAC,aAAA,GAAAF,OAAA,CAAAC,OAAA;EAAAE,WAAA,GAAAH,OAAA,CAAAC,OAAA;EAAAG,qBAAA,GAAAJ,OAAA,CAAAC,OAAA;EAAAI,oBAAA,GAAAJ,OAAA;AAAA,SACxCL,0BAAAU,KAAA;EACA;MAAAC,WAAA;MAAAC,kBAAA;MAAAC,iBAAA;MAAAC,0BAAA;MAAAC;IAAA,IAAAL,KAAA;IAA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AAA6E,GAAA,IAAA7E,SAAA,CAAA8E,OAAA;YAAA,IAC3BH,eAAA,EACF,OAAAnF,WAAA,CAAAU,OAAA,CAAAoE,QAAA,CAAA9E,WAAA,CAAAU,OAAA,CAAAqE,OAAA,CAAA5D,cAAA,GAAAnB,WAAA,CAAAU,OAAA,CAAAgC,IAAA,CAAAtC,WAAA,EAAA+E,eAAA;UACF;QACF;MACF,EACF;IAEJ;EACF","ignoreList":[]}
@@ -0,0 +1,102 @@
1
+ import * as t from "@babel/types";
2
+ import { deadCodeElimination, findReferencedIdentifiers } from "babel-dead-code-elimination";
3
+ const SERVER_EXPORTS = ["loader", "generateStaticParams"];
4
+ function removeServerCodePlugin(_, options) {
5
+ const { routerRoot = "app" } = options;
6
+ return {
7
+ name: "one-remove-server-code",
8
+ visitor: {
9
+ Program: {
10
+ enter(path, state) {
11
+ const filename = state.filename;
12
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules"))
13
+ return;
14
+ const code = path.toString();
15
+ if (/generateStaticParams|loader/.test(code))
16
+ try {
17
+ state.referenced = findReferencedIdentifiers(path.node);
18
+ } catch (error) {
19
+ console.warn(
20
+ `[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`,
21
+ error instanceof Error ? error.message : String(error)
22
+ );
23
+ }
24
+ },
25
+ exit(path, state) {
26
+ const filename = state.filename;
27
+ if (!filename || !new RegExp(`[/\\\\]${routerRoot}[/\\\\]`).test(filename) || filename.includes("node_modules") || !state.referenced)
28
+ return;
29
+ const removedExports = /* @__PURE__ */ new Set();
30
+ if (path.traverse({
31
+ ExportNamedDeclaration(exportPath) {
32
+ const declaration = exportPath.node.declaration;
33
+ if (t.isFunctionDeclaration(declaration) && declaration.id) {
34
+ const name = declaration.id.name;
35
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), exportPath.remove());
36
+ } else if (t.isVariableDeclaration(declaration))
37
+ for (let i = declaration.declarations.length - 1; i >= 0; i--) {
38
+ const declarator = declaration.declarations[i];
39
+ if (t.isIdentifier(declarator.id)) {
40
+ const name = declarator.id.name;
41
+ SERVER_EXPORTS.includes(name) && (removedExports.add(name), declaration.declarations.length === 1 ? exportPath.remove() : declaration.declarations.splice(i, 1));
42
+ }
43
+ }
44
+ },
45
+ // Also remove helper functions created by babel's async-to-generator transform
46
+ // These are named _loader, _generateStaticParams, etc.
47
+ FunctionDeclaration(funcPath) {
48
+ if (!funcPath.node.id) return;
49
+ const name = funcPath.node.id.name;
50
+ for (const serverExport of SERVER_EXPORTS)
51
+ if (name === `_${serverExport}`) {
52
+ let isAsyncHelper = !1;
53
+ funcPath.traverse({
54
+ Identifier(idPath) {
55
+ idPath.node.name === "_asyncToGenerator" && (isAsyncHelper = !0, idPath.stop());
56
+ }
57
+ }), isAsyncHelper && (removedExports.add(serverExport), funcPath.remove());
58
+ }
59
+ }
60
+ }), removedExports.size === 0)
61
+ return;
62
+ try {
63
+ deadCodeElimination(path.node, state.referenced);
64
+ } catch (error) {
65
+ console.warn(
66
+ `[one/metro] Dead code elimination failed for ${filename}:`,
67
+ error instanceof Error ? error.message : String(error)
68
+ );
69
+ }
70
+ const stubs = [];
71
+ removedExports.has("loader") && stubs.push(
72
+ t.exportNamedDeclaration(
73
+ t.functionDeclaration(
74
+ t.identifier("loader"),
75
+ [],
76
+ t.blockStatement([t.returnStatement(t.stringLiteral("__vxrn__loader__"))])
77
+ )
78
+ )
79
+ ), removedExports.has("generateStaticParams") && stubs.push(
80
+ t.exportNamedDeclaration(
81
+ t.functionDeclaration(
82
+ t.identifier("generateStaticParams"),
83
+ [],
84
+ t.blockStatement([])
85
+ )
86
+ )
87
+ );
88
+ for (const stub of stubs)
89
+ path.pushContainer("body", stub);
90
+ console.info(
91
+ ` \u{1F9F9} [one/metro] ${filename} removed ${removedExports.size} server-only exports`
92
+ );
93
+ }
94
+ }
95
+ }
96
+ };
97
+ }
98
+ var remove_server_code_default = removeServerCodePlugin;
99
+ export {
100
+ remove_server_code_default as default
101
+ };
102
+ //# sourceMappingURL=remove-server-code.js.map