From dc9941bfa6e2b590ef95f1bc5ebe51537e0c273e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 1 Jun 2016 13:36:18 -0400 Subject: [PATCH] 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. --- tools/isobuild/compiler-plugin.js | 2 +- tools/isobuild/resolver.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index dee5eb6a26..c32b3768e9 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -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) { diff --git a/tools/isobuild/resolver.js b/tools/isobuild/resolver.js index c1a46af2c9..21e9684fd8 100644 --- a/tools/isobuild/resolver.js +++ b/tools/isobuild/resolver.js @@ -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; }