diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 5f63f6317a6e59..540b07e99c9c55 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -1854,6 +1854,33 @@ Repository: git+https://github.com/isaacs/fs.realpath.git --------------------------------------- +## function-bind +License: MIT +By: Raynos, Jordan Harband +Repository: git://github.com/Raynos/function-bind.git + +> Copyright (c) 2013 Raynos. +> +> 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. + +--------------------------------------- + ## generic-names License: MIT By: Alexey Litvinov @@ -1969,6 +1996,36 @@ Repository: sindresorhus/globby --------------------------------------- +## has +License: MIT +By: Thiago de Arruda, Jordan Harband +Repository: git://github.com/tarruda/has.git + +> Copyright (c) 2013 Thiago de Arruda +> +> 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. + +--------------------------------------- + ## has-flag License: MIT By: Sindre Sorhus @@ -2371,6 +2428,34 @@ Repository: sindresorhus/is-binary-path --------------------------------------- +## is-core-module +License: MIT +By: Jordan Harband +Repository: git+https://github.com/inspect-js/is-core-module.git + +> The MIT License (MIT) +> +> Copyright (c) 2014 Dave Justice +> +> 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. + +--------------------------------------- + ## is-docker License: MIT By: Sindre Sorhus @@ -3601,6 +3686,35 @@ Repository: sindresorhus/path-key --------------------------------------- +## path-parse +License: MIT +By: Javier Blanco +Repository: https://github.com/jbgutierrez/path-parse.git + +> The MIT License (MIT) +> +> Copyright (c) 2015 Javier Blanco +> +> 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. + +--------------------------------------- + ## path-type License: MIT By: Sindre Sorhus @@ -4019,6 +4133,35 @@ Repository: https://github.com/unshiftio/requires-port --------------------------------------- +## resolve +License: MIT +By: James Halliday +Repository: git://github.com/browserify/resolve.git + +> MIT License +> +> Copyright (c) 2012 James Halliday +> +> 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. + +--------------------------------------- + ## resolve-from License: MIT By: Sindre Sorhus diff --git a/packages/vite/package.json b/packages/vite/package.json index c21cb540072a80..3d471b12eb40de 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -44,9 +44,9 @@ }, "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!", "dependencies": { + "enhanced-resolve": "^5.8.2", "esbuild": "^0.13.12", "postcss": "^8.3.11", - "resolve": "^1.20.0", "rollup": "^2.59.0" }, "optionalDependencies": { @@ -70,7 +70,6 @@ "@types/less": "^3.0.3", "@types/mime": "^2.0.3", "@types/node": "^16.11.6", - "@types/resolve": "^1.20.1", "@types/sass": "~1.43.0", "@types/stylus": "^0.48.36", "@types/ws": "^8.2.0", diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index bdbbce4faa166e..58beaa6969bf95 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1,5 +1,6 @@ import debug from 'debug' import chalk from 'chalk' +import enhancedResolve from 'enhanced-resolve' import fs from 'fs' import os from 'os' import path from 'path' @@ -11,7 +12,6 @@ import { CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH } from './constants' -import resolve from 'resolve' import builtins from 'builtin-modules' import { FSWatcher } from 'chokidar' import remapping from '@ampproject/remapping' @@ -66,12 +66,16 @@ export function resolveFrom( preserveSymlinks = false, ssr = false ): string { - return resolve.sync(id, { - basedir, + preserveSymlinks = preserveSymlinks || isRunningWithYarnPnp || false + const resolve = enhancedResolve.create.sync({ extensions: ssr ? ssrExtensions : DEFAULT_EXTENSIONS, // necessary to work with pnpm - preserveSymlinks: preserveSymlinks || isRunningWithYarnPnp || false + symlinks: !preserveSymlinks, + conditionNames: ['node', 'require'], + // allow package.json resolution even if not exported + exportsFields: id.endsWith('/package.json') ? [] : ['exports'] }) + return resolve(basedir, id) as string } /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb312ee8b4d82f..98b6475bb4c173 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -687,7 +687,6 @@ importers: '@types/less': ^3.0.3 '@types/mime': ^2.0.3 '@types/node': ^16.11.6 - '@types/resolve': ^1.20.1 '@types/sass': ~1.43.0 '@types/stylus': ^0.48.36 '@types/ws': ^8.2.0 @@ -707,6 +706,7 @@ importers: debug: ^4.3.2 dotenv: ^10.0.0 dotenv-expand: ^5.1.0 + enhanced-resolve: ^5.8.2 es-module-lexer: ^0.9.3 esbuild: ^0.13.12 estree-walker: ^2.0.2 @@ -726,7 +726,6 @@ importers: postcss-import: ^14.0.2 postcss-load-config: ^3.1.0 postcss-modules: ^4.2.2 - resolve: ^1.20.0 resolve.exports: ^1.1.0 rollup: ^2.59.0 rollup-plugin-license: ^2.6.0 @@ -741,9 +740,9 @@ importers: types: link:./types ws: ^8.2.3 dependencies: + enhanced-resolve: 5.8.3 esbuild: 0.13.12 postcss: 8.3.11 - resolve: 1.20.0 rollup: 2.59.0 optionalDependencies: fsevents: 2.3.2 @@ -765,7 +764,6 @@ importers: '@types/less': 3.0.3 '@types/mime': 2.0.3 '@types/node': 16.11.6 - '@types/resolve': 1.20.1 '@types/sass': 1.43.0 '@types/stylus': 0.48.36 '@types/ws': 8.2.0 @@ -2150,10 +2148,6 @@ packages: '@types/node': 16.11.6 dev: true - /@types/resolve/1.20.1: - resolution: {integrity: sha512-Ku5+GPFa12S3W26Uwtw+xyrtIpaZsGYHH6zxNbZlstmlvMYSZRzOwzwsXbxlVUbHyUucctSyuFtu6bNxwYomIw==} - dev: true - /@types/sass/1.43.0: resolution: {integrity: sha512-DPSXNJ1rYLo88GyF9tuB4bsYGfpKI1a4+wOQmc+LI1SUoocm9QLRSpz0GxxuyjmJsYFIQo/dDlRSSpIXngff+w==} dependencies: @@ -3770,6 +3764,14 @@ packages: once: 1.4.0 dev: true + /enhanced-resolve/5.8.3: + resolution: {integrity: sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA==} + engines: {node: '>=10.13.0'} + dependencies: + graceful-fs: 4.2.8 + tapable: 2.2.1 + dev: false + /enquirer/2.3.6: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} engines: {node: '>=8.6'} @@ -8129,6 +8131,11 @@ packages: - ts-node dev: false + /tapable/2.2.1: + resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} + engines: {node: '>=6'} + dev: false + /temp-dir/2.0.0: resolution: {integrity: sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==} engines: {node: '>=8'}