TS: Move definition of mainStr

This commit is contained in:
Asger Feldthaus
2020-01-24 10:02:06 +00:00
parent 9ed77585a7
commit 1f647223e0

View File

@@ -801,15 +801,6 @@ public class AutoBuild {
return resolved;
}
// Get the "main" property from the package.json
// This usually refers to the compiled output, such as `./out/foo.js` but may hint as to
// the name of main file ("foo" in this case).
String mainStr = null;
JsonElement mainElm = packageJson.get("main");
if (mainElm instanceof JsonPrimitive && ((JsonPrimitive)mainElm).isString()) {
mainStr = mainElm.getAsString();
}
// Look for source files `./src` if it exists
Path sourceDir = packageDir.resolve("src");
if (Files.isDirectory(sourceDir)) {
@@ -819,6 +810,11 @@ public class AutoBuild {
return resolved;
}
// Get the "main" property from the package.json
// This usually refers to the compiled output, such as `./out/foo.js` but may hint as to
// the name of main file ("foo" in this case).
String mainStr = getChildAsString(packageJson, "main");
// If "main" was defined, try to map it to a file in `src`.
// For example `out/dist/foo.bundle.js` might be mapped back to `src/foo.ts`.
if (mainStr != null) {