From 40dff8f2488eda18ab260bd55d5bf2fc1c5d8230 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Fri, 7 Mar 2025 20:04:05 -0800 Subject: [PATCH] clean up --- package.json | 8 +- pnpm-lock.yaml | 125 ++++++++++++++++--------------- rewriter/rewriter/src/visitor.rs | 26 ++----- 3 files changed, 76 insertions(+), 83 deletions(-) diff --git a/package.json b/package.json index 39efff8..06bf5e4 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "license": "MIT", "devDependencies": { "@eslint/eslintrc": "^3.3.0", - "@eslint/js": "^9.21.0", + "@eslint/js": "^9.22.0", "@estruyf/github-actions-reporter": "^1.10.0", "@fastify/static": "^8.1.1", "@mercuryworkshop/bare-as-module3": "^2.2.5", @@ -40,7 +40,7 @@ "@mercuryworkshop/libcurl-transport": "^1.4.0", "@mercuryworkshop/wisp-js": "^0.3.3", "@nebula-services/bare-server-node": "^2.0.4", - "@playwright/test": "^1.50.1", + "@playwright/test": "^1.51.0", "@rsdoctor/rspack-plugin": "^0.4.13", "@rspack/cli": "^1.2.7", "@rspack/core": "^1.2.7", @@ -51,9 +51,9 @@ "@typescript-eslint/eslint-plugin": "^8.26.0", "@typescript-eslint/parser": "^8.26.0", "dotenv": "^16.4.7", - "eslint": "^9.21.0", + "eslint": "^9.22.0", "fastify": "^5.2.1", - "playwright": "^1.50.1", + "playwright": "^1.51.0", "prettier": "^3.5.3", "tslib": "^2.8.1", "typescript": "^5.8.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5bae5c8..b858159 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,11 +34,11 @@ importers: specifier: ^3.3.0 version: 3.3.0 '@eslint/js': - specifier: ^9.21.0 - version: 9.21.0 + specifier: ^9.22.0 + version: 9.22.0 '@estruyf/github-actions-reporter': specifier: ^1.10.0 - version: 1.10.0(@playwright/test@1.50.1) + version: 1.10.0(@playwright/test@1.51.0) '@fastify/static': specifier: ^8.1.1 version: 8.1.1 @@ -58,8 +58,8 @@ importers: specifier: ^2.0.4 version: 2.0.4(bufferutil@4.0.9) '@playwright/test': - specifier: ^1.50.1 - version: 1.50.1 + specifier: ^1.51.0 + version: 1.51.0 '@rsdoctor/rspack-plugin': specifier: ^0.4.13 version: 0.4.13(@rspack/core@1.2.7)(bufferutil@4.0.9)(webpack@5.97.1) @@ -83,22 +83,22 @@ importers: version: 0.0.123 '@typescript-eslint/eslint-plugin': specifier: ^8.26.0 - version: 8.26.0(@typescript-eslint/parser@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2) + version: 8.26.0(@typescript-eslint/parser@8.26.0(eslint@9.22.0)(typescript@5.8.2))(eslint@9.22.0)(typescript@5.8.2) '@typescript-eslint/parser': specifier: ^8.26.0 - version: 8.26.0(eslint@9.21.0)(typescript@5.8.2) + version: 8.26.0(eslint@9.22.0)(typescript@5.8.2) dotenv: specifier: ^16.4.7 version: 16.4.7 eslint: - specifier: ^9.21.0 - version: 9.21.0 + specifier: ^9.22.0 + version: 9.22.0 fastify: specifier: ^5.2.1 version: 5.2.1 playwright: - specifier: ^1.50.1 - version: 1.50.1 + specifier: ^1.51.0 + version: 1.51.0 prettier: specifier: ^3.5.3 version: 3.5.3 @@ -153,6 +153,10 @@ packages: resolution: {integrity: sha512-GNKqxfHG2ySmJOBSHg7LxeUx4xpuCoFjacmlCoYWEbaPXLwvfIjixRI12xCQZeULksQb23uiA8F40w5TojpV7w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@eslint/config-helpers@0.1.0': + resolution: {integrity: sha512-kLrdPDJE1ckPo94kmPPf9Hfd0DU0Jw6oKYrhe+pwSC0iTUInmTa+w6fw8sGgcfkFJGNdWOUeOaDM4quW4a7OkA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@eslint/core@0.12.0': resolution: {integrity: sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -161,8 +165,8 @@ packages: resolution: {integrity: sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.21.0': - resolution: {integrity: sha512-BqStZ3HX8Yz6LvsF5ByXYrtigrV5AXADWLAGc7PH/1SxOb7/FIYYMszZZWiUou/GB9P2lXWk2SV4d+Z8h0nknw==} + '@eslint/js@9.22.0': + resolution: {integrity: sha512-vLFajx9o8d1/oL2ZkpMYbkLv8nDB6yaIwFNt7nI4+I80U/z03SxmfOMsLbvWr3p7C+Wnoh//aOu2pQW8cS0HCQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.6': @@ -334,8 +338,8 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} - '@playwright/test@1.50.1': - resolution: {integrity: sha512-Jii3aBg+CEDpgnuDxEp/h7BimHcUTDlpEtce89xEumlJ5ef2hqepZ+PWp1DDpYC/VO9fmWVI1IlEaoI5fK9FXQ==} + '@playwright/test@1.51.0': + resolution: {integrity: sha512-dJ0dMbZeHhI+wb77+ljx/FeC8VBP6j/rj9OAojO08JI80wTZy6vRk9KvHKiDCUh4iMpEiseMgqRBIeW+eKX6RA==} engines: {node: '>=18'} hasBin: true @@ -758,8 +762,8 @@ packages: avvio@9.1.0: resolution: {integrity: sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==} - axios@1.8.1: - resolution: {integrity: sha512-NN+fvwH/kV01dYUQ3PTOZns4LWtWhOFCAhQ/pHb88WQ1hNe5V/dvFwc4VJcDL11LT9xSX0QtsR8sWUuyOuOq7g==} + axios@1.8.2: + resolution: {integrity: sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==} balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -1059,8 +1063,8 @@ packages: ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - electron-to-chromium@1.5.112: - resolution: {integrity: sha512-oen93kVyqSb3l+ziUgzIOlWt/oOuy4zRmpwestMn4rhFWAoFJeFuCVte9F2fASjeZZo7l/Cif9TiyrdW4CwEMA==} + electron-to-chromium@1.5.113: + resolution: {integrity: sha512-wjT2O4hX+wdWPJ76gWSkMhcHAV2PTMX+QetUCPYEdCIe+cxmgzzSSiGRCKW8nuh4mwKZlpv0xvoW7OF2X+wmHg==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -1146,8 +1150,8 @@ packages: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} - eslint-scope@8.2.0: - resolution: {integrity: sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==} + eslint-scope@8.3.0: + resolution: {integrity: sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} eslint-visitor-keys@3.4.3: @@ -1158,8 +1162,8 @@ packages: resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.21.0: - resolution: {integrity: sha512-KjeihdFqTPhOMXTt7StsDxriV4n66ueuF/jfPNC3j/lduHwr/ijDwJMsF+wyMJethgiKi5wniIE243vi07d3pg==} + eslint@9.22.0: + resolution: {integrity: sha512-9V/QURhsRN40xuHXWjV64yvrzMjcz7ZyNoF2jJFmy9j/SLk0u1OLSZgXi28MrXjymnjEGSR80WCdab3RGMDveQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -1921,13 +1925,13 @@ packages: resolution: {integrity: sha512-i85pKRCt4qMjZ1+L7sy2Ag4t1atFcdbEt76+7iRJn1g2BvsnRMGu9p8pivl9fs63M2kF/A0OacFZhTub+m/qMg==} hasBin: true - playwright-core@1.50.1: - resolution: {integrity: sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==} + playwright-core@1.51.0: + resolution: {integrity: sha512-x47yPE3Zwhlil7wlNU/iktF7t2r/URR3VLbH6EknJd/04Qc/PSJ0EY3CMXipmglLG+zyRxW6HNo2EGbKLHPWMg==} engines: {node: '>=18'} hasBin: true - playwright@1.50.1: - resolution: {integrity: sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==} + playwright@1.51.0: + resolution: {integrity: sha512-442pTfGM0xxfCYxuBa/Pu6B2OqxqqaYq39JS8QDMGThUvIOCd6s0ANDog3uwA0cHavVlnTQzGCN7Id2YekDSXA==} engines: {node: '>=18'} hasBin: true @@ -2550,9 +2554,9 @@ snapshots: '@discoveryjs/json-ext@0.5.7': {} - '@eslint-community/eslint-utils@4.4.1(eslint@9.21.0)': + '@eslint-community/eslint-utils@4.4.1(eslint@9.22.0)': dependencies: - eslint: 9.21.0 + eslint: 9.22.0 eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} @@ -2565,6 +2569,8 @@ snapshots: transitivePeerDependencies: - supports-color + '@eslint/config-helpers@0.1.0': {} + '@eslint/core@0.12.0': dependencies: '@types/json-schema': 7.0.15 @@ -2583,7 +2589,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@9.21.0': {} + '@eslint/js@9.22.0': {} '@eslint/object-schema@2.1.6': {} @@ -2592,10 +2598,10 @@ snapshots: '@eslint/core': 0.12.0 levn: 0.4.1 - '@estruyf/github-actions-reporter@1.10.0(@playwright/test@1.50.1)': + '@estruyf/github-actions-reporter@1.10.0(@playwright/test@1.51.0)': dependencies: '@actions/core': 1.11.1 - '@playwright/test': 1.50.1 + '@playwright/test': 1.51.0 ansi-to-html: 0.7.2 marked: 12.0.2 @@ -2781,9 +2787,9 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@playwright/test@1.50.1': + '@playwright/test@1.51.0': dependencies: - playwright: 1.50.1 + playwright: 1.51.0 '@polka/url@1.0.0-next.28': {} @@ -2795,7 +2801,7 @@ snapshots: '@rsdoctor/sdk': 0.4.13(@rspack/core@1.2.7)(bufferutil@4.0.9)(webpack@5.97.1) '@rsdoctor/types': 0.4.13(@rspack/core@1.2.7)(webpack@5.97.1) '@rsdoctor/utils': 0.4.13(@rspack/core@1.2.7)(webpack@5.97.1) - axios: 1.8.1 + axios: 1.8.2 enhanced-resolve: 5.12.0 filesize: 10.1.6 fs-extra: 11.3.0 @@ -3113,15 +3119,15 @@ snapshots: dependencies: '@types/node': 22.13.9 - '@typescript-eslint/eslint-plugin@8.26.0(@typescript-eslint/parser@8.26.0(eslint@9.21.0)(typescript@5.8.2))(eslint@9.21.0)(typescript@5.8.2)': + '@typescript-eslint/eslint-plugin@8.26.0(@typescript-eslint/parser@8.26.0(eslint@9.22.0)(typescript@5.8.2))(eslint@9.22.0)(typescript@5.8.2)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.26.0(eslint@9.21.0)(typescript@5.8.2) + '@typescript-eslint/parser': 8.26.0(eslint@9.22.0)(typescript@5.8.2) '@typescript-eslint/scope-manager': 8.26.0 - '@typescript-eslint/type-utils': 8.26.0(eslint@9.21.0)(typescript@5.8.2) - '@typescript-eslint/utils': 8.26.0(eslint@9.21.0)(typescript@5.8.2) + '@typescript-eslint/type-utils': 8.26.0(eslint@9.22.0)(typescript@5.8.2) + '@typescript-eslint/utils': 8.26.0(eslint@9.22.0)(typescript@5.8.2) '@typescript-eslint/visitor-keys': 8.26.0 - eslint: 9.21.0 + eslint: 9.22.0 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 @@ -3130,14 +3136,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.26.0(eslint@9.21.0)(typescript@5.8.2)': + '@typescript-eslint/parser@8.26.0(eslint@9.22.0)(typescript@5.8.2)': dependencies: '@typescript-eslint/scope-manager': 8.26.0 '@typescript-eslint/types': 8.26.0 '@typescript-eslint/typescript-estree': 8.26.0(typescript@5.8.2) '@typescript-eslint/visitor-keys': 8.26.0 debug: 4.4.0 - eslint: 9.21.0 + eslint: 9.22.0 typescript: 5.8.2 transitivePeerDependencies: - supports-color @@ -3147,12 +3153,12 @@ snapshots: '@typescript-eslint/types': 8.26.0 '@typescript-eslint/visitor-keys': 8.26.0 - '@typescript-eslint/type-utils@8.26.0(eslint@9.21.0)(typescript@5.8.2)': + '@typescript-eslint/type-utils@8.26.0(eslint@9.22.0)(typescript@5.8.2)': dependencies: '@typescript-eslint/typescript-estree': 8.26.0(typescript@5.8.2) - '@typescript-eslint/utils': 8.26.0(eslint@9.21.0)(typescript@5.8.2) + '@typescript-eslint/utils': 8.26.0(eslint@9.22.0)(typescript@5.8.2) debug: 4.4.0 - eslint: 9.21.0 + eslint: 9.22.0 ts-api-utils: 2.0.1(typescript@5.8.2) typescript: 5.8.2 transitivePeerDependencies: @@ -3174,13 +3180,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.26.0(eslint@9.21.0)(typescript@5.8.2)': + '@typescript-eslint/utils@8.26.0(eslint@9.22.0)(typescript@5.8.2)': dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.21.0) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.22.0) '@typescript-eslint/scope-manager': 8.26.0 '@typescript-eslint/types': 8.26.0 '@typescript-eslint/typescript-estree': 8.26.0(typescript@5.8.2) - eslint: 9.21.0 + eslint: 9.22.0 typescript: 5.8.2 transitivePeerDependencies: - supports-color @@ -3362,7 +3368,7 @@ snapshots: '@fastify/error': 4.0.0 fastq: 1.19.1 - axios@1.8.1: + axios@1.8.2: dependencies: follow-redirects: 1.15.9 form-data: 4.0.2 @@ -3416,7 +3422,7 @@ snapshots: browserslist@4.24.4: dependencies: caniuse-lite: 1.0.30001702 - electron-to-chromium: 1.5.112 + electron-to-chromium: 1.5.113 node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.24.4) @@ -3650,7 +3656,7 @@ snapshots: ee-first@1.1.1: {} - electron-to-chromium@1.5.112: {} + electron-to-chromium@1.5.113: {} emoji-regex@8.0.0: {} @@ -3726,7 +3732,7 @@ snapshots: esrecurse: 4.3.0 estraverse: 4.3.0 - eslint-scope@8.2.0: + eslint-scope@8.3.0: dependencies: esrecurse: 4.3.0 estraverse: 5.3.0 @@ -3735,14 +3741,15 @@ snapshots: eslint-visitor-keys@4.2.0: {} - eslint@9.21.0: + eslint@9.22.0: dependencies: - '@eslint-community/eslint-utils': 4.4.1(eslint@9.21.0) + '@eslint-community/eslint-utils': 4.4.1(eslint@9.22.0) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.19.2 + '@eslint/config-helpers': 0.1.0 '@eslint/core': 0.12.0 '@eslint/eslintrc': 3.3.0 - '@eslint/js': 9.21.0 + '@eslint/js': 9.22.0 '@eslint/plugin-kit': 0.2.7 '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 @@ -3754,7 +3761,7 @@ snapshots: cross-spawn: 7.0.6 debug: 4.4.0 escape-string-regexp: 4.0.0 - eslint-scope: 8.2.0 + eslint-scope: 8.3.0 eslint-visitor-keys: 4.2.0 espree: 10.3.0 esquery: 1.6.0 @@ -4512,11 +4519,11 @@ snapshots: sonic-boom: 4.2.0 thread-stream: 3.1.0 - playwright-core@1.50.1: {} + playwright-core@1.51.0: {} - playwright@1.50.1: + playwright@1.51.0: dependencies: - playwright-core: 1.50.1 + playwright-core: 1.51.0 optionalDependencies: fsevents: 2.3.2 diff --git a/rewriter/rewriter/src/visitor.rs b/rewriter/rewriter/src/visitor.rs index 80346ea..54ec186 100644 --- a/rewriter/rewriter/src/visitor.rs +++ b/rewriter/rewriter/src/visitor.rs @@ -2,10 +2,10 @@ use oxc::{ allocator::{Allocator, String}, ast::ast::{ AssignmentExpression, AssignmentTarget, CallExpression, DebuggerStatement, - ExportAllDeclaration, ExportNamedDeclaration, Expression, ForInStatement, ForOfStatement, - FunctionBody, IdentifierReference, ImportDeclaration, ImportExpression, MemberExpression, - MetaProperty, NewExpression, ObjectExpression, ObjectPropertyKind, ReturnStatement, - ThisExpression, UnaryExpression, UnaryOperator, UpdateExpression, + ExportAllDeclaration, ExportNamedDeclaration, Expression, FunctionBody, + IdentifierReference, ImportDeclaration, ImportExpression, MemberExpression, MetaProperty, + NewExpression, ObjectExpression, ObjectPropertyKind, ReturnStatement, ThisExpression, + UnaryExpression, UnaryOperator, UpdateExpression, }, ast_visit::{walk, Visit}, span::{Atom, GetSpan, Span}, @@ -61,7 +61,7 @@ where } fn walk_member_expression(&mut self, it: &Expression) -> bool { - if match it { + match it { Expression::Identifier(s) => { self.rewrite_ident(&s.name, s.span); true @@ -69,12 +69,7 @@ where Expression::StaticMemberExpression(s) => self.walk_member_expression(&s.object), Expression::ComputedMemberExpression(s) => self.walk_member_expression(&s.object), _ => false, - } { - return true; } - - // don't walk further here it causes issues with constructors - false } fn scramitize(&mut self, span: Span) { @@ -106,7 +101,6 @@ where // } } - // we need to rewrite `new Something` to `new (wrapfn(Something))` instead of `new wrapfn(Something)`, that's why there's weird extra code here fn visit_new_expression(&mut self, it: &NewExpression<'data>) { self.walk_member_expression(&it.callee); walk::walk_arguments(self, &it.arguments); @@ -159,7 +153,7 @@ where // if it's optional that actually makes it an indirect eval which is handled separately if s.name == "eval" && !it.optional { self.jschanges.add(Rewrite::Eval { - span: Span::new(it.span.start, it.span.end), + span: it.span, inner: Span::new(s.span.end + 1, it.span.end), }); @@ -277,14 +271,6 @@ where walk::walk_unary_expression(self, it); } - // we don't want to rewrite the identifiers here because of a very specific edge case - fn visit_for_in_statement(&mut self, it: &ForInStatement<'data>) { - walk::walk_statement(self, &it.body); - } - fn visit_for_of_statement(&mut self, it: &ForOfStatement<'data>) { - walk::walk_statement(self, &it.body); - } - fn visit_update_expression(&mut self, _it: &UpdateExpression<'data>) { // then no, don't walk it, we don't care }