Add support for embedded JS dependencies (embed Lime dependencies by default)

This commit is contained in:
Joshua Granick
2019-02-12 13:30:07 -08:00
parent 3e9f875eaf
commit cac82509da
5 changed files with 39 additions and 12 deletions

View File

@@ -83,6 +83,19 @@ class HTML5Platform extends PlatformTarget {
var context = project.templateContext;
context.SOURCE_FILE = File.getContent (outputFile);
context.embeddedLibraries = [];
for (dependency in project.dependencies) {
if (dependency.embed && StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
var script = File.getContent (dependency.path);
context.embeddedLibraries.push (script);
}
}
System.copyFileTemplate (project.templatePaths, "html5/output.js", outputFile, context);
}
@@ -341,16 +354,20 @@ class HTML5Platform extends PlatformTarget {
for (dependency in project.dependencies) {
if (StringTools.endsWith (dependency.name, ".js")) {
if (!dependency.embed) {
context.linkedLibraries.push (dependency.name);
if (StringTools.endsWith (dependency.name, ".js")) {
} else if (StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
context.linkedLibraries.push (dependency.name);
var name = Path.withoutDirectory (dependency.path);
} else if (StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
context.linkedLibraries.push ("./" + dependencyPath + "/" + name);
System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
var name = Path.withoutDirectory (dependency.path);
context.linkedLibraries.push ("./" + dependencyPath + "/" + name);
System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
}
}