diff --git a/package.json b/package.json index 12d6e36d63d241..60a5773daed501 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "@types/babel__core": "^7.20.5", "@types/babel__preset-env": "^7.10.0", "@types/convert-source-map": "^2.0.3", - "@types/cross-spawn": "^6.0.6", "@types/etag": "^1.8.4", "@types/less": "^3.0.8", "@types/node": "^24.13.6", diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 6d24a5e9c7c10d..07a9200aa51018 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -674,35 +674,6 @@ Repository: https://github.com/expressjs/cors --------------------------------------- -## cross-spawn -License: MIT -By: André Cruz -Repository: https://github.com/moxystudio/node-cross-spawn - -> The MIT License (MIT) -> -> Copyright (c) 2018 Made With MOXY Lda -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - ## cssesc License: MIT By: Mathias Bynens @@ -1226,29 +1197,6 @@ Repository: https://github.com/Rich-Harris/is-reference --------------------------------------- -## isexe, which -License: ISC -By: Isaac Z. Schlueter -Repositories: https://github.com/isaacs/isexe, https://github.com/isaacs/node-which - -> The ISC License -> -> Copyright (c) Isaac Z. Schlueter and Contributors -> -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -> IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - ## js-tokens License: MIT By: Simon Lydell @@ -1669,23 +1617,6 @@ Repository: https://github.com/pillarjs/parseurl --------------------------------------- -## path-key, shebang-regex -License: MIT -By: Sindre Sorhus -Repositories: https://github.com/sindresorhus/path-key, https://github.com/sindresorhus/shebang-regex - -> MIT License -> -> Copyright (c) Sindre Sorhus (sindresorhus.com) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## periscopic License: MIT Repository: https://github.com/Rich-Harris/periscopic @@ -1996,23 +1927,6 @@ Repositories: https://github.com/lukeed/resolve.exports, https://github.com/luke --------------------------------------- -## shebang-command -License: MIT -By: Kevin Mårtensson -Repository: https://github.com/kevva/shebang-command - -> MIT License -> -> Copyright (c) Kevin Mårtensson (github.com/kevva) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## shell-quote License: MIT By: James Halliday @@ -2118,6 +2032,35 @@ Repository: https://github.com/antfu/strip-literal --------------------------------------- +## tinyexec +License: MIT +By: James Garbutt +Repository: https://github.com/tinylibs/tinyexec + +> MIT License +> +> Copyright (c) 2024 Tinylibs +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + ## to-regex-range License: MIT By: Jon Schlinkert, Rouven Weßling diff --git a/packages/vite/package.json b/packages/vite/package.json index a4a112d4554b5d..885045ff487629 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -96,7 +96,6 @@ "connect": "^3.7.0", "convert-source-map": "^2.0.0", "cors": "^2.8.6", - "cross-spawn": "^7.0.6", "dotenv-expand": "^13.0.0", "es-module-lexer": "^2.3.2", "esbuild": "^0.28.2", @@ -130,6 +129,7 @@ "sirv": "^3.0.2", "strip-literal": "^4.0.0", "terser": "^5.51.2", + "tinyexec": "^1.3.1", "ufo": "^1.6.4", "ws": "^8.21.3" }, diff --git a/packages/vite/src/node/server/openBrowser.ts b/packages/vite/src/node/server/openBrowser.ts index a0bc4d475a214e..2715a96e5d9688 100644 --- a/packages/vite/src/node/server/openBrowser.ts +++ b/packages/vite/src/node/server/openBrowser.ts @@ -11,10 +11,10 @@ import { exec } from 'node:child_process' import type { ExecOptions } from 'node:child_process' import { join } from 'node:path' -import spawn from 'cross-spawn' import open from 'open' import type { Options } from 'open' import colors from 'picocolors' +import { x } from 'tinyexec' import { VITE_PACKAGE_DIR } from '../constants' import type { Logger } from '../logger' @@ -41,16 +41,15 @@ export function openBrowser( function executeNodeScript(scriptPath: string, url: string, logger: Logger) { const extraArgs = process.argv.slice(2) - const child = spawn(process.execPath, [scriptPath, ...extraArgs, url], { - stdio: 'inherit', - }) - child.on('close', (code) => { - if (code !== 0) { + x(process.execPath, [scriptPath, ...extraArgs, url], { + nodeOptions: { stdio: 'inherit' }, + }).then(({ exitCode }) => { + if (exitCode !== 0) { logger.error( colors.red( `\nThe script specified as BROWSER environment variable failed.\n\n${colors.cyan( scriptPath, - )} exited with code ${code}.`, + )} exited with code ${exitCode}.`, ), { error: null }, ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0f1476480c028..3ab7eda3ba8254 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -196,9 +196,6 @@ importers: '@types/convert-source-map': specifier: ^2.0.3 version: 2.0.3 - '@types/cross-spawn': - specifier: ^6.0.6 - version: 6.0.6 '@types/etag': specifier: ^1.8.4 version: 1.8.4 @@ -465,9 +462,6 @@ importers: cors: specifier: ^2.8.6 version: 2.8.6 - cross-spawn: - specifier: ^7.0.6 - version: 7.0.6 dotenv-expand: specifier: ^13.0.0 version: 13.0.0(patch_hash=49330a663821151418e003e822a82a6a61d2f0f8a6e3cab00c1c94815a112889) @@ -567,6 +561,9 @@ importers: terser: specifier: ^5.51.2 version: 5.51.2 + tinyexec: + specifier: ^1.3.1 + version: 1.3.1 ufo: specifier: ^1.6.4 version: 1.6.4 @@ -4280,9 +4277,6 @@ packages: '@types/convert-source-map@2.0.3': resolution: {integrity: sha512-ag0BfJLZf6CQz8VIuRIEYQ5Ggwk/82uvTQf27RcpyDNbY0Vw49LIPqAxk5tqYfrCs9xDaIMvl4aj7ZopnYL8bA==} - '@types/cross-spawn@6.0.6': - resolution: {integrity: sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA==} - '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -10409,10 +10403,6 @@ snapshots: '@types/convert-source-map@2.0.3': {} - '@types/cross-spawn@6.0.6': - dependencies: - '@types/node': 24.13.6 - '@types/debug@4.1.12': dependencies: '@types/ms': 2.1.0