diff --git a/package.json b/package.json index 742fc25..f642452 100644 --- a/package.json +++ b/package.json @@ -95,14 +95,13 @@ "@babel/core": "^7.29.0", "@babel/plugin-transform-arrow-functions": "^7.27.1", "cac": "^7.0.0", - "esbuild": "^0.25.11", "magic-string": "^0.30.21", - "picocolors": "^1.1.1" + "picocolors": "^1.1.1", + "rolldown": "~1.2.10" }, "pnpm": { "onlyBuiltDependencies": [ "@swc/core", - "esbuild", "simple-git-hooks" ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b2488f6..0a6073f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,15 +17,15 @@ importers: cac: specifier: ^7.0.0 version: 7.0.0 - esbuild: - specifier: ^0.25.11 - version: 0.25.11 magic-string: specifier: ^0.30.21 version: 0.30.21 picocolors: specifier: ^1.1.1 version: 1.1.1 + rolldown: + specifier: ~1.2.10 + version: 1.2.10 devDependencies: '@eslint/js': specifier: ^10.0.1 @@ -89,7 +89,7 @@ importers: version: 8.57.2(eslint@10.1.0)(typescript@5.9.3) vite: specifier: ^8.0.3 - version: 8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@22.19.15)(esbuild@0.25.11)(yaml@2.8.3) + version: 8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@22.19.15)(yaml@2.8.3) packages: @@ -192,162 +192,6 @@ packages: '@emnapi/wasi-threads@1.2.0': resolution: {integrity: sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==} - '@esbuild/aix-ppc64@0.25.11': - resolution: {integrity: sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [aix] - - '@esbuild/android-arm64@0.25.11': - resolution: {integrity: sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [android] - - '@esbuild/android-arm@0.25.11': - resolution: {integrity: sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==} - engines: {node: '>=18'} - cpu: [arm] - os: [android] - - '@esbuild/android-x64@0.25.11': - resolution: {integrity: sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==} - engines: {node: '>=18'} - cpu: [x64] - os: [android] - - '@esbuild/darwin-arm64@0.25.11': - resolution: {integrity: sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==} - engines: {node: '>=18'} - cpu: [arm64] - os: [darwin] - - '@esbuild/darwin-x64@0.25.11': - resolution: {integrity: sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==} - engines: {node: '>=18'} - cpu: [x64] - os: [darwin] - - '@esbuild/freebsd-arm64@0.25.11': - resolution: {integrity: sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==} - engines: {node: '>=18'} - cpu: [arm64] - os: [freebsd] - - '@esbuild/freebsd-x64@0.25.11': - resolution: {integrity: sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==} - engines: {node: '>=18'} - cpu: [x64] - os: [freebsd] - - '@esbuild/linux-arm64@0.25.11': - resolution: {integrity: sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==} - engines: {node: '>=18'} - cpu: [arm64] - os: [linux] - - '@esbuild/linux-arm@0.25.11': - resolution: {integrity: sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==} - engines: {node: '>=18'} - cpu: [arm] - os: [linux] - - '@esbuild/linux-ia32@0.25.11': - resolution: {integrity: sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==} - engines: {node: '>=18'} - cpu: [ia32] - os: [linux] - - '@esbuild/linux-loong64@0.25.11': - resolution: {integrity: sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==} - engines: {node: '>=18'} - cpu: [loong64] - os: [linux] - - '@esbuild/linux-mips64el@0.25.11': - resolution: {integrity: sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==} - engines: {node: '>=18'} - cpu: [mips64el] - os: [linux] - - '@esbuild/linux-ppc64@0.25.11': - resolution: {integrity: sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [linux] - - '@esbuild/linux-riscv64@0.25.11': - resolution: {integrity: sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==} - engines: {node: '>=18'} - cpu: [riscv64] - os: [linux] - - '@esbuild/linux-s390x@0.25.11': - resolution: {integrity: sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==} - engines: {node: '>=18'} - cpu: [s390x] - os: [linux] - - '@esbuild/linux-x64@0.25.11': - resolution: {integrity: sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==} - engines: {node: '>=18'} - cpu: [x64] - os: [linux] - - '@esbuild/netbsd-arm64@0.25.11': - resolution: {integrity: sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [netbsd] - - '@esbuild/netbsd-x64@0.25.11': - resolution: {integrity: sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==} - engines: {node: '>=18'} - cpu: [x64] - os: [netbsd] - - '@esbuild/openbsd-arm64@0.25.11': - resolution: {integrity: sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openbsd] - - '@esbuild/openbsd-x64@0.25.11': - resolution: {integrity: sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==} - engines: {node: '>=18'} - cpu: [x64] - os: [openbsd] - - '@esbuild/openharmony-arm64@0.25.11': - resolution: {integrity: sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openharmony] - - '@esbuild/sunos-x64@0.25.11': - resolution: {integrity: sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==} - engines: {node: '>=18'} - cpu: [x64] - os: [sunos] - - '@esbuild/win32-arm64@0.25.11': - resolution: {integrity: sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==} - engines: {node: '>=18'} - cpu: [arm64] - os: [win32] - - '@esbuild/win32-ia32@0.25.11': - resolution: {integrity: sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==} - engines: {node: '>=18'} - cpu: [ia32] - os: [win32] - - '@esbuild/win32-x64@0.25.11': - resolution: {integrity: sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==} - engines: {node: '>=18'} - cpu: [x64] - os: [win32] - '@eslint-community/eslint-utils@4.9.1': resolution: {integrity: sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -428,82 +272,163 @@ packages: '@oxc-project/types@0.122.0': resolution: {integrity: sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==} + '@oxc-project/types@0.151.0': + resolution: {integrity: sha512-J1yXrIlNDZVzE3ada310xeAw7nH8yCAyLPuUIsjKatFPmfn5bS1oW+cM+QsGOtVWd5nhSpbwZWx/rue+r5Z+PA==} + '@pkgr/core@0.2.9': resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + '@rolldown/binding-android-arm-eabi@1.2.10': + resolution: {integrity: sha512-bp9svZb+QurZeh+8H4BhrZkifEB0YBNvTVzNSJnJQkj4NrRwmQoDUCGP0vSN7PbvLeM7l1tK6GXL8mrTiH2myg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + '@rolldown/binding-android-arm64@1.0.0-rc.12': resolution: {integrity: sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] + '@rolldown/binding-android-arm64@1.2.10': + resolution: {integrity: sha512-wm6Dld3RXUAZ/gRWKyUy+4W1B5CB5UeFaOzsSWJWEdxZXHH8rCYiZ5dGe6oJmhsunAPWzL7FZV+VtvmN5Ye2eA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + '@rolldown/binding-darwin-arm64@1.0.0-rc.12': resolution: {integrity: sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] + '@rolldown/binding-darwin-arm64@1.2.10': + resolution: {integrity: sha512-UbEfXq/AqGNgRTV3ik+X/iR6mUxu2QdYAadwRxJWquUGnW6gDqdP1FtLtFXRow7RJx0ssRwi80XAPr4r+4DtsA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + '@rolldown/binding-darwin-x64@1.0.0-rc.12': resolution: {integrity: sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] + '@rolldown/binding-darwin-x64@1.2.10': + resolution: {integrity: sha512-7f5h17q5KZVx/ji1vb8OTq31ch1O2I7K8NPIr44GkyWTApXMIsmhWqZfgpOH10xeauqghDAvGlZktasCkcF6Eg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + '@rolldown/binding-freebsd-x64@1.0.0-rc.12': resolution: {integrity: sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] + '@rolldown/binding-freebsd-x64@1.2.10': + resolution: {integrity: sha512-ynOk/eEYhC6ZB2xCGvKrEOwE58oBy9LnrAqtkrDF9Fz1VTaNdGZTsV0VarJdhPwb+sOJTGjCLwcuyRJZ1dnMcQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.12': resolution: {integrity: sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] + '@rolldown/binding-linux-arm-gnueabihf@1.2.10': + resolution: {integrity: sha512-ERrAs185meZZhGan7a4l3RiiJK1ArSDlHdST++uvSxe+FDbR4TwUPahT/cbZJvaG6fIpDpF78surN+tX708Y4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.12': resolution: {integrity: sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] + '@rolldown/binding-linux-arm64-gnu@1.2.10': + resolution: {integrity: sha512-KN7OHKD0J3jy1UzBwZWPxpwhODf9IARUIJcrH+yLYKOcmegZ8luEUM38lDP1bDVj40yP6PsSzCqOJF76vljFnQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.12': resolution: {integrity: sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] + '@rolldown/binding-linux-arm64-musl@1.2.10': + resolution: {integrity: sha512-8l9wP8O+wa8zD6iw6egSfzVtu7oZVfH3hlUsMM4MwbLMhxleqeoXbZzjddyK3YyNlwLhqznq3tF7PkNJ8T/V2w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.12': resolution: {integrity: sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] + '@rolldown/binding-linux-ppc64-gnu@1.2.10': + resolution: {integrity: sha512-SeXNKeQzA5kLhz/J0CH6ZP0/HJ3v1xm/0YbiYpE0kK7emfRC2OIGGIaE14xzkISEGv2aYuUSpiLiU5Gbq+OI0A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.12': resolution: {integrity: sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] + '@rolldown/binding-linux-s390x-gnu@1.2.10': + resolution: {integrity: sha512-mtht0nR+y8/hart4175Ll15w7lY8dg7CtQ+j2FDNTsDRspOWTK/2V3l0aj9sIj7XmvqxT8Yli/wq22e7feTTWg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.12': resolution: {integrity: sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] + '@rolldown/binding-linux-x64-gnu@1.2.10': + resolution: {integrity: sha512-FSM94nGd55NYo48usCyM/nHfUKRnqc9+b0vJNuKV0oCCpIp/OGims7rO1Nv/DkFkt0S/s2rxsJ2kkS8J3HcpeA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + '@rolldown/binding-linux-x64-musl@1.0.0-rc.12': resolution: {integrity: sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] + '@rolldown/binding-linux-x64-musl@1.2.10': + resolution: {integrity: sha512-C3YxNB16myRLs7o+B+6PnQ6jBsdIS4+AE4Ah8glVGhDpEv9AOvxhZ/1duAb4B0UGczEK/lBbccksd8VI+p6zfw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + '@rolldown/binding-openharmony-arm64@1.0.0-rc.12': resolution: {integrity: sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] + '@rolldown/binding-openharmony-arm64@1.2.10': + resolution: {integrity: sha512-571TlE/F1eeTjjdjYAMMMPs1Mfv3MtX6s3+ZKVU6HiUjZ5Njc6c/qzNy/8K3zALTZnaw3JQVYrHxvNfjm43KAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + '@rolldown/binding-wasm32-wasi@1.0.0-rc.12': resolution: {integrity: sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==} engines: {node: '>=14.0.0'} @@ -515,15 +440,30 @@ packages: cpu: [arm64] os: [win32] + '@rolldown/binding-win32-arm64-msvc@1.2.10': + resolution: {integrity: sha512-QXW+ZWaiqs2c7Fi++D/SsW07LTPcUrncxcskJGfGNBoaLik1IU6fJymz4HsqwEO0u5Iq11yTO0B/mc4cPk7jrQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.12': resolution: {integrity: sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] + '@rolldown/binding-win32-x64-msvc@1.2.10': + resolution: {integrity: sha512-5FQFGgah17YeMtG1Yd5a+rMxQpTksyNXxRtKz06FVTaQw3RKYUJQbUoKk0/5jrXBpDo+7makNP7UHA2LQyH64A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@rolldown/pluginutils@1.0.0-rc.12': resolution: {integrity: sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==} + '@rolldown/pluginutils@1.0.1': + resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} + '@rollup/plugin-json@6.1.0': resolution: {integrity: sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==} engines: {node: '>=14.0.0'} @@ -967,11 +907,6 @@ packages: resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==} engines: {node: '>=18'} - esbuild@0.25.11: - resolution: {integrity: sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==} - engines: {node: '>=18'} - hasBin: true - escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -1366,6 +1301,11 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} hasBin: true + rolldown@1.2.10: + resolution: {integrity: sha512-OxkA08pSryMK7B3XiFA09B4OJ1xJMPgIYCBMY2xchzpqgBGsV1o0DetPAE+Sl3N3L4oCPiEzmHVSOj7iR04Zog==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + rollup-plugin-dts@6.4.1: resolution: {integrity: sha512-l//F3Zf7ID5GoOfLfD8kroBjQKEKpy1qfhtAdnpibFZMffPaylrg1CoDC2vGkPeTeyxUe4bVFCln2EFuL7IGGg==} engines: {node: '>=20'} @@ -1693,84 +1633,6 @@ snapshots: tslib: 2.8.1 optional: true - '@esbuild/aix-ppc64@0.25.11': - optional: true - - '@esbuild/android-arm64@0.25.11': - optional: true - - '@esbuild/android-arm@0.25.11': - optional: true - - '@esbuild/android-x64@0.25.11': - optional: true - - '@esbuild/darwin-arm64@0.25.11': - optional: true - - '@esbuild/darwin-x64@0.25.11': - optional: true - - '@esbuild/freebsd-arm64@0.25.11': - optional: true - - '@esbuild/freebsd-x64@0.25.11': - optional: true - - '@esbuild/linux-arm64@0.25.11': - optional: true - - '@esbuild/linux-arm@0.25.11': - optional: true - - '@esbuild/linux-ia32@0.25.11': - optional: true - - '@esbuild/linux-loong64@0.25.11': - optional: true - - '@esbuild/linux-mips64el@0.25.11': - optional: true - - '@esbuild/linux-ppc64@0.25.11': - optional: true - - '@esbuild/linux-riscv64@0.25.11': - optional: true - - '@esbuild/linux-s390x@0.25.11': - optional: true - - '@esbuild/linux-x64@0.25.11': - optional: true - - '@esbuild/netbsd-arm64@0.25.11': - optional: true - - '@esbuild/netbsd-x64@0.25.11': - optional: true - - '@esbuild/openbsd-arm64@0.25.11': - optional: true - - '@esbuild/openbsd-x64@0.25.11': - optional: true - - '@esbuild/openharmony-arm64@0.25.11': - optional: true - - '@esbuild/sunos-x64@0.25.11': - optional: true - - '@esbuild/win32-arm64@0.25.11': - optional: true - - '@esbuild/win32-ia32@0.25.11': - optional: true - - '@esbuild/win32-x64@0.25.11': - optional: true - '@eslint-community/eslint-utils@4.9.1(eslint@10.1.0)': dependencies: eslint: 10.1.0 @@ -1844,44 +1706,85 @@ snapshots: '@oxc-project/types@0.122.0': {} + '@oxc-project/types@0.151.0': {} + '@pkgr/core@0.2.9': {} + '@rolldown/binding-android-arm-eabi@1.2.10': + optional: true + '@rolldown/binding-android-arm64@1.0.0-rc.12': optional: true + '@rolldown/binding-android-arm64@1.2.10': + optional: true + '@rolldown/binding-darwin-arm64@1.0.0-rc.12': optional: true + '@rolldown/binding-darwin-arm64@1.2.10': + optional: true + '@rolldown/binding-darwin-x64@1.0.0-rc.12': optional: true + '@rolldown/binding-darwin-x64@1.2.10': + optional: true + '@rolldown/binding-freebsd-x64@1.0.0-rc.12': optional: true + '@rolldown/binding-freebsd-x64@1.2.10': + optional: true + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-arm-gnueabihf@1.2.10': + optional: true + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-arm64-gnu@1.2.10': + optional: true + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-arm64-musl@1.2.10': + optional: true + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-ppc64-gnu@1.2.10': + optional: true + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-s390x-gnu@1.2.10': + optional: true + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-x64-gnu@1.2.10': + optional: true + '@rolldown/binding-linux-x64-musl@1.0.0-rc.12': optional: true + '@rolldown/binding-linux-x64-musl@1.2.10': + optional: true + '@rolldown/binding-openharmony-arm64@1.0.0-rc.12': optional: true + '@rolldown/binding-openharmony-arm64@1.2.10': + optional: true + '@rolldown/binding-wasm32-wasi@1.0.0-rc.12(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)': dependencies: '@napi-rs/wasm-runtime': 1.1.2(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1) @@ -1893,11 +1796,19 @@ snapshots: '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.12': optional: true + '@rolldown/binding-win32-arm64-msvc@1.2.10': + optional: true + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.12': optional: true + '@rolldown/binding-win32-x64-msvc@1.2.10': + optional: true + '@rolldown/pluginutils@1.0.0-rc.12': {} + '@rolldown/pluginutils@1.0.1': {} + '@rollup/plugin-json@6.1.0(rollup@4.60.0)': dependencies: '@rollup/pluginutils': 5.3.0(rollup@4.60.0) @@ -2273,35 +2184,6 @@ snapshots: environment@1.1.0: {} - esbuild@0.25.11: - optionalDependencies: - '@esbuild/aix-ppc64': 0.25.11 - '@esbuild/android-arm': 0.25.11 - '@esbuild/android-arm64': 0.25.11 - '@esbuild/android-x64': 0.25.11 - '@esbuild/darwin-arm64': 0.25.11 - '@esbuild/darwin-x64': 0.25.11 - '@esbuild/freebsd-arm64': 0.25.11 - '@esbuild/freebsd-x64': 0.25.11 - '@esbuild/linux-arm': 0.25.11 - '@esbuild/linux-arm64': 0.25.11 - '@esbuild/linux-ia32': 0.25.11 - '@esbuild/linux-loong64': 0.25.11 - '@esbuild/linux-mips64el': 0.25.11 - '@esbuild/linux-ppc64': 0.25.11 - '@esbuild/linux-riscv64': 0.25.11 - '@esbuild/linux-s390x': 0.25.11 - '@esbuild/linux-x64': 0.25.11 - '@esbuild/netbsd-arm64': 0.25.11 - '@esbuild/netbsd-x64': 0.25.11 - '@esbuild/openbsd-arm64': 0.25.11 - '@esbuild/openbsd-x64': 0.25.11 - '@esbuild/openharmony-arm64': 0.25.11 - '@esbuild/sunos-x64': 0.25.11 - '@esbuild/win32-arm64': 0.25.11 - '@esbuild/win32-ia32': 0.25.11 - '@esbuild/win32-x64': 0.25.11 - escalade@3.2.0: {} escape-string-regexp@4.0.0: {} @@ -2666,6 +2548,27 @@ snapshots: - '@emnapi/core' - '@emnapi/runtime' + rolldown@1.2.10: + dependencies: + '@oxc-project/types': 0.151.0 + '@rolldown/pluginutils': 1.0.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.10 + '@rolldown/binding-android-arm64': 1.2.10 + '@rolldown/binding-darwin-arm64': 1.2.10 + '@rolldown/binding-darwin-x64': 1.2.10 + '@rolldown/binding-freebsd-x64': 1.2.10 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.10 + '@rolldown/binding-linux-arm64-gnu': 1.2.10 + '@rolldown/binding-linux-arm64-musl': 1.2.10 + '@rolldown/binding-linux-ppc64-gnu': 1.2.10 + '@rolldown/binding-linux-s390x-gnu': 1.2.10 + '@rolldown/binding-linux-x64-gnu': 1.2.10 + '@rolldown/binding-linux-x64-musl': 1.2.10 + '@rolldown/binding-openharmony-arm64': 1.2.10 + '@rolldown/binding-win32-arm64-msvc': 1.2.10 + '@rolldown/binding-win32-x64-msvc': 1.2.10 + rollup-plugin-dts@6.4.1(rollup@4.60.0)(typescript@5.9.3): dependencies: '@jridgewell/remapping': 2.3.5 @@ -2803,7 +2706,7 @@ snapshots: dependencies: punycode: 2.3.1 - vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@22.19.15)(esbuild@0.25.11)(yaml@2.8.3): + vite@8.0.3(@emnapi/core@1.9.1)(@emnapi/runtime@1.9.1)(@types/node@22.19.15)(yaml@2.8.3): dependencies: lightningcss: 1.32.0 picomatch: 4.0.4 @@ -2812,7 +2715,6 @@ snapshots: tinyglobby: 0.2.15 optionalDependencies: '@types/node': 22.19.15 - esbuild: 0.25.11 fsevents: 2.3.3 yaml: 2.8.3 transitivePeerDependencies: diff --git a/src/config.ts b/src/config.ts index 99ca514..446d42a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,7 +1,4 @@ import path from 'node:path' -import fs from 'node:fs' -import { pathToFileURL } from 'node:url' -import { createRequire } from 'node:module' import colors from 'picocolors' import { type UserConfig as ViteConfig, @@ -14,7 +11,6 @@ import { mergeConfig, normalizePath } from 'vite' -import { build } from 'esbuild' import { electronMainConfigPresetPlugin, @@ -33,6 +29,7 @@ import isolateEntriesPlugin from './plugins/isolateEntries' import { type ExternalOptions, externalizeDepsPlugin } from './plugins/externalizeDeps' import { type BytecodeOptions, bytecodePlugin } from './plugins/bytecode' import { isObject, isFilePathESM, deepClone, asyncFlatten } from './utils' +import { findConfigFile, bundleConfigFile, loadConfigFormBundledFile } from './load' export { defineConfig as defineViteConfig } from 'vite' @@ -369,8 +366,6 @@ function isOptions(value: boolean | T): value is T { return typeof value === 'object' && value !== null } -const CONFIG_FILE_NAME = 'electron.vite.config' - export async function loadConfigFromFile( configEnv: ConfigEnv, configFile?: string, @@ -386,9 +381,7 @@ export async function loadConfigFromFile( throw new Error(`config file cannot be named ${configFile}.`) } - const resolvedPath = configFile - ? path.resolve(configFile) - : findConfigFile(configRoot, ['js', 'ts', 'mjs', 'cjs', 'mts', 'cts']) + const resolvedPath = configFile ? path.resolve(configFile) : findConfigFile(configRoot) if (!resolvedPath) { return { @@ -402,7 +395,7 @@ export async function loadConfigFromFile( try { const { code, dependencies } = await bundleConfigFile(resolvedPath, isESM) - const configExport = await loadConfigFormBundledFile(configRoot, resolvedPath, code, isESM) + const configExport = await loadConfigFormBundledFile(resolvedPath, code, isESM) const config = await (typeof configExport === 'function' ? configExport(configEnv) : configExport) if (!isObject(config)) { @@ -428,116 +421,3 @@ export async function loadConfigFromFile( throw e } } - -function findConfigFile(configRoot: string, extensions: string[]): string { - for (const ext of extensions) { - const configFile = path.resolve(configRoot, `${CONFIG_FILE_NAME}.${ext}`) - if (fs.existsSync(configFile)) { - return configFile - } - } - return '' -} - -async function bundleConfigFile(fileName: string, isESM: boolean): Promise<{ code: string; dependencies: string[] }> { - const dirnameVarName = '__electron_vite_injected_dirname' - const filenameVarName = '__electron_vite_injected_filename' - const importMetaUrlVarName = '__electron_vite_injected_import_meta_url' - const result = await build({ - absWorkingDir: process.cwd(), - entryPoints: [fileName], - write: false, - target: ['node20'], - platform: 'node', - bundle: true, - format: isESM ? 'esm' : 'cjs', - sourcemap: false, - metafile: true, - define: { - __dirname: dirnameVarName, - __filename: filenameVarName, - 'import.meta.url': importMetaUrlVarName - }, - plugins: [ - { - name: 'externalize-deps', - setup(build): void { - build.onResolve({ filter: /.*/ }, args => { - const id = args.path - if (id[0] !== '.' && !path.isAbsolute(id)) { - return { - external: true - } - } - return null - }) - } - }, - { - name: 'replace-import-meta', - setup(build): void { - build.onLoad({ filter: /\.[cm]?[jt]s$/ }, async args => { - const contents = await fs.promises.readFile(args.path, 'utf8') - const injectValues = - `const ${dirnameVarName} = ${JSON.stringify(path.dirname(args.path))};` + - `const ${filenameVarName} = ${JSON.stringify(args.path)};` + - `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};` - - return { - loader: args.path.endsWith('ts') ? 'ts' : 'js', - contents: injectValues + contents - } - }) - } - } - ] - }) - const { text } = result.outputFiles[0] - return { - code: text, - dependencies: result.metafile ? Object.keys(result.metafile.inputs) : [] - } -} - -interface NodeModuleWithCompile extends NodeModule { - /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ - _compile(code: string, filename: string): any -} - -const _require = createRequire(import.meta.url) -async function loadConfigFormBundledFile( - configRoot: string, - configFile: string, - bundledCode: string, - isESM: boolean -): Promise { - if (isESM) { - const fileNameTmp = path.resolve(configRoot, `${CONFIG_FILE_NAME}.${Date.now()}.mjs`) - fs.writeFileSync(fileNameTmp, bundledCode) - - const fileUrl = pathToFileURL(fileNameTmp) - try { - return (await import(fileUrl.href)).default - } finally { - try { - fs.unlinkSync(fileNameTmp) - } catch {} - } - } else { - const extension = path.extname(configFile) - const realFileName = fs.realpathSync(configFile) - const loaderExt = extension in _require.extensions ? extension : '.js' - const defaultLoader = _require.extensions[loaderExt]! - _require.extensions[loaderExt] = (module: NodeModule, filename: string): void => { - if (filename === realFileName) { - ;(module as NodeModuleWithCompile)._compile(bundledCode, filename) - } else { - defaultLoader(module, filename) - } - } - delete _require.cache[_require.resolve(configFile)] - const raw = _require(configFile) - _require.extensions[loaderExt] = defaultLoader - return raw.__esModule ? raw.default : raw - } -} diff --git a/src/load.ts b/src/load.ts new file mode 100644 index 0000000..df63ae8 --- /dev/null +++ b/src/load.ts @@ -0,0 +1,130 @@ +import path from 'node:path' +import fs from 'node:fs' +import { pathToFileURL } from 'node:url' +import { createRequire } from 'node:module' +import { rolldown } from 'rolldown' +import type { RolldownOutput, OutputChunk } from 'rolldown' + +const CONFIG_FILE_NAME = 'electron.vite.config' + +export function findConfigFile( + configRoot: string, + extensions: string[] = ['js', 'ts', 'mjs', 'cjs', 'mts', 'cts'] +): string { + for (const ext of extensions) { + const configFile = path.resolve(configRoot, `${CONFIG_FILE_NAME}.${ext}`) + if (fs.existsSync(configFile)) { + return configFile + } + } + return '' +} + +export async function bundleConfigFile( + fileName: string, + isESM: boolean +): Promise<{ code: string; dependencies: string[] }> { + const dirnameVarName = '__electron_vite_injected_dirname' + const filenameVarName = '__electron_vite_injected_filename' + const importMetaUrlVarName = '__electron_vite_injected_import_meta_url' + + const bundle = await rolldown({ + input: path.resolve(fileName), + platform: 'node', + transform: { + target: 'node20', + define: { + __dirname: dirnameVarName, + __filename: filenameVarName, + 'import.meta.url': importMetaUrlVarName + } + }, + plugins: [ + { + name: 'externalize-deps', + resolveId(id) { + if (id[0] !== '.' && !path.isAbsolute(id)) { + return { id, external: true } + } + return null + } + }, + { + name: 'inject-file-scope-variables', + transform: { + filter: { id: /\.[cm]?[jt]s$/ }, + handler(code, id) { + const injectValues = + `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};` + + `const ${filenameVarName} = ${JSON.stringify(id)};` + + `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};` + return { code: injectValues + code, map: null } + } + } + } + ] + }) + + let result: RolldownOutput + try { + result = await bundle.generate({ + format: isESM ? 'esm' : 'cjs', + sourcemap: 'inline', + sourcemapPathTransform(relative, sourcemapPath) { + return path.resolve(path.dirname(sourcemapPath), relative) + }, + codeSplitting: false + }) + } finally { + await bundle.close() + } + + const entryChunk = result.output.find((chunk): chunk is OutputChunk => chunk.type === 'chunk' && chunk.isEntry) + if (!entryChunk) { + throw new Error(`Failed to bundle config file: ${fileName}`) + } + + return { + code: entryChunk.code, + dependencies: entryChunk.moduleIds.filter(id => !id.startsWith('\0')) + } +} + +interface NodeModuleWithCompile extends NodeModule { + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ + _compile(code: string, filename: string): any +} + +const _require = createRequire(import.meta.url) + +export async function loadConfigFormBundledFile(fileName: string, bundledCode: string, isESM: boolean): Promise { + if (isESM) { + const fileNameTmp = `${fileName}.${Date.now()}-${Math.random().toString(16).slice(2)}.mjs` + fs.writeFileSync(fileNameTmp, bundledCode) + + const fileUrl = pathToFileURL(fileNameTmp) + try { + return (await import(fileUrl.href)).default + } finally { + try { + fs.unlinkSync(fileNameTmp) + } catch {} + } + } else { + const extension = path.extname(fileName) + const realFileName = fs.realpathSync(fileName) + const loaderExt = extension in _require.extensions ? extension : '.js' + const defaultLoader = _require.extensions[loaderExt]! + _require.extensions[loaderExt] = (module: NodeModule, filename: string): void => { + if (filename === realFileName) { + ;(module as NodeModuleWithCompile)._compile(bundledCode, filename) + } else { + defaultLoader(module, filename) + } + } + delete _require.cache[_require.resolve(fileName)] + const raw = _require(fileName) + _require.extensions[loaderExt] = defaultLoader + return raw.__esModule ? raw.default : raw + } +}