{"id":13659237,"url":"https://github.com/amitayh/amd-compiler","last_synced_at":"2026-05-20T17:10:14.226Z","repository":{"id":16849144,"uuid":"19608990","full_name":"amitayh/amd-compiler","owner":"amitayh","description":"Compiles JS source written as AMD modules to a single file without the need for a loader (RequireJS / almond / etc.)","archived":false,"fork":false,"pushed_at":"2017-11-11T17:24:30.000Z","size":84,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-02T05:10:32.335Z","etag":null,"topics":["almond","amd-modules","dependency-graph","escodegen","esprima","javascript","requirejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amitayh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-09T11:32:01.000Z","updated_at":"2018-05-30T18:26:43.000Z","dependencies_parsed_at":"2022-09-06T17:00:23.906Z","dependency_job_id":null,"html_url":"https://github.com/amitayh/amd-compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitayh%2Famd-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitayh%2Famd-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitayh%2Famd-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitayh%2Famd-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amitayh","download_url":"https://codeload.github.com/amitayh/amd-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223952711,"owners_count":17230937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["almond","amd-modules","dependency-graph","escodegen","esprima","javascript","requirejs"],"created_at":"2024-08-02T05:01:06.611Z","updated_at":"2025-12-27T14:49:29.699Z","avatar_url":"https://github.com/amitayh.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# amd-compiler [![Build Status](https://travis-ci.org/amitayh/amd-compiler.svg?branch=master)](https://travis-ci.org/amitayh/amd-compiler) [![codecov](https://codecov.io/gh/amitayh/amd-compiler/branch/master/graph/badge.svg)](https://codecov.io/gh/amitayh/amd-compiler)\n\nCompiles JS source written as AMD modules to a single file without the need for a loader (RequireJS / almond / etc.)\n\n## Installation\n\n```\n$ git clone https://github.com/amitayh/amd-compiler.git\n$ cd amd-compiler\n$ npm install\n```\n\n## Usage\n\nInvoke the `bin/compile` script to compile source:\n\n```\n$ node bin/compile \u003cpath/to/main\u003e \u003e\u003e compiled.js\n```\n\n### Example\n\nSay the given modules are defined in the path `/foo/bar`:\n\n\n```js\n// modA.js\ndefine([\"modB\", \"modC\"], function(b, c) {\n  return b + c(\"A\");\n});\n```\n\n```js\n// modB.js\ndefine([\"modC\"], function(c) {\n  return c(\"B\");\n});\n```\n\n```js\n// modC.js\ndefine(function() {\n  return function(name) {\n    return \"Hello, \" + name + \"!\";\n  };\n});\n```\n\n```js\n// main.js\nrequire([\"modA\", \"modB\"], function(a, b) {\n  console.log(a, b);\n});\n```\n\nThen invoking the comiler script like so:\n\n```\n$ node bin/compile /foo/bar/main\n```\n\nWill generate the following output:\n\n```js\n(function () {\n  // Source: /foo/bar/modC.js\n  var modC = function () {\n      return function (name) {\n        return \"Hello, \" + name + \"!\";\n      };\n    }();\n  // Source: /foo/bar/modB.js\n  var modB = function (c) {\n      return c(\"B\");\n    }(modC);\n  // Source: /foo/bar/modA.js\n  var modA = function (b, c) {\n      return b + c(\"A\");\n    }(modB, modC);\n  // Source: /foo/bar/main.js\n  (function (a, b) {\n    console.log(a, b);\n  }(modA, modB));\n}());\n```\n\n## Running tests\n\nInstall [mocha](http://visionmedia.github.io/mocha/):\n\n```\n$ npm install -g mocha\n```\n\nRun tests:\n\n```\n$ mocha specs/\n```\n\n## Internals\n\n1. Dependency graph is resolved, using [esprima](http://esprima.org/) for parsing the JS sources:\u003cbr\u003e\n   ![Dependency graph](doc/deps.png)\n2. Graph is topologically sorted, making sure that the dependencies are in the correct order:\u003cbr\u003e\n   ![Dependencies in topological order](doc/sorted.png)\n3. Using [escodegen](https://github.com/Constellation/escodegen), the compiler constructs a single source from all needed dependencies","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitayh%2Famd-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famitayh%2Famd-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitayh%2Famd-compiler/lists"}