{"id":26467384,"url":"https://github.com/urunium/urunium.stitch","last_synced_at":"2026-04-29T23:04:57.534Z","repository":{"id":146285103,"uuid":"96005692","full_name":"urunium/Urunium.Stitch","owner":"urunium","description":"Stitch together: js modules, css, images etc. in commonjs. Inspired by https://github.com/davidpadbury/StitchIt","archived":false,"fork":false,"pushed_at":"2017-08-15T06:54:38.000Z","size":1249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T18:07:05.467Z","etag":null,"topics":["bundle","commonjs","css","dotnet","js","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urunium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-02T06:07:55.000Z","updated_at":"2017-08-15T06:33:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"210dbef0-5b6e-4c7d-a7c9-e6ae17fbcaa9","html_url":"https://github.com/urunium/Urunium.Stitch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/urunium/Urunium.Stitch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urunium%2FUrunium.Stitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urunium%2FUrunium.Stitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urunium%2FUrunium.Stitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urunium%2FUrunium.Stitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urunium","download_url":"https://codeload.github.com/urunium/Urunium.Stitch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urunium%2FUrunium.Stitch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32447312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","commonjs","css","dotnet","js","webpack"],"created_at":"2025-03-19T14:06:53.515Z","updated_at":"2026-04-29T23:04:57.487Z","avatar_url":"https://github.com/urunium.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Urunium.Stitch\nStitch together: js modules, css, images etc. in commonjs. Inspired by https://github.com/davidpadbury/StitchIt\n\n# Goal\nGoal of this project is to provide [webpack](https://webpack.github.io/) like capability, to bundle various resources into single commonjs resource.\n\n## Getting started\n\nIn near future (nuget package is not available yet!):\n```\nInstall-Package Urunium-Stitch\n```\nOr,\n```\nInstall-Package Urunium-Stitch.Msbuild\n```\n\nMost likely all you'd need `Urunium-Stitch.Msbuild` package which integrates with the msbuild process and can be configured using [Json based](#usingjsonconfig) config. For more flexibility or extending capabalities use `Urunium-Stitch` package. This provides code based approach which needs to be written into appropriate place, as per project's need and architecture.\n\n## Brief look at Usage:\n\n```c#\n        [Test]\n        public void BuildTest()\n        {\n            IFileSystem fileSystem = new MockFileSystem(new Dictionary\u003cstring, MockFileData\u003e\n            {\n                { @\"c:\\App\\App.js\", new MockFileData(\"exports.default = ()=\u003e'Hello';\") },\n                { @\"c:\\App\\font.ttf\", new MockFileData(\"ttffilehere\") }\n            });\n            Stitcher.Stitch\n                .From((source) =\u003e\n                {\n                    source.RootPath = @\"c:\\App\";\n                    source.EntryPoints = new[] { \"./App\" };\n                    source.CopyFiles = new[] { \"./font.ttf\" };\n                }).Into((destination) =\u003e\n                {\n                    destination.Directory = @\"c:\\Bundle\";\n                    destination.BundleFileName = \"app.bundle.js\";\n                })\n                .WithFileSystem(fileSystem)\n                .AddTransformer\u003cBabelModuleTransformer\u003e()\n                .AddTransformer\u003cLessModuleTransformer\u003e()\n                .AddTransformer\u003cSassModuleTransformer\u003e()\n                .AddTransformer\u003cBase64ModuleTransformer\u003e()\n                .Sew();\n\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\app.bundle.js\"));\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\font.ttf\"));\n        }\n```\nOutermost API is the `Stitcher` class that provides fluent-api to configure and run the urunium-stitch process. Following are the parts configured in above example:\n\n* From : In above example we are configuring the `RootPath`, `EntryPoints` and `CopyFiles` properties of `SourceConfig`. \n  - RootPath as name suggests is the location from where files search need to be based on.\n  - EntryPoints configure the items which needs to be bundled. Bundling happens recursively for each entry-point item. But all the modules will remain in single file, irrespective of number of entry points.\n  - CopyFiles denote the files that needs to be copied to the output. Generally these are the resources that cannot be bundled into CommonJs modules but are part of final product.\n  \n* Into : Configures the destination. It has two properties: `Directory`, which is the location where bundled file must be created, and `BundleFileName`\n\n* AddTransformer : Adds an `IModuleTransformer` into the pipeline. Following transformers are available:\n  - BabelModuleTransformer\n  - Base64ModuleTransformer\n  - DefaultModuleTransformer\n  - LessModuleTransformer\n  - SassModuleTransformer\n  - TypescriptModuleTransformer\n  \nThe sequence in which transformers are added may have some impact on the output. The default sequence is as follows:\n  - BabelModuleTransformer\n  - TypescriptModuleTransformer\n  - LessModuleTransformer\n  - SassModuleTransformer\n  - Base64ModuleTransformer\n  \nInstead of adding these transformers we can simple call `UsingDefaultTransformers`\n\n* Sew : Finally `Sew` method actually starts the bundling.\n\n## Global modules\n\n```c#\n[Test]\n        public void GlobalModulesTest()\n        {\n            var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer();\n            Stitcher.Stitch\n                .UsingContainer(container)\n                .From((source) =\u003e\n                {\n                    source.RootPath = @\"c:\\App\";\n                    source.EntryPoints = new[] { \"./App\" };\n                    source.CopyFiles = new[] { \"./font.ttf\" };\n                    source.Globals = new GlobalsConfig\n                    {\n                        [\"react\"] = \"React\",\n                        [\"react-dom\"] = \"ReactDOM\"\n                    };\n                }).Into((destination) =\u003e\n                {\n                    destination.Directory = @\"c:\\Bundle\";\n                    destination.BundleFileName = \"app.bundle.js\";\n                })\n                .WithFileSystem\u003cMyMockFileSystem\u003e()\n                .UsingDefaultTransformers()\n                .Sew();\n\n            var fileSystem = container.Resolve\u003cIFileSystem\u003e();\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\app.bundle.js\"));\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\font.ttf\"));\n        }\n```\nWhile configuring the source, we can specify global modules. Global modules will not be bundled into the final bundle, but will be assumed to be available in global context.\n\n## UsingConfig\n\n```c#\n        [Test]\n        public void BuildUsingConfigTest()\n        {\n            var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer();\n            Stitcher.Stitch\n                .UsingContainer(container)\n                .UsingConfig(new StitchConfig\n                {\n                    From = new SourceConfig\n                    {\n                        RootPath = @\"c:\\App\",\n                        EntryPoints = new[] { \"./App\" },\n                        CopyFiles = new[] { \"./font.ttf\" }\n                    },\n                    Into = new DestinationConfig\n                    {\n                        Directory = @\"c:\\Bundle\",\n                        BundleFileName = \"app.bundle.js\"\n                    },\n                    Extendibility = new PackagerExtendibilityConfig\n                    {\n                        DI = new Dictionary\u003cstring, string\u003e\n                        {\n                            { \"System.IO.Abstractions.IFileSystem, System.IO.Abstractions\", \"Urunium.Stitch.Tests.StitcherTests+MyMockFileSystem, Urunium.Stitch.Tests\" },\n                            { \"Urunium.Stitch.PackageBundler, Urunium.Stitch\", \"Urunium.Stitch.Tests.StitcherTests+MyPackageBundler, Urunium.Stitch.Tests\" },\n                            { \"Urunium.Stitch.Tests.StitcherTests+ICommentWriter, Urunium.Stitch.Tests\", \"Urunium.Stitch.Tests.StitcherTests+CommentWriter, Urunium.Stitch.Tests\" }\n                        },\n                        Transformers = new List\u003cstring\u003e\n                        {\n                            // default transformers\n                            \"Urunium.Stitch.ModuleTransformers.BabelModuleTransformer\",\n                            \"Urunium.Stitch.ModuleTransformers.LessModuleTransformer\",\n                            \"Urunium.Stitch.ModuleTransformers.SassModuleTransformer\",\n                            \"Urunium.Stitch.ModuleTransformers.Base64ModuleTransformer\",\n                            // extra transformers\n                            \"Urunium.Stitch.Tests.StitcherTests+TestModuleTransformer, Urunium.Stitch.Tests\",\n                        }\n                    }\n                }).Sew();\n\n            var fileSystem = container.Resolve\u003cIFileSystem\u003e();\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\app.bundle.js\"));\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\font.ttf\"));\n            Assert.True(fileSystem.File.ReadAllText(@\"c:\\Bundle\\app.bundle.js\").Contains(\"'font.ttf' : function(require, exports, module) \"));\n            Assert.True(fileSystem.File.ReadAllText(@\"c:\\Bundle\\app.bundle.js\").Contains(\"// Comment added from MyPackageBundler\"));\n        }\n```\nAs shown above instead of configuring each parts individually, we can also configure in one scoop using `StitchConfig` and `UsingConfig` method.\n\n## UsingJsonConfig\n\nJson config is also supported, as follows:\n\n```c#\n        [Test]\n        public void BuildUsingJsonConfigTest()\n        {\n            var container = new Urunium.Stitch.TinyIoC.TinyIoCContainer();\n            var config = @\"{\n                'From': {\n                    'RootPath': 'c:\\\\App',\n                    'EntryPoints': ['./App'],\n                    'CopyFiles': ['./font.ttf']\n                },\n                'Into': {\n                    'Directory': 'c:\\\\Bundle',\n                    'BundleFileName': 'app.bundle.js'\n                },\n                'Extendibility': {\n                    'DI': {\n                      'System.IO.Abstractions.IFileSystem, System.IO.Abstractions': 'Urunium.Stitch.Tests.StitcherTests+MyMockFileSystem, Urunium.Stitch.Tests',\n                      'Urunium.Stitch.PackageBundler, Urunium.Stitch': 'Urunium.Stitch.Tests.StitcherTests+MyPackageBundler, Urunium.Stitch.Tests',\n                      'Urunium.Stitch.Tests.StitcherTests+ICommentWriter, Urunium.Stitch.Tests': 'Urunium.Stitch.Tests.StitcherTests+CommentWriter, Urunium.Stitch.Tests'\n                    },\n                    'Transformers': [\n                            'Urunium.Stitch.ModuleTransformers.BabelModuleTransformer',\n                            'Urunium.Stitch.ModuleTransformers.LessModuleTransformer',\n                            'Urunium.Stitch.ModuleTransformers.SassModuleTransformer',\n                            'Urunium.Stitch.ModuleTransformers.Base64ModuleTransformer',\n                            'Urunium.Stitch.Tests.StitcherTests+TestModuleTransformer, Urunium.Stitch.Tests'\n                    ]\n                }\n            }\";\n            Stitcher.Stitch\n                .UsingContainer(container)\n                .UsingJsonConfig(config).Sew();\n\n            var fileSystem = container.Resolve\u003cIFileSystem\u003e();\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\app.bundle.js\"));\n            Assert.True(fileSystem.File.Exists(@\"c:\\Bundle\\font.ttf\"));\n            Assert.True(fileSystem.File.ReadAllText(@\"c:\\Bundle\\app.bundle.js\").Contains(\"'font.ttf' : function(require, exports, module) \"));\n            Assert.True(fileSystem.File.ReadAllText(@\"c:\\Bundle\\app.bundle.js\").Contains(\"// Comment added from MyPackageBundler\"));\n        }\n```\n\n# Interested in contributing?\nFork the project from github and send PR. Only tested using Visual studio 2017, but 2015 may work as well.\nExecute `build.bat` or `build.ps1`. Final nuget packages are created at `artifact` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furunium%2Furunium.stitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furunium%2Furunium.stitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furunium%2Furunium.stitch/lists"}