Return {path,id,stat} from Resolver.prototype.resolve.

The id property is an absolute module identifer, suitable for passing to a
native Node require function.
This commit is contained in:
Ben Newman
2016-06-01 13:36:18 -04:00
parent 949e418c12
commit dc9941bfa6
2 changed files with 10 additions and 1 deletions

View File

@@ -349,7 +349,7 @@ class InputFile extends buildPluginModule.InputFile {
const resolver = batch.getResolver();
return this._resolveCacheStore(
id, parentPath, resolver.resolve(id, parentPath).path);
id, parentPath, resolver.resolve(id, parentPath).id);
}
require(id, parentPath) {

View File

@@ -12,6 +12,8 @@ import {
pathNormalize,
pathDirname,
statOrNull as realStatOrNull,
convertToOSPath,
convertToPosixPath,
} from "../fs/files.js";
const nativeModulesMap = Object.create(null);
@@ -108,6 +110,13 @@ export default class Resolver {
resolved = this._joinAndStat(dirPath, "index.js");
}
if (resolved) {
resolved.id = convertToPosixPath(
convertToOSPath(resolved.path),
true
);
}
return resolved;
}