Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8dfac1

Browse filesBrowse files
committed
use resolve for even more robust dep checking
1 parent d715da3 commit c8dfac1
Copy full SHA for c8dfac1

File tree

3 files changed

+4356
-5
lines changed
Filter options

3 files changed

+4356
-5
lines changed

‎lib/utils/try-require.js

Copy file name to clipboardExpand all lines: lib/utils/try-require.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
var fs = require('fs')
2-
var path = require('path')
31
var cwd = process.cwd()
2+
var resolve = require('resolve')
43

54
// attempts to first require a dep using projects cwd (when vue-loader is linked)
65
// then try a normal require.
76
module.exports = function tryRequire (dep) {
8-
var cwdPath = path.resolve(cwd, 'node_modules', dep)
9-
if (fs.existsSync(cwdPath)) {
10-
return require(cwdPath)
7+
var fromCwd
8+
try {
9+
fromCwd = resolve.sync(dep, { basedir: cwd })
10+
} catch (e) {}
11+
if (fromCwd) {
12+
return require(fromCwd)
1113
} else {
1214
try {
1315
return require(dep)

‎package.json

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"postcss": "^5.0.21",
3838
"postcss-load-config": "^1.1.0",
3939
"postcss-selector-parser": "^2.0.0",
40+
"resolve": "^1.3.3",
4041
"source-map": "^0.5.6",
4142
"vue-hot-reload-api": "^2.1.0",
4243
"vue-style-loader": "^3.0.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.