{"id":13803645,"url":"https://github.com/DavyJonesLocker/es6_module_transpiler-rails","last_synced_at":"2025-05-13T16:32:13.008Z","repository":{"id":11438824,"uuid":"13895032","full_name":"DavyJonesLocker/es6_module_transpiler-rails","owner":"DavyJonesLocker","description":"Transpile ES6 Modules in the Rails Asset Pipeline","archived":false,"fork":false,"pushed_at":"2014-12-09T17:52:48.000Z","size":373,"stargazers_count":87,"open_issues_count":0,"forks_count":10,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-03T15:46:37.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://dockyard.com","language":"JavaScript","has_issues":false,"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/DavyJonesLocker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-27T03:14:08.000Z","updated_at":"2021-08-24T12:40:33.000Z","dependencies_parsed_at":"2022-09-22T22:51:03.772Z","dependency_job_id":null,"html_url":"https://github.com/DavyJonesLocker/es6_module_transpiler-rails","commit_stats":null,"previous_names":["dockyard/es6_module_transpiler-rails"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavyJonesLocker%2Fes6_module_transpiler-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavyJonesLocker%2Fes6_module_transpiler-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavyJonesLocker%2Fes6_module_transpiler-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavyJonesLocker%2Fes6_module_transpiler-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavyJonesLocker","download_url":"https://codeload.github.com/DavyJonesLocker/es6_module_transpiler-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252714795,"owners_count":21792750,"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":[],"created_at":"2024-08-04T01:00:36.527Z","updated_at":"2025-05-13T16:32:07.956Z","avatar_url":"https://github.com/DavyJonesLocker.png","language":"JavaScript","funding_links":[],"categories":["Transpilers"],"sub_categories":[],"readme":"# ES6ModuleTranspiler-Rails #\n\n[![Build Status](https://secure.travis-ci.org/dockyard/es6_module_transpiler-rails.png?branch=master)](http://travis-ci.org/dockyard/es6_module_transpiler-rails)\n[![Dependency Status](https://gemnasium.com/dockyard/es6_module_transpiler-rails.png?travis)](https://gemnasium.com/dockyard/es6_module_transpiler-rails)\n[![Code Climate](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails.png)](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails)\n\nTranspile ES6 Modules in the Rails Asset Pipeline\n\nUses [Square's ES6 Module Transpiler](https://github.com/square/es6-module-transpiler)\n\n## Installation ##\n\n**Node.js must be installed for the transpiling to happen**\n\n```ruby\ngem 'es6_module_transpiler-rails'\n```\n\n## Usage ##\n\nYour modules will transpile and are named based upon their directory\nnesting + filename, as long as the file has the `.es6` extension.\nFor example, `app/assets/javascripts/controllers/fooController.js.es6`\n\n```js\nvar fooController = function() {\n  console.log('fooController is in the house!');\n};\n\nexport default fooController;\n```\n\nwill compile to `/assets/controllers/fooController.js`\n\n```js\ndefine(\"controllers/fooController\",\n  [\"exports\"],\n  function(__exports__) {\n    \"use strict\";\n    var fooController = function() {\n      console.log('fooController is in the house!');\n    };\n\n    __exports__[\"default\"] = fooController;\n  });\n```\n\n### Compiling ###\n\nBy default your module will compile to an AMD. You can also compile it to globals or CommonJS by making the following switch:\n\n```ruby\nES6ModuleTranspiler.compile_to = :globals\n# or\nES6ModuleTranspiler.compile_to = :cjs\n```\n\nYou may modify the `options` that are passed to the module compiler (i.e.\n[compatFix](https://github.com/square/es6-module-transpiler/blob/3e708b70dffeaf753307f9d5ecdf780fd6c7b74e/lib/amd_compiler.js#L68)) by \nmodifying the `compiler_options` hash:\n\n```ruby\nES6ModuleTranspiler.compiler_options[:compatFix] = true;\n```\n\nThe `compiler_options` hash is empty by default.\n\n### Loading Modules ###\n\nWhen compiling to AMD or CommonJS, you'll need to be able to load the compiled result.  In the below example, we're using a minimal AMD loader called [loader.js](https://github.com/stefanpenner/loader.js).  Without a loader, you'll get an error like:\n\n```\nUncaught ReferenceError: define is not defined\n```\n\nFor example, in **application.js**:\n```\n//= require loader\n//= require_tree ./modules\n//= require main\n\nrequire('main');\n```\nNow `main.js.es6` is our entry point - from this file we can use the es6 module syntax to load any es6 modules in the `./modules` directory.\n\n### Custom Module Prefix ###\n\nYou can match module names based upon a pattern to apply a prefix to the\nname. You can add multiple patterns (which can each have separate prefixes):\n\n```ruby\nES6ModuleTranspiler.add_prefix_pattern Regexp.new(File.join(Rails.root, 'app')), 'app'\nES6ModuleTranspiler.add_prefix_pattern Regexp.new(File.join(Rails.root, 'config')), 'config'\n```\n\nThis would match names that start with the pattern and prepend with\n`app/` or `config/`. For example, `/home/user/app/controllers/fooController` would now be named\n`app/controllers/fooController`, and `/home/user/config/router` would now be\nnamed `config/router`.\n\nNote the path is made up of the *root path* and the *logical path* for the asset. For example, if the\npath to your asset is\n`/home/user/app/assets/javascripts/controllers/fooController.js.es6` the root path is `/home/user/app/assets/javascripts/` and the logical\npath is `controllers/fooController`. It is entirely dependent upon what\nSprockets considers to be the mount point for the asset.\n\n## Authors ##\n\n[Brian Cardarella](http://twitter.com/bcardarella)\n\n[We are very thankful for the many contributors](https://github.com/dockyard/es6_module_transpiler-rails/graphs/contributors)\n\n## Versioning ##\n\nThis gem follows [Semantic Versioning](http://semver.org)\n\n## Want to help? ##\n\nPlease do! We are always looking to improve this gem.\n\n## Legal ##\n\n[DockYard](http://dockyard.com), LLC \u0026copy; 2013\n\n[@dockyard](http://twitter.com/dockyard)\n\n[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavyJonesLocker%2Fes6_module_transpiler-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDavyJonesLocker%2Fes6_module_transpiler-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavyJonesLocker%2Fes6_module_transpiler-rails/lists"}