{"id":15379596,"url":"https://github.com/blond/es6-module-transpiler-dist-formatter","last_synced_at":"2025-04-09T03:16:21.263Z","repository":{"id":23677639,"uuid":"27049060","full_name":"blond/es6-module-transpiler-dist-formatter","owner":"blond","description":"ES6 Module Transpiler Extension to Output Dist Bundle Format","archived":false,"fork":false,"pushed_at":"2014-11-24T12:30:41.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T21:31:11.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/blond.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}},"created_at":"2014-11-23T21:46:51.000Z","updated_at":"2014-11-24T12:30:33.000Z","dependencies_parsed_at":"2022-08-18T21:42:34.193Z","dependency_job_id":null,"html_url":"https://github.com/blond/es6-module-transpiler-dist-formatter","commit_stats":null,"previous_names":["andrewblond/es6-module-transpiler-dist-formatter"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blond%2Fes6-module-transpiler-dist-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blond%2Fes6-module-transpiler-dist-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blond%2Fes6-module-transpiler-dist-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blond%2Fes6-module-transpiler-dist-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blond","download_url":"https://codeload.github.com/blond/es6-module-transpiler-dist-formatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247968377,"owners_count":21025823,"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-10-01T14:19:26.443Z","updated_at":"2025-04-09T03:16:21.243Z","avatar_url":"https://github.com/blond.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"es6-module-transpiler-dist-formatter\n====================================\n\n[![NPM version](http://img.shields.io/npm/v/es6-module-transpiler-dist-formatter.svg?style=flat)](http://www.npmjs.org/package/es6-module-transpiler-dist-formatter) [![Build Status](http://img.shields.io/travis/andrewblond/es6-module-transpiler-dist-formatter/master.svg?style=flat)](https://travis-ci.org/andrewblond/es6-module-transpiler-dist-formatter) [![Coverage Status](https://img.shields.io/coveralls/andrewblond/es6-module-transpiler-dist-formatter.svg?branch=master\u0026style=flat)](https://coveralls.io/r/andrewblond/es6-module-transpiler-dist-formatter) [![dependency Status](http://img.shields.io/david/andrewblond/es6-module-transpiler-dist-formatter.svg?style=flat)](https://david-dm.org/andrewblond/es6-module-transpiler-dist-formatter)\n\nES6 Module Transpiler Extension to Output Dist Bundle Format.\n\n## Usage\n\n### Build tools\n\nSince this formatters is an plugin for [es6-module-transpiler], you can use it with any existing build tool that supports [es6-module-transpiler] as the underlaying engine to transpile the ES6 modules.\n\nYou just need to make sure that `es6-module-transpiler-dist-formatter` is accessible for those tools, and pass the proper `formatter` option thru the [es6-module-transpiler][] configuration.\n\n### Executable\n\nIf you plan to use the `compile-module` CLI, the formatters can be used directly from the command line:\n\n```\n$ npm install es6-module-transpiler\n$ npm install es6-module-transpiler-dist-formatter\n$ ./node_modules/.bin/compile-modules convert -f es6-module-transpiler-dist-formatter path/to/**/*.js -o build/\n```\n\n__The `-f` option allow you to specify the path to the specific formatter, which is this case is an installed module called `es6-module-transpiler-dist-formatter`.__\n\n### Library\n\nYou can also use the formatter with the transpiler as a library:\n\n```javascript\nvar transpiler = require('es6-module-transpiler');\nvar DistFormatter = require('es6-module-transpiler-dist-formatter');\nvar Container = transpiler.Container;\nvar FileResolver = transpiler.FileResolver;\n\nvar container = new Container({\n  resolvers: [new FileResolver(['lib/'])],\n  formatter: new DistFormatter({ name: 'module-name' })\n});\n\ncontainer.getModule('index');\ncontainer.write('out/mylib.js');\n```\n\n## Supported ES6 Module Syntax\n\nAgain, this syntax is in flux and is closely tracking the module work being done by TC39. This package relies on the syntax supported by [es6-module-transpiler], which relies on [esprima], you can have more information about the supported syntax here: https://github.com/square/es6-module-transpiler#supported-es6-module-syntax\n\n[esprima]: https://github.com/ariya/esprima\n\n## Compiled Output\n\nFirst of all, the output format for `define()` might looks alien even for many developers, but considering that [es6-module-transpiler] relies on [Recast] to mutate the original ES6 code, it can output the corresponding [sourceMap], you should be able to debug the module code without having to understand the actual output format.\n\n[sourceMap]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/\n[Recast]: https://github.com/benjamn/recast\n\n### Default export\n\nFor a module without imports, and a single default exports:\n\n```js\nexport default function (a, b) {\n    return a + b;\n}\n```\n\nwill produce something like this:\n\n```js\n(function() {\n    \"use strict\";\n    var index$$default = function (a, b) {\n        return a + b;\n    };\n    var defineAsGlobal = true;\n\n    // Node.js\n    if (typeof exports === 'object') {\n        module.exports = index$$default;\n        defineAsGlobal = false;\n    }\n\n    // YModules\n    if (typeof modules === 'object') {\n        modules.define('module-name', function (provide) {\n            provide(index$$default);\n        });\n        defineAsGlobal = false;\n    }\n\n    defineAsGlobal \u0026\u0026 (global.moduleName = index$$default);\n}).call(this);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblond%2Fes6-module-transpiler-dist-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblond%2Fes6-module-transpiler-dist-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblond%2Fes6-module-transpiler-dist-formatter/lists"}