{"id":18653235,"url":"https://github.com/babel-utils/babel-explode-module","last_synced_at":"2025-10-24T05:50:44.880Z","repository":{"id":46933951,"uuid":"91463712","full_name":"babel-utils/babel-explode-module","owner":"babel-utils","description":"Serialize a module into an easier format to work with","archived":false,"fork":false,"pushed_at":"2023-01-12T10:12:46.000Z","size":135,"stargazers_count":34,"open_issues_count":11,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T04:32:25.977Z","etag":null,"topics":["babel","babel-util","modules"],"latest_commit_sha":null,"homepage":null,"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/babel-utils.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":"2017-05-16T13:48:29.000Z","updated_at":"2025-02-09T06:31:44.000Z","dependencies_parsed_at":"2023-02-09T11:16:14.277Z","dependency_job_id":null,"html_url":"https://github.com/babel-utils/babel-explode-module","commit_stats":null,"previous_names":["thejameskyle/babel-explode-module"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel-utils%2Fbabel-explode-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel-utils%2Fbabel-explode-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel-utils%2Fbabel-explode-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel-utils%2Fbabel-explode-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babel-utils","download_url":"https://codeload.github.com/babel-utils/babel-explode-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441282,"owners_count":21103957,"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":["babel","babel-util","modules"],"created_at":"2024-11-07T07:10:40.346Z","updated_at":"2025-10-24T05:50:44.830Z","avatar_url":"https://github.com/babel-utils.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-explode-module\n\n\u003e Serialize a module into an easier format to work with\n\n```js\nimport {foo, bar} from \"mod\";\n\nexport default function() {\n  // ...\n}\n\nconst baz = 42,\n      bat = class Bat {};\n\nexport {\n  baz,\n  bat\n};\n```\n\nCreating this AST:\n\n```yml\nProgram\n  body:\n    - ImportDeclaration\n        specifiers:\n          - ImportSpecifier\n          - ImportSpecifier\n    - ExportDefaultDeclaration\n        declaration: FunctionDeclaration\n    - VariableDeclaration\n        declarations:\n          - VariableDeclarator\n          - VariableDeclarator\n    - ExportNamedDeclaration\n        specifiers:\n          - ExportSpecifier\n          - ExportSpecifier\n```\n\nWill be exploded to this:\n\n```js\n{\n  imports: [\n    { kind: \"value\", local: \"foo\", external: \"foo\", source: \"mod\", loc: {...} },\n    { kind: \"value\", local: \"bar\", external: \"bar\", source: \"mod\", loc: {...} },\n  ],\n  exports: [\n    { local: \"_default\", external: \"default\", loc: {...} },\n    { local: \"baz\", external: \"baz\", loc: {...} },\n    { local: \"bat\", external: \"bat\", loc: {...} },\n  },\n  statements: [\n    { type: \"FunctionDeclaration\" },\n    { type: \"VariableDeclaration\", declarations: VariableDeclarator },\n    { type: \"VariableDeclaration\", declarations: VariableDeclarator },\n  ],\n}\n```\n\n#### Serializes imports/exports to an easy to work with format\n\n```js\n// input\nimport a, {b} from \"mod\";\nimport * as c from \"mod\";\nexport default function d() {}\nexport {e, f as g};\nexport {default as h} from \"mod\";\nexport * from \"mod\";\n```\n\n```js\n// output\n{\n  imports: [\n    { kind: \"value\", local: \"a\", external: \"a\", source: \"mod\" },\n    { kind: \"value\", local: \"b\", external: \"b\", source: \"mod\" },\n    { kind: \"value\", local: \"c\", source: \"d\" },\n  ],\n  exports: [\n    { local: \"d\", external: \"d\" },\n    { local: \"e\", external: \"e\" },\n    { local: \"f\", external: \"g\" },\n    { local: \"default\", external: \"g\", source: \"mod\" },\n    { source: \"mod\" },\n  ]\n}\n```\n\n#### Simplifies declarations to create 1 binding per statement (i.e. variables)\n\n```js\n// input\nfunction a() {}\nvar b,\n    c;\n```\n\n```js\n// output (printed)\nfunction a() {}\nvar b;\nvar c;\n```\n\n#### Splits export values away from their exports\n\n```js\n// input\nexport function a() {}\nexport default function() {}\n```\n\n```js\n// output (printed)\nfunction a() {}\nvar _default = function() {};\nexport {a};\nexport default _default;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel-utils%2Fbabel-explode-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabel-utils%2Fbabel-explode-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel-utils%2Fbabel-explode-module/lists"}