public void Dispose() { _fusejs?.Dispose(); _fusejs = null; }
SourcePackage GetPackage(Source src, Project project, bool startup = false) { SourcePackage result; if (_cache.TryGetValue(project.Name, out result)) { if (result == null) { Log.Error(src, null, "Circular reference to " + project.Name.Quote()); return(new SourcePackage(project.Name)); } if (result.Source.FullPath != project.FullPath || startup) { Log.Error(src, null, "Multiple projects or packages with the name " + project.Name.Quote()); return(new SourcePackage(project.Name)); } result.Flags &= ~SourcePackageFlags.Startup; return(result); } result = project.CreateSourcePackage(startup); _cache[project.Name] = null; if (project.UnoCoreReference) { result.References.Add(GetPackage(new PackageReference(project.Source, "UnoCore"))); } foreach (var r in project.PackageReferences) { result.References.Add(GetPackage(r)); } foreach (var r in project.ProjectReferences) { result.References.Add(GetPackage(r.Source, LoadProject(r.Source, r.GetFullPath(project.RootDirectory)))); } // Transpile FuseJS files foreach (var f in project.FuseJSFiles) { // We don't need to spend time on this in UXNinja, tests, etc. if (!_enableFuseJS) { continue; } var name = f.NativePath; var nameWithoutExt = Path.ChangeExtension(name, null); var inputFile = Path.Combine(project.RootDirectory, name); var outputFile = Path.Combine(project.RootDirectory, ".uno", "fusejs", nameWithoutExt + ".js"); result.AdditionalFiles.Add(f); // Invalidate the project when a FuseJS file changes result.BundleFiles.Add(new FileItem(outputFile.ToRelativePath(project.RootDirectory, true).NativeToUnix(), f.Condition)); if (!File.Exists(inputFile)) { Log.Error(src, ErrorCode.E0000, "File not found: " + inputFile.ToRelativePath()); continue; } if (File.Exists(outputFile) && File.GetLastWriteTime(outputFile) >= File.GetLastWriteTime(inputFile)) { continue; } // Ensure FuseJS is initialized before starting a task if (_fusejs == null) { _fusejs = new FuseJS(this); } name = inputFile.ToRelativePath(); Log.Verbose("Transpiling " + name); string output; if (_fusejs.TryTranspile(name, File.ReadAllText(inputFile), out output)) { using (var file = Disk.CreateText(outputFile)) file.Write(output); } } result.FlattenTransitiveReferences(); _cache[project.Name] = result; return(result); }