Skip to content

Commit

Permalink
fix: use enhanced-resolve instead of resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Nov 8, 2021
1 parent a473570 commit 2ca540e
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 14 deletions.
143 changes: 143 additions & 0 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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
}

/**
Expand Down
23 changes: 15 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ca540e

Please sign in to comment.