public Package Package(SourceConfig packagerConfig) { string rootPath = packagerConfig.RootPath; Package package = new Package(rootPath); string currentPath = null; if (packagerConfig.Globals?.Count > 0) { foreach (string moduleId in packagerConfig.Globals.Keys) { package.Modules.Add(new Module { ModuleId = moduleId, TransformedContent = $"Object.defineProperty(exports, '__esModule', {{value: true}}); exports.default = {packagerConfig.Globals[moduleId]}" }); } } if (packagerConfig.EntryPoints?.Length > 0) { foreach (string entryPoint in packagerConfig.EntryPoints) { ProcessModule(rootPath, package, entryPoint, currentPath); } } if (packagerConfig.CopyFiles?.Length > 0) { foreach (string copyFile in packagerConfig.CopyFiles) { package.Files.Add(copyFile); } } return(package); }
private Stitcher UsingConfig(StitchConfig config) { if (config.Into == null) { throw new Exception("Compiler config is required"); } if (string.IsNullOrWhiteSpace(config.Into.Directory)) { throw new Exception("DestinationDirectory is required"); } if (config.From == null) { throw new Exception("Packager config is required"); } if (string.IsNullOrWhiteSpace(config.From.RootPath)) { throw new Exception("RootPath is required"); } if (((config.From.EntryPoints?.Length ?? 0) == 0) && (config.From.CopyFiles?.Length ?? 0) == 0) { throw new Exception("EntryPoints or CopyFiles is required"); } _sourceConfig = config.From; _destinationConfig = config.Into; if (config.Extendibility != null) { if (config.Extendibility.DI != null) { foreach (var diEntry in config.Extendibility.DI) { Type registerType = Type.GetType(diEntry.Key, true); Type implementationType = Type.GetType(diEntry.Value, true); _container.Register(registerType, implementationType); } } if (config.Extendibility.Transformers?.Count > 0) { _useDefaultTransformers = false; _transformerTypes.Clear(); foreach (var moduleTransformerTypeName in config.Extendibility.Transformers) { Type moduleTransformerType = Type.GetType(moduleTransformerTypeName, true); _transformerTypes.Add(moduleTransformerType); } } } return(this); }
public DestinationConfigurator From(Action <SourceConfig> configuratorCallback) { if (_stitcher._container == null) { _stitcher._container = new Urunium.Stitch.TinyIoC.TinyIoCContainer(); } var config = new SourceConfig(); configuratorCallback(config); _stitcher.UsingSourceConfig(config); return(new DestinationConfigurator(_stitcher)); }
private Stitcher UsingSourceConfig(SourceConfig packagerConfig) { _sourceConfig = packagerConfig; return(this); }