one 1.1.519 → 1.1.520-1755196935791

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.
@@ -58,31 +58,51 @@ const traverse = import_traverse.default.default,
58
58
  });
59
59
  async function transformTreeShakeClient(code, id) {
60
60
  if (!/generateStaticParams|loader/.test(code)) return;
61
- const ast = (0, import_parser.parse)(code, {
61
+ let ast;
62
+ try {
63
+ ast = (0, import_parser.parse)(code, {
62
64
  sourceType: "module",
63
65
  plugins: ["typescript", "jsx"]
64
- }),
65
- referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast),
66
- removed = {
67
- loader: !1,
68
- generateStaticParams: !1
69
- };
70
- traverse(ast, {
71
- ExportNamedDeclaration(path) {
72
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
73
- if (!path.node.declaration.id) return;
74
- const functionName = path.node.declaration.id.name;
75
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
76
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
77
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
78
- const declaration = path.get("declaration.declarations." + index);
79
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
80
- }
81
- });
82
- }
83
- });
66
+ });
67
+ } catch (error) {
68
+ const errorMessage = error instanceof Error ? error.message : String(error);
69
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
70
+ return;
71
+ }
72
+ let referenced;
73
+ try {
74
+ referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast);
75
+ } catch (error) {
76
+ const errorMessage = error instanceof Error ? error.message : String(error);
77
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage);
78
+ return;
79
+ }
80
+ const removed = {
81
+ loader: !1,
82
+ generateStaticParams: !1
83
+ };
84
+ try {
85
+ traverse(ast, {
86
+ ExportNamedDeclaration(path) {
87
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
88
+ if (!path.node.declaration.id) return;
89
+ const functionName = path.node.declaration.id.name;
90
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
91
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
92
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
93
+ const declaration = path.get("declaration.declarations." + index);
94
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
95
+ }
96
+ });
97
+ }
98
+ });
99
+ } catch (error) {
100
+ const errorMessage = error instanceof Error ? error.message : String(error);
101
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage);
102
+ return;
103
+ }
84
104
  const removedFunctions = Object.keys(removed).filter(key => removed[key]);
85
- if (removedFunctions.length) {
105
+ if (removedFunctions.length) try {
86
106
  (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, referenced);
87
107
  const out = generate(ast),
88
108
  codeOut = out.code + `
@@ -93,5 +113,9 @@ async function transformTreeShakeClient(code, id) {
93
113
  code: codeOut,
94
114
  map: out.map
95
115
  };
116
+ } catch (error) {
117
+ const errorMessage = error instanceof Error ? error.message : String(error);
118
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage);
119
+ return;
96
120
  }
97
121
  }
@@ -43,37 +43,64 @@ const traverse = import_traverse.default.default, generate = import_generator.de
43
43
  async function transformTreeShakeClient(code, id) {
44
44
  if (!/generateStaticParams|loader/.test(code))
45
45
  return;
46
- const ast = (0, import_parser.parse)(code, { sourceType: "module", plugins: ["typescript", "jsx"] }), referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast), removed = {
46
+ let ast;
47
+ try {
48
+ ast = (0, import_parser.parse)(code, { sourceType: "module", plugins: ["typescript", "jsx"] });
49
+ } catch (error) {
50
+ const errorMessage = error instanceof Error ? error.message : String(error);
51
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
52
+ return;
53
+ }
54
+ let referenced;
55
+ try {
56
+ referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast);
57
+ } catch (error) {
58
+ const errorMessage = error instanceof Error ? error.message : String(error);
59
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage);
60
+ return;
61
+ }
62
+ const removed = {
47
63
  loader: !1,
48
64
  generateStaticParams: !1
49
65
  };
50
- traverse(ast, {
51
- ExportNamedDeclaration(path) {
52
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
53
- if (!path.node.declaration.id) return;
54
- const functionName = path.node.declaration.id.name;
55
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
56
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
57
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
58
- const declaration = path.get("declaration.declarations." + index);
59
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
60
- }
61
- });
62
- }
63
- });
66
+ try {
67
+ traverse(ast, {
68
+ ExportNamedDeclaration(path) {
69
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
70
+ if (!path.node.declaration.id) return;
71
+ const functionName = path.node.declaration.id.name;
72
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
73
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
74
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
75
+ const declaration = path.get("declaration.declarations." + index);
76
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
77
+ }
78
+ });
79
+ }
80
+ });
81
+ } catch (error) {
82
+ const errorMessage = error instanceof Error ? error.message : String(error);
83
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage);
84
+ return;
85
+ }
64
86
  const removedFunctions = Object.keys(removed).filter((key) => removed[key]);
65
- if (removedFunctions.length) {
66
- (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, referenced);
67
- const out = generate(ast), codeOut = out.code + `
87
+ if (removedFunctions.length)
88
+ try {
89
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, referenced);
90
+ const out = generate(ast), codeOut = out.code + `
68
91
 
69
92
  ` + removedFunctions.map((key) => key === "loader" ? import_constants.EMPTY_LOADER_STRING : "export function generateStaticParams() {};").join(`
70
93
  `);
71
- return console.info(
72
- ` \u{1F9F9} [one] ${(0, import_node_path.relative)(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
73
- ), {
74
- code: codeOut,
75
- map: out.map
76
- };
77
- }
94
+ return console.info(
95
+ ` \u{1F9F9} [one] ${(0, import_node_path.relative)(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
96
+ ), {
97
+ code: codeOut,
98
+ map: out.map
99
+ };
100
+ } catch (error) {
101
+ const errorMessage = error instanceof Error ? error.message : String(error);
102
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage);
103
+ return;
104
+ }
78
105
  }
79
106
  //# sourceMappingURL=clientTreeShakePlugin.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B,yCAC1B,gBAAsB,0BACtB,kBAA0B,wCAC1B,qCAA+D,wCAC/D,mBAAkC,sBAElC,mBAAoC;AAEpC,MAAM,WAAW,gBAAAA,QAAc,SACzB,WAAW,iBAAAC,QAAc,SAElB,wBAAwB,OAC5B;AAAA,EACL,MA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OAAO;AAEd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC1E,YAAQ,KAAK,mCAAmC,EAAE,4BAA4B,YAAY;AAC1F;AAAA,EACF;AAEA,QAAM,mBAAmB,OAAO,KAAK,OAAO,EAAE,OAAO,CAAC,QAAQ,QAAQ,GAAG,CAAC;AAE1E,MAAI,iBAAiB;AACnB,QAAI;AACF,kEAAoB,KAAK,UAAU;AAEnC,YAAM,MAAM,SAAS,GAAG,GAGlB,UACJ,IAAI,OACJ;AAAA;AAAA,IACA,iBACG,IAAI,CAAC,QACA,QAAQ,WACH,uCAGF,4CACR,EACA,KAAK;AAAA,CAAI;AAEd,qBAAQ;AAAA,QACN,6BAAkB,2BAAS,QAAQ,IAAI,GAAG,EAAE,CAAC,YAAY,iBAAiB,MAAM;AAAA,MAClF,GAEO;AAAA,QACL,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX;AAAA,IACF,SAAS,OAAO;AAEd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC1E,cAAQ,KAAK,mCAAmC,EAAE,kCAAkC,YAAY;AAChG;AAAA,IACF;AAEJ;",
5
5
  "names": ["BabelTraverse", "BabelGenerate"]
6
6
  }
@@ -47,46 +47,73 @@ var import_generator = __toESM(require("@babel/generator"), 1), import_parser =
47
47
  };
48
48
  async function transformTreeShakeClient(code, id) {
49
49
  if (/generateStaticParams|loader/.test(code)) {
50
- var ast = (0, import_parser.parse)(code, {
51
- sourceType: "module",
52
- plugins: [
53
- "typescript",
54
- "jsx"
55
- ]
56
- }), referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast), removed = {
50
+ var ast;
51
+ try {
52
+ ast = (0, import_parser.parse)(code, {
53
+ sourceType: "module",
54
+ plugins: [
55
+ "typescript",
56
+ "jsx"
57
+ ]
58
+ });
59
+ } catch (error) {
60
+ var errorMessage = error instanceof Error ? error.message : String(error);
61
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
62
+ return;
63
+ }
64
+ var referenced;
65
+ try {
66
+ referenced = (0, import_babel_dead_code_elimination.findReferencedIdentifiers)(ast);
67
+ } catch (error) {
68
+ var errorMessage1 = error instanceof Error ? error.message : String(error);
69
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage1);
70
+ return;
71
+ }
72
+ var removed = {
57
73
  loader: !1,
58
74
  generateStaticParams: !1
59
75
  };
60
- traverse(ast, {
61
- ExportNamedDeclaration(path) {
62
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
63
- if (!path.node.declaration.id) return;
64
- var functionName = path.node.declaration.id.name;
65
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
66
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach(function(declarator, index) {
67
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
68
- var declaration = path.get("declaration.declarations." + index);
69
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
70
- }
71
- });
72
- }
73
- });
76
+ try {
77
+ traverse(ast, {
78
+ ExportNamedDeclaration(path) {
79
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
80
+ if (!path.node.declaration.id) return;
81
+ var functionName = path.node.declaration.id.name;
82
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
83
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach(function(declarator, index) {
84
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
85
+ var declaration = path.get("declaration.declarations." + index);
86
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
87
+ }
88
+ });
89
+ }
90
+ });
91
+ } catch (error) {
92
+ var errorMessage2 = error instanceof Error ? error.message : String(error);
93
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage2);
94
+ return;
95
+ }
74
96
  var removedFunctions = Object.keys(removed).filter(function(key) {
75
97
  return removed[key];
76
98
  });
77
- if (removedFunctions.length) {
78
- (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, referenced);
79
- var out = generate(ast), codeOut = out.code + `
99
+ if (removedFunctions.length)
100
+ try {
101
+ (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, referenced);
102
+ var out = generate(ast), codeOut = out.code + `
80
103
 
81
104
  ` + removedFunctions.map(function(key) {
82
- return key === "loader" ? import_constants.EMPTY_LOADER_STRING : "export function generateStaticParams() {};";
83
- }).join(`
105
+ return key === "loader" ? import_constants.EMPTY_LOADER_STRING : "export function generateStaticParams() {};";
106
+ }).join(`
84
107
  `);
85
- return console.info(` \u{1F9F9} [one] ${(0, import_node_path.relative)(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`), {
86
- code: codeOut,
87
- map: out.map
88
- };
89
- }
108
+ return console.info(` \u{1F9F9} [one] ${(0, import_node_path.relative)(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`), {
109
+ code: codeOut,
110
+ map: out.map
111
+ };
112
+ } catch (error) {
113
+ var errorMessage3 = error instanceof Error ? error.message : String(error);
114
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage3);
115
+ return;
116
+ }
90
117
  }
91
118
  }
92
119
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;uBAA0B,yCAC1B,gBAAsB,0BACtB,kBAA0B,wCAC1B,qCAA+D,wCAC/D,mBAAkC,sBAElC,mBAAoC,yBAE9BA,WAAWC,gBAAAA,QAAc,SACzBC,WAAWC,iBAAAA,QAAc,SAElBC,wBAAwB,WAAA;AACnC,SAAO;IACLC,MAAM;IAEN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QAAQV,WAAAA,MACjBA,YAAYG,OAAM,GAClBT,QAAQY,WAAWzB,GAAGR,IAAI,IAAI;UAElC;QACF,CAAA;MAEJ;IACF,CAAA;AAEA,QAAMsC,mBAAmBC,OAAOC,KAAKnB,OAAAA,EAASoB,OAAO,SAACC,KAAAA;aAAQrB,QAAQqB,GAAAA;;AAEtE,QAAIJ,iBAAiBK,QAAQ;AAC3BC,kEAAoB7B,KAAKI,UAAAA;AAEzB,UAAMN,MAAMhB,SAASkB,GAAAA,GAGf8B,UACJhC,IAAIN,OACJ;;IACA+B,iBACGQ,IAAI,SAACJ,KAAAA;AACJ,eAAIA,QAAQ,WACHK,uCAGF;MACT,CAAA,EACCC,KAAK;CAAA;AAEVC,qBAAQC,KACN,6BAAkBC,2BAASC,QAAQC,IAAG,GAAI7C,EAAAA,CAAAA,YAAe8B,iBAAiBK,MAAM,sBAAsB,GAGjG;QACLpC,MAAMsC;QACNC,KAAKjC,IAAIiC;MACX;IACF;;AACF;",
5
- "names": ["traverse", "BabelTraverse", "generate", "BabelGenerate", "clientTreeShakePlugin", "name", "enforce", "applyToEnvironment", "env", "transform", "order", "handler", "code", "id", "settings", "environment", "test", "extname", "out", "transformTreeShakeClient", "ast", "parse", "sourceType", "plugins", "referenced", "findReferencedIdentifiers", "removed", "loader", "generateStaticParams", "ExportNamedDeclaration", "path", "node", "declaration", "type", "functionName", "remove", "declarations", "forEach", "declarator", "index", "get", "Array", "isArray", "removedFunctions", "Object", "keys", "filter", "key", "length", "deadCodeElimination", "codeOut", "map", "EMPTY_LOADER_STRING", "join", "console", "info", "relative", "process", "cwd"]
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;uBAA0B,yCAC1B,gBAAsB,0BACtB,kBAA0B,wCAC1B,qCAA+D,wCAC/D,mBAAkC,sBAElC,mBAAoC,yBAE9BA,WAAWC,gBAAAA,QAAc,SACzBC,WAAWC,iBAAAA,QAAc,SAElBC,wBAAwB,WAAA;AACnC,SAAO;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;AACrEK,gBAAQC,KAAK,mCAAmCjB,EAAAA,kCAAoCY,aAAAA;AACpF;MACF;;AAEJ;",
5
+ "names": ["traverse", "BabelTraverse", "generate", "BabelGenerate", "clientTreeShakePlugin", "name", "enforce", "applyToEnvironment", "env", "transform", "order", "handler", "code", "id", "settings", "environment", "test", "extname", "out", "transformTreeShakeClient", "ast", "parse", "sourceType", "plugins", "error", "errorMessage", "Error", "message", "String", "console", "warn", "referenced", "findReferencedIdentifiers", "removed", "loader", "generateStaticParams", "ExportNamedDeclaration", "path", "node", "declaration", "type", "functionName", "remove", "declarations", "forEach", "declarator", "index", "get", "Array", "isArray", "removedFunctions", "Object", "keys", "filter", "key", "length", "deadCodeElimination", "codeOut", "map", "EMPTY_LOADER_STRING", "join", "info", "relative", "process", "cwd"]
6
6
  }
@@ -20,38 +20,65 @@ const traverse = BabelTraverse.default, generate = BabelGenerate.default, client
20
20
  async function transformTreeShakeClient(code, id) {
21
21
  if (!/generateStaticParams|loader/.test(code))
22
22
  return;
23
- const ast = parse(code, { sourceType: "module", plugins: ["typescript", "jsx"] }), referenced = findReferencedIdentifiers(ast), removed = {
23
+ let ast;
24
+ try {
25
+ ast = parse(code, { sourceType: "module", plugins: ["typescript", "jsx"] });
26
+ } catch (error) {
27
+ const errorMessage = error instanceof Error ? error.message : String(error);
28
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
29
+ return;
30
+ }
31
+ let referenced;
32
+ try {
33
+ referenced = findReferencedIdentifiers(ast);
34
+ } catch (error) {
35
+ const errorMessage = error instanceof Error ? error.message : String(error);
36
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage);
37
+ return;
38
+ }
39
+ const removed = {
24
40
  loader: !1,
25
41
  generateStaticParams: !1
26
42
  };
27
- traverse(ast, {
28
- ExportNamedDeclaration(path) {
29
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
30
- if (!path.node.declaration.id) return;
31
- const functionName = path.node.declaration.id.name;
32
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
33
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
34
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
35
- const declaration = path.get("declaration.declarations." + index);
36
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
37
- }
38
- });
39
- }
40
- });
43
+ try {
44
+ traverse(ast, {
45
+ ExportNamedDeclaration(path) {
46
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
47
+ if (!path.node.declaration.id) return;
48
+ const functionName = path.node.declaration.id.name;
49
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
50
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
51
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
52
+ const declaration = path.get("declaration.declarations." + index);
53
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
54
+ }
55
+ });
56
+ }
57
+ });
58
+ } catch (error) {
59
+ const errorMessage = error instanceof Error ? error.message : String(error);
60
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage);
61
+ return;
62
+ }
41
63
  const removedFunctions = Object.keys(removed).filter((key) => removed[key]);
42
- if (removedFunctions.length) {
43
- deadCodeElimination(ast, referenced);
44
- const out = generate(ast), codeOut = out.code + `
64
+ if (removedFunctions.length)
65
+ try {
66
+ deadCodeElimination(ast, referenced);
67
+ const out = generate(ast), codeOut = out.code + `
45
68
 
46
69
  ` + removedFunctions.map((key) => key === "loader" ? EMPTY_LOADER_STRING : "export function generateStaticParams() {};").join(`
47
70
  `);
48
- return console.info(
49
- ` \u{1F9F9} [one] ${relative(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
50
- ), {
51
- code: codeOut,
52
- map: out.map
53
- };
54
- }
71
+ return console.info(
72
+ ` \u{1F9F9} [one] ${relative(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
73
+ ), {
74
+ code: codeOut,
75
+ map: out.map
76
+ };
77
+ } catch (error) {
78
+ const errorMessage = error instanceof Error ? error.message : String(error);
79
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage);
80
+ return;
81
+ }
55
82
  }
56
83
  export {
57
84
  clientTreeShakePlugin,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],
4
- "mappings": "AAAA,OAAO,mBAAmB;AAC1B,SAAS,aAAa;AACtB,OAAO,mBAAmB;AAC1B,SAAS,qBAAqB,iCAAiC;AAC/D,SAAS,SAAS,gBAAgB;AAElC,SAAS,2BAA2B;AAEpC,MAAM,WAAW,cAAc,SACzB,WAAW,cAAc,SAElB,wBAAwB,OAC5B;AAAA,EACL,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,mBAAmB,KAAK;AACtB,WAAO,IAAI,SAAS,YAAY,IAAI,SAAS,SAAS,IAAI,SAAS;AAAA,EACrE;AAAA,EAEA,WAAW;AAAA,IACT,OAAO;AAAA,IACP,MAAM,QAAQ,MAAM,IAAI,UAAU;AAOhC,aANI,KAAK,YAAY,SAAS,SAG1B,CAAC,oBAAoB,KAAK,QAAQ,EAAE,CAAC,KAGrC,eAAe,KAAK,EAAE,IACxB,SAGU,MAAM,yBAAyB,MAAM,EAAE;AAAA,IAGrD;AAAA,EACF;AACF;AAGF,eAAsB,yBAAyB,MAAc,IAAY;AACvE,MAAI,CAAC,8BAA8B,KAAK,IAAI;AAC1C;AAIF,QAAM,MAAM,MAAM,MAAM,EAAE,YAAY,UAAU,SAAS,CAAC,cAAc,KAAK,EAAE,CAAC,GAE1E,aAAa,0BAA0B,GAAG,GAE1C,UAAU;AAAA,IACd,QAAQ;AAAA,IACR,sBAAs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O,KAAK;AAC1E,cAAQ,KAAK,mCAAmC,EAAE,kCAAkC,YAAY;AAChG;AAAA,IACF;AAEJ;",
5
5
  "names": []
6
6
  }
@@ -21,31 +21,51 @@ const traverse = BabelTraverse.default,
21
21
  });
22
22
  async function transformTreeShakeClient(code, id) {
23
23
  if (!/generateStaticParams|loader/.test(code)) return;
24
- const ast = parse(code, {
24
+ let ast;
25
+ try {
26
+ ast = parse(code, {
25
27
  sourceType: "module",
26
28
  plugins: ["typescript", "jsx"]
27
- }),
28
- referenced = findReferencedIdentifiers(ast),
29
- removed = {
30
- loader: !1,
31
- generateStaticParams: !1
32
- };
33
- traverse(ast, {
34
- ExportNamedDeclaration(path) {
35
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
36
- if (!path.node.declaration.id) return;
37
- const functionName = path.node.declaration.id.name;
38
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
39
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
40
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
41
- const declaration = path.get("declaration.declarations." + index);
42
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
43
- }
44
- });
45
- }
46
- });
29
+ });
30
+ } catch (error) {
31
+ const errorMessage = error instanceof Error ? error.message : String(error);
32
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
33
+ return;
34
+ }
35
+ let referenced;
36
+ try {
37
+ referenced = findReferencedIdentifiers(ast);
38
+ } catch (error) {
39
+ const errorMessage = error instanceof Error ? error.message : String(error);
40
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage);
41
+ return;
42
+ }
43
+ const removed = {
44
+ loader: !1,
45
+ generateStaticParams: !1
46
+ };
47
+ try {
48
+ traverse(ast, {
49
+ ExportNamedDeclaration(path) {
50
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
51
+ if (!path.node.declaration.id) return;
52
+ const functionName = path.node.declaration.id.name;
53
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
54
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
55
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
56
+ const declaration = path.get("declaration.declarations." + index);
57
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
58
+ }
59
+ });
60
+ }
61
+ });
62
+ } catch (error) {
63
+ const errorMessage = error instanceof Error ? error.message : String(error);
64
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage);
65
+ return;
66
+ }
47
67
  const removedFunctions = Object.keys(removed).filter(key => removed[key]);
48
- if (removedFunctions.length) {
68
+ if (removedFunctions.length) try {
49
69
  deadCodeElimination(ast, referenced);
50
70
  const out = generate(ast),
51
71
  codeOut = out.code + `
@@ -56,6 +76,10 @@ async function transformTreeShakeClient(code, id) {
56
76
  code: codeOut,
57
77
  map: out.map
58
78
  };
79
+ } catch (error) {
80
+ const errorMessage = error instanceof Error ? error.message : String(error);
81
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage);
82
+ return;
59
83
  }
60
84
  }
61
85
  export { clientTreeShakePlugin, transformTreeShakeClient };
@@ -1 +1 @@
1
- {"version":3,"names":["BabelGenerate","parse","BabelTraverse","deadCodeElimination","findReferencedIdentifiers","extname","relative","EMPTY_LOADER_STRING","traverse","default","generate","clientTreeShakePlugin","name","enforce","applyToEnvironment","env","transform","order","handler","code","id","settings","environment","test","transformTreeShakeClient","ast","sourceType","plugins","referenced","removed","loader","generateStaticParams","ExportNamedDeclaration","path","node","declaration","type","functionName","remove","declarations","forEach","declarator","index","get","Array","isArray","removedFunctions","Object","keys","filter","key","length","out","codeOut","map","join","console","info","process","cwd"],"sources":["../../../../src/vite/plugins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AM1C,QAAA,CAASe,GAAG;MAGlB4B,OAAA,GACJD,GAAA,CAAIjC,IAAA,GACJ;AAAA;AAAA,IACA2B,gBAAA,CACGQ,GAAA,CAAKJ,GAAA,IACAA,GAAA,KAAQ,WACH3C,mBAAA,GAGF,4CACR,EACAgD,IAAA,CAAK;AAAA,CAAI;IAEd,OAAAC,OAAA,CAAQC,IAAA,CACN,yBAAkBnD,QAAA,CAASoD,OAAA,CAAQC,GAAA,CAAI,GAAGvC,EAAE,CAAC,YAAY0B,gBAAA,CAAiBK,MAAM,sBAClF,GAEO;MACLhC,IAAA,EAAMkC,OAAA;MACNC,GAAA,EAAKF,GAAA,CAAIE;IACX;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["BabelGenerate","parse","BabelTraverse","deadCodeElimination","findReferencedIdentifiers","extname","relative","EMPTY_LOADER_STRING","traverse","default","generate","clientTreeShakePlugin","name","enforce","applyToEnvironment","env","transform","order","handler","code","id","settings","environment","test","transformTreeShakeClient","ast","sourceType","plugins","error","errorMessage","Error","message","String","console","warn","referenced","removed","loader","generateStaticParams","ExportNamedDeclaration","path","node","declaration","type","functionName","remove","declarations","forEach","declarator","index","get","Array","isArray","removedFunctions","Object","keys","filter","key","length","out","codeOut","map","join","info","process","cwd"],"sources":["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,aAAA,MAAmB;AAC1B,SAASC,KAAA,QAAa;AACtB,OAAOC,aAAA,MAAmB;AAC1B,SAASC,mBAAA,EAAqBC,yBAAA,QAAiC;AAC/D,SAASC,OAAA,EAASC,QAAA,QAAgB;AAElC,SAASC,mBAAA,QAA2B;AAEpC,MAAMC,QAAA,GAAWN,aAAA,CAAcO,OAAA;EACzBC,QAAA,GAAWV,aAAA,CAAcS,OAAA;EAElBE,qBAAA,GAAwBA,CAAA,MAC5B;IACLC,IAAA,EAAM;IAENC,OAAA,EAAS;IAETC,mBAAmBC,GAAA,EAAK;MACtB,OAAOA,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IAC1F;EACF;EAEA,MAAMwB,gBAAA,GAAmBC,MAAA,CAAOC,IAAA,CAAKnB,OAAO,EAAEoB,MAAA,CAAQC,GAAA,IAAQrB,OAAA,CAAQqB,GAAG,CAAC;EAE1E,IAAIJ,gBAAA,CAAiBK,MAAA,EACnB,IAAI;IACFvD,mBAAA,CAAoBsB,GAAA,EAAKU,UAAU;IAEnC,MAAMwB,GAAA,GAAMjD,QAAA,CAASe,GAAG;MAGlBmC,OAAA,GACJD,GAAA,CAAIxC,IAAA,GACJ;AAAA;AAAA,IACAkC,gBAAA,CACGQ,GAAA,CAAKJ,GAAA,IACAA,GAAA,KAAQ,WACHlD,mBAAA,GAGF,4CACR,EACAuD,IAAA,CAAK;AAAA,CAAI;IAEd,OAAA7B,OAAA,CAAQ8B,IAAA,CACN,yBAAkBzD,QAAA,CAAS0D,OAAA,CAAQC,GAAA,CAAI,GAAG7C,EAAE,CAAC,YAAYiC,gBAAA,CAAiBK,MAAM,sBAClF,GAEO;MACLvC,IAAA,EAAMyC,OAAA;MACNC,GAAA,EAAKF,GAAA,CAAIE;IACX;EACF,SAASjC,KAAA,EAAO;IAEd,MAAMC,YAAA,GAAeD,KAAA,YAAiBE,KAAA,GAAQF,KAAA,CAAMG,OAAA,GAAUC,MAAA,CAAOJ,KAAK;IAC1EK,OAAA,CAAQC,IAAA,CAAK,mCAAmCd,EAAE,kCAAkCS,YAAY;IAChG;EACF;AAEJ","ignoreList":[]}
@@ -26,33 +26,53 @@ var traverse = BabelTraverse.default,
26
26
  };
27
27
  async function transformTreeShakeClient(code, id) {
28
28
  if (/generateStaticParams|loader/.test(code)) {
29
- var ast = parse(code, {
29
+ var ast;
30
+ try {
31
+ ast = parse(code, {
30
32
  sourceType: "module",
31
33
  plugins: ["typescript", "jsx"]
32
- }),
33
- referenced = findReferencedIdentifiers(ast),
34
- removed = {
35
- loader: !1,
36
- generateStaticParams: !1
37
- };
38
- traverse(ast, {
39
- ExportNamedDeclaration(path) {
40
- if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
41
- if (!path.node.declaration.id) return;
42
- var functionName = path.node.declaration.id.name;
43
- (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
44
- } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach(function (declarator, index) {
45
- if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
46
- var declaration = path.get("declaration.declarations." + index);
47
- Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
48
- }
49
- });
50
- }
51
- });
34
+ });
35
+ } catch (error) {
36
+ var errorMessage = error instanceof Error ? error.message : String(error);
37
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage);
38
+ return;
39
+ }
40
+ var referenced;
41
+ try {
42
+ referenced = findReferencedIdentifiers(ast);
43
+ } catch (error) {
44
+ var errorMessage1 = error instanceof Error ? error.message : String(error);
45
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage1);
46
+ return;
47
+ }
48
+ var removed = {
49
+ loader: !1,
50
+ generateStaticParams: !1
51
+ };
52
+ try {
53
+ traverse(ast, {
54
+ ExportNamedDeclaration(path) {
55
+ if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
56
+ if (!path.node.declaration.id) return;
57
+ var functionName = path.node.declaration.id.name;
58
+ (functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
59
+ } else path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach(function (declarator, index) {
60
+ if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
61
+ var declaration = path.get("declaration.declarations." + index);
62
+ Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
63
+ }
64
+ });
65
+ }
66
+ });
67
+ } catch (error) {
68
+ var errorMessage2 = error instanceof Error ? error.message : String(error);
69
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage2);
70
+ return;
71
+ }
52
72
  var removedFunctions = Object.keys(removed).filter(function (key) {
53
73
  return removed[key];
54
74
  });
55
- if (removedFunctions.length) {
75
+ if (removedFunctions.length) try {
56
76
  deadCodeElimination(ast, referenced);
57
77
  var out = generate(ast),
58
78
  codeOut = out.code + `
@@ -65,6 +85,10 @@ async function transformTreeShakeClient(code, id) {
65
85
  code: codeOut,
66
86
  map: out.map
67
87
  };
88
+ } catch (error) {
89
+ var errorMessage3 = error instanceof Error ? error.message : String(error);
90
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage3);
91
+ return;
68
92
  }
69
93
  }
70
94
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BabelGenerate","parse","BabelTraverse","deadCodeElimination","findReferencedIdentifiers","extname","relative","EMPTY_LOADER_STRING","traverse","default","generate","clientTreeShakePlugin","name","enforce","applyToEnvironment","env","transform","order","handler","code","id","settings","environment","test","out","transformTreeShakeClient","ast","sourceType","plugins","referenced","removed","loader","generateStaticParams","ExportNamedDeclaration","path","node","declaration","type","functionName","remove","declarations","forEach","declarator","index","get","Array","isArray","removedFunctions","Object","keys","filter","key","length"],"sources":["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,aAAA,MAAmB;AAC1B,SAASC,KAAA,QAAa;AACtB,OAAOC,aAAA,MAAmB;AAC1B,SAASC,mBAAA,EAAqBC,yBAAA,QAAiC;AAC/D,SAASC,OAAA,EAASC,QAAA,QAAgB;AAElC,SAASC,mBAAA,QAA2B;AAEpC,IAAAC,QAAM,GAAAN,aAAW,CAAAO,OAAc;EAAAC,QACzB,GAAAV,aAAW,CAAAS,OAAc;EAAAE,qBAElB,YAAAA,CAAA,EACJ;IACL,OAAM;MAENC,IAAA,yBAAS;MAETC,OAAA;MACEC,kBAAWA,CAAAC,GAAS;QACtB,OAAAA,GAAA,CAAAH,IAAA,iBAAAG,G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,KAAA;UAE7B,IAAAD,UAAM,CAAStB,EAAA,CAAGiB,IAGlB,iBACA,KACJK,UAAA,CAAAtB,EAAA,CAAAR,IAAA,iBAAA8B,UAAA,CAAAtB,EAAA,CAAAR,IAAA;YAAA,IAAAwB,WAAA,GAAAF,IAAA,CAAAU,GAAA,+BAAAD,KAAA;YACAE,KAAA,CAAAC,OACO,CAACV,WACA,MAAQA,WACH,CAAAG,MAAA,IAAAT,OAAA,CAAAY,UAGF,CAAAtB,EAAA,CAAAR,IAAA;UAEC;QAEd;MACE;IACF;IAEO,IACLmC,gBAAM,GAAAC,MAAA,CAAAC,IAAA,CAAAnB,OAAA,EAAAoB,MAAA,WAAAC,GAAA;MACN,OAAKrB,OAAI,CAAAqB,GAAA;IACX;IACF,IAAAJ,gBAAA,CAAAK,MAAA;MACFjD,mBAAA,CAAAuB,GAAA,EAAAG,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["BabelGenerate","parse","BabelTraverse","deadCodeElimination","findReferencedIdentifiers","extname","relative","EMPTY_LOADER_STRING","traverse","default","generate","clientTreeShakePlugin","name","enforce","applyToEnvironment","env","transform","order","handler","code","id","settings","environment","test","out","transformTreeShakeClient","ast","sourceType","plugins","error","errorMessage","Error","message","String","console","warn","referenced","errorMessage1","removed","loader","generateStaticParams","ExportNamedDeclaration","path","node","declaration","type","functionName","remove","declarations","forEach","declarator","index","get","Array","isArray","errorMessage2","removedFunctions","Object","keys","filter","key","length","codeOut","map"],"sources":["../../../../src/vite/plugins/clientTreeShakePlugin.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,aAAA,MAAmB;AAC1B,SAASC,KAAA,QAAa;AACtB,OAAOC,aAAA,MAAmB;AAC1B,SAASC,mBAAA,EAAqBC,yBAAA,QAAiC;AAC/D,SAASC,OAAA,EAASC,QAAA,QAAgB;AAElC,SAASC,mBAAA,QAA2B;AAEpC,IAAAC,QAAM,GAAAN,aAAW,CAAAO,OAAc;EAAAC,QACzB,GAAAV,aAAW,CAA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AA,OACLtB,OAAM,CAAAsB,GAAA;IAAA;IACG,IACXJ,gBAAA,CAAAK,MAAA,EACF;MAEE1D,mBAAqB,CAAAuB,GAAA,EAAAU,UAAA,CAAiB;MACtC,IAAAZ,GAAQ,GAAAd,QAAK,CAAAgB,GAAA;QAAAoC,OAAA,GAAAtC,GAAA,CAAAL,IAAA,GAAmC;AAChD;AAAA,IACFqC,gBAAA,CAAAO,GAAA,WAAAH,GAAA;UAEJ,OAAAA,GAAA,gBAAArD,mBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "1.1.519",
3
+ "version": "1.1.520-1755196935791",
4
4
  "license": "BSD-3-Clause",
5
5
  "sideEffects": [
6
6
  "setup.mjs",
@@ -105,24 +105,22 @@
105
105
  "@radix-ui/react-slot": "^1.0.2",
106
106
  "@react-native-masked-view/masked-view": "^0.3.1",
107
107
  "@react-navigation/bottom-tabs": "7.3.4",
108
- "@react-navigation/core": "~7.8.0",
109
108
  "@react-navigation/drawer": "7.3.3",
110
109
  "@react-navigation/elements": "2.3.2",
111
- "@react-navigation/native": "~7.1.0",
112
110
  "@react-navigation/native-stack": "7.3.4",
113
111
  "@react-navigation/routers": "~7.3.2",
114
112
  "@swc/core": "^1.10.4",
115
113
  "@ungap/structured-clone": "^1.2.0",
116
- "@vxrn/compiler": "1.1.519",
117
- "@vxrn/resolve": "1.1.519",
118
- "@vxrn/tslib-lite": "1.1.519",
119
- "@vxrn/universal-color-scheme": "1.1.519",
120
- "@vxrn/use-isomorphic-layout-effect": "1.1.519",
114
+ "@vxrn/compiler": "1.1.520-1755196935791",
115
+ "@vxrn/resolve": "1.1.520-1755196935791",
116
+ "@vxrn/tslib-lite": "1.1.520-1755196935791",
117
+ "@vxrn/universal-color-scheme": "1.1.520-1755196935791",
118
+ "@vxrn/use-isomorphic-layout-effect": "1.1.520-1755196935791",
121
119
  "babel-dead-code-elimination": "^1.0.9",
122
120
  "babel-plugin-module-resolver": "^5",
123
121
  "citty": "^0.1.6",
124
122
  "core-js": "^3.38.1",
125
- "create-vxrn": "1.1.519",
123
+ "create-vxrn": "1.1.520-1755196935791",
126
124
  "escape-string-regexp": "^5.0.0",
127
125
  "expo-linking": "~6.3.1",
128
126
  "expo-modules-core": "~2.5.0",
@@ -141,33 +139,21 @@
141
139
  "react-native-css-interop": "^0.1.22",
142
140
  "react-native-gesture-handler": "~2.24.0",
143
141
  "react-native-reanimated": "~3.17.4",
144
- "react-native-safe-area-context": "5.4.0",
145
- "react-native-screens": "4.10.0",
146
142
  "ts-pattern": "^5.6.2",
147
143
  "tsconfig-paths": "^4",
148
144
  "use-latest-callback": "^0.2.3",
149
145
  "vite": "^7.0.1",
150
146
  "vite-plugin-barrel": "^0.4.1",
151
147
  "vite-tsconfig-paths": "^5.0.1",
152
- "vxrn": "1.1.519",
148
+ "vxrn": "1.1.520-1755196935791",
153
149
  "ws": "^8.18.0",
154
150
  "xxhashjs": "^0.2.2"
155
151
  },
156
- "devDependencies": {
157
- "@tamagui/build": "^1.132.17",
158
- "@types/node": "^22.1.0",
159
- "@types/react-dom": "^18.2.25",
160
- "@types/xxhashjs": "^0.2.4",
161
- "@vxrn/vite-plugin-metro": "1.1.519",
162
- "depcheck": "^1.4.7",
163
- "immer": "^10.1.1",
164
- "react-native": "~0.79.2",
165
- "rollup": "^4.29.1",
166
- "typescript": "^5.7.3",
167
- "vitest": "^3.2.0"
168
- },
169
152
  "peerDependencies": {
153
+ "@react-navigation/native": "~7.1.0",
170
154
  "react-native": "*",
155
+ "react-native-safe-area-context": "5.4.0",
156
+ "react-native-screens": "4.10.0",
171
157
  "react-scan": "^0.1.3"
172
158
  },
173
159
  "peerDependenciesMeta": {
@@ -178,6 +164,21 @@
178
164
  "optional": true
179
165
  }
180
166
  },
167
+ "devDependencies": {
168
+ "@react-navigation/core": "~7.8.0",
169
+ "@react-navigation/native": "~7.1.0",
170
+ "@tamagui/build": "^1.132.17",
171
+ "@types/node": "^22.1.0",
172
+ "@types/react-dom": "^18.2.25",
173
+ "@types/xxhashjs": "^0.2.4",
174
+ "@vxrn/vite-plugin-metro": "1.1.520-1755196935791",
175
+ "depcheck": "^1.4.7",
176
+ "immer": "^10.1.1",
177
+ "react-native": "~0.79.2",
178
+ "rollup": "^4.29.1",
179
+ "typescript": "^5.7.3",
180
+ "vitest": "^3.2.0"
181
+ },
181
182
  "publishConfig": {
182
183
  "access": "public"
183
184
  }
@@ -45,70 +45,101 @@ export async function transformTreeShakeClient(code: string, id: string) {
45
45
  return
46
46
  }
47
47
 
48
- // `as any` because babel-dead-code-elimination using @types and it conflicts :/
49
- const ast = parse(code, { sourceType: 'module', plugins: ['typescript', 'jsx'] }) as any
48
+ let ast: any
49
+ try {
50
+ // `as any` because babel-dead-code-elimination using @types and it conflicts :/
51
+ ast = parse(code, { sourceType: 'module', plugins: ['typescript', 'jsx'] }) as any
52
+ } catch (error) {
53
+ // If there's a syntax error, skip transformation and let Vite handle the error
54
+ // This prevents the dev server from crashing on syntax errors
55
+ const errorMessage = error instanceof Error ? error.message : String(error)
56
+ console.warn(`[one] Skipping tree shaking for ${id} due to syntax error:`, errorMessage)
57
+ return
58
+ }
50
59
 
51
- const referenced = findReferencedIdentifiers(ast)
60
+ let referenced: any
61
+ try {
62
+ referenced = findReferencedIdentifiers(ast)
63
+ } catch (error) {
64
+ // If finding referenced identifiers fails, skip transformation
65
+ const errorMessage = error instanceof Error ? error.message : String(error)
66
+ console.warn(`[one] Skipping tree shaking for ${id} due to identifier analysis error:`, errorMessage)
67
+ return
68
+ }
52
69
 
53
70
  const removed = {
54
71
  loader: false,
55
72
  generateStaticParams: false,
56
73
  }
57
74
 
58
- traverse(ast, {
59
- ExportNamedDeclaration(path) {
60
- if (path.node.declaration && path.node.declaration.type === 'FunctionDeclaration') {
61
- if (!path.node.declaration.id) return
62
- const functionName = path.node.declaration.id.name
63
- if (functionName === 'loader' || functionName === 'generateStaticParams') {
64
- path.remove()
65
- removed[functionName] = true
66
- }
67
- } else if (path.node.declaration && path.node.declaration.type === 'VariableDeclaration') {
68
- path.node.declaration.declarations.forEach((declarator, index) => {
69
- if (
70
- declarator.id.type === 'Identifier' &&
71
- (declarator.id.name === 'loader' || declarator.id.name === 'generateStaticParams')
72
- ) {
73
- const declaration = path.get('declaration.declarations.' + index)
74
- if (!Array.isArray(declaration)) {
75
- declaration.remove()
76
- removed[declarator.id.name] = true
77
- }
75
+ try {
76
+ traverse(ast, {
77
+ ExportNamedDeclaration(path) {
78
+ if (path.node.declaration && path.node.declaration.type === 'FunctionDeclaration') {
79
+ if (!path.node.declaration.id) return
80
+ const functionName = path.node.declaration.id.name
81
+ if (functionName === 'loader' || functionName === 'generateStaticParams') {
82
+ path.remove()
83
+ removed[functionName] = true
78
84
  }
79
- })
80
- }
81
- },
82
- })
85
+ } else if (path.node.declaration && path.node.declaration.type === 'VariableDeclaration') {
86
+ path.node.declaration.declarations.forEach((declarator, index) => {
87
+ if (
88
+ declarator.id.type === 'Identifier' &&
89
+ (declarator.id.name === 'loader' || declarator.id.name === 'generateStaticParams')
90
+ ) {
91
+ const declaration = path.get('declaration.declarations.' + index)
92
+ if (!Array.isArray(declaration)) {
93
+ declaration.remove()
94
+ removed[declarator.id.name] = true
95
+ }
96
+ }
97
+ })
98
+ }
99
+ },
100
+ })
101
+ } catch (error) {
102
+ // If traversal fails, skip transformation
103
+ const errorMessage = error instanceof Error ? error.message : String(error)
104
+ console.warn(`[one] Skipping tree shaking for ${id} due to traversal error:`, errorMessage)
105
+ return
106
+ }
83
107
 
84
108
  const removedFunctions = Object.keys(removed).filter((key) => removed[key])
85
109
 
86
110
  if (removedFunctions.length) {
87
- deadCodeElimination(ast, referenced)
88
-
89
- const out = generate(ast)
90
-
91
- // add back in empty or filled loader and genparams
92
- const codeOut =
93
- out.code +
94
- '\n\n' +
95
- removedFunctions
96
- .map((key) => {
97
- if (key === 'loader') {
98
- return EMPTY_LOADER_STRING
99
- }
111
+ try {
112
+ deadCodeElimination(ast, referenced)
113
+
114
+ const out = generate(ast)
115
+
116
+ // add back in empty or filled loader and genparams
117
+ const codeOut =
118
+ out.code +
119
+ '\n\n' +
120
+ removedFunctions
121
+ .map((key) => {
122
+ if (key === 'loader') {
123
+ return EMPTY_LOADER_STRING
124
+ }
100
125
 
101
- return `export function generateStaticParams() {};`
102
- })
103
- .join('\n')
126
+ return `export function generateStaticParams() {};`
127
+ })
128
+ .join('\n')
104
129
 
105
- console.info(
106
- ` 🧹 [one] ${relative(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
107
- )
130
+ console.info(
131
+ ` 🧹 [one] ${relative(process.cwd(), id)} removed ${removedFunctions.length} server-only exports`
132
+ )
108
133
 
109
- return {
110
- code: codeOut,
111
- map: out.map,
134
+ return {
135
+ code: codeOut,
136
+ map: out.map,
137
+ }
138
+ } catch (error) {
139
+ // If code generation fails, skip transformation
140
+ const errorMessage = error instanceof Error ? error.message : String(error)
141
+ console.warn(`[one] Skipping tree shaking for ${id} due to code generation error:`, errorMessage)
142
+ return
112
143
  }
113
144
  }
114
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clientTreeShakePlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/clientTreeShakePlugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,eAAO,MAAM,qBAAqB,QAAO,MA6BxC,CAAA;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;eAuEtE"}
1
+ {"version":3,"file":"clientTreeShakePlugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/clientTreeShakePlugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,eAAO,MAAM,qBAAqB,QAAO,MA6BxC,CAAA;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;eAsGtE"}