Clean up compiler.tryResolveAppPath
Enable the strict mode by default.
This commit is contained in:
parent
e3763ac28e
commit
acb3d1815f
|
@ -272,7 +272,7 @@ function findModelDefinitions(rootDir, sources) {
|
||||||
var registry = {};
|
var registry = {};
|
||||||
|
|
||||||
sources.forEach(function(src) {
|
sources.forEach(function(src) {
|
||||||
var srcDir = tryResolveAppPath(rootDir, src);
|
var srcDir = tryResolveAppPath(rootDir, src, { strict: false });
|
||||||
if (!srcDir) {
|
if (!srcDir) {
|
||||||
debug('Skipping unknown module source dir %j', src);
|
debug('Skipping unknown module source dir %j', src);
|
||||||
return;
|
return;
|
||||||
|
@ -314,13 +314,14 @@ function tryResolveAppPath(rootDir, relativePath, resolveOptions) {
|
||||||
var fullPath;
|
var fullPath;
|
||||||
var start = relativePath.substring(0, 2);
|
var start = relativePath.substring(0, 2);
|
||||||
|
|
||||||
/* In order to retain backward compatibility, while resolving
|
/* In order to retain backward compatibility, we need to support
|
||||||
* component path, `resolveOptions` parameter is added where
|
* two ways how to treat values that are not relative nor absolute
|
||||||
* `resolveOptions.strict` = true,
|
* path (e.g. `relativePath = 'foobar'`)
|
||||||
* means retain backward compatibility when resolving the path and
|
* - `resolveOptions.strict = true` searches in `node_modules` only
|
||||||
* `resolveOptions.strict` = false,
|
* - `resolveOptions.strict = false` attempts to resolve the value
|
||||||
* does not enforce any such restriction when resolving the path */
|
* as a relative path first before searching `node_modules`
|
||||||
resolveOptions = resolveOptions || { strict: false };
|
*/
|
||||||
|
resolveOptions = resolveOptions || { strict: true };
|
||||||
|
|
||||||
var isModuleRelative = false;
|
var isModuleRelative = false;
|
||||||
if (relativePath[0] === '/') {
|
if (relativePath[0] === '/') {
|
||||||
|
@ -535,8 +536,9 @@ function buildComponentInstructions(rootDir, componentConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveRelativePaths(relativePaths, appRootDir) {
|
function resolveRelativePaths(relativePaths, appRootDir) {
|
||||||
|
var resolveOpts = { strict: false };
|
||||||
relativePaths.forEach(function(relativePath, k) {
|
relativePaths.forEach(function(relativePath, k) {
|
||||||
var resolvedPath = tryResolveAppPath(appRootDir, relativePath);
|
var resolvedPath = tryResolveAppPath(appRootDir, relativePath, resolveOpts);
|
||||||
if (resolvedPath !== undefined) {
|
if (resolvedPath !== undefined) {
|
||||||
relativePaths[k] = resolvedPath;
|
relativePaths[k] = resolvedPath;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue