{"id":22423299,"url":"https://github.com/prantlf/requirejs-esm-converter","last_synced_at":"2025-08-01T07:32:09.352Z","repository":{"id":57688850,"uuid":"489962465","full_name":"prantlf/requirejs-esm-converter","owner":"prantlf","description":"Converts source RequireJS modules from AMD to ESM format.","archived":false,"fork":false,"pushed_at":"2024-07-28T07:37:50.000Z","size":141,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-28T10:41:35.780Z","etag":null,"topics":["amd","convert","converter","es6","esm","requirejs"],"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/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-05-08T14:12:52.000Z","updated_at":"2024-07-28T07:37:53.000Z","dependencies_parsed_at":"2024-10-19T03:29:19.637Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/requirejs-esm-converter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Frequirejs-esm-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Frequirejs-esm-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Frequirejs-esm-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Frequirejs-esm-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/requirejs-esm-converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228348371,"owners_count":17905899,"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":["amd","convert","converter","es6","esm","requirejs"],"created_at":"2024-12-05T18:09:56.031Z","updated_at":"2025-08-01T07:32:09.344Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RequireJS ESM Converter\n\nConverts source [RequireJS] modules from [AMD] to [ESM] format.\n\nIf you enabled usage of [ESM] modules in your [RequireJS] project (using [requirejs-babel7], [requirejs-esm] or [requirejs-esm-preprocessor], for example), you might want to convert all your code base to the [ESM] format to follow the same consistent coding standard and use the same set of tools to build, test and analyse your sources.\n\n## Synopsis\n\nConvert all JavaScript sources in the project's subdirectories:\n\n    ❯ requirejs-to-esm '*/**/*.js' '!node_modules'\n\n    lib/impl/analyse.js: converted\n    lib/impl/convert.js: converted\n    lib/index.js: multiple statements\n    test/index.js: converted\n\nThe file `lib/index.js` wasn't an AMD module. (It didn't contain a single `define` or `require` statement.) It will need an inspection and manual conversion.\n\n## Installation\n\nThis module can be installed globally using [NPM], [PNPM] or [Yarn]. Make sure, that you use [Node.js] version 14 or newer.\n\n```sh\nnpm i -g requirejs-esm-converter\npnpm i -g requirejs-esm-converter\nyarn add --global requirejs-esm-converter\n```\n\n## Command Line\n\n    requirejs-to-esm [option...] [\u003cpattern\u003e ...]\n\nYou can use BASH patterns for including and excluding files (only files).\nPatterns are case-sensitive and have to use slashes as directory separators.\nA pattern to exclude from processing starts with \"!\".\n\nFiles will overwritten with the converted output, if they are recognised\nas AMD modules and if the dry-run mode is not enabled.\n\nIf named modules are detected, an import map will be printed on the console,\nif no file name for the import map was specified.\n\n### Options\n\n    -d|--[no-]dry-run       only log results, no writing to files\n    -p|--[no-]print         write to stdout instead of overwriting files\n    -m|--import-map \u003cfile\u003e  write the import map with named modules\n    -V|--version            print version number\n    -h|--help               print usage instructions\n\n### Examples\n\n    requirejs-to-esm '**/*.js' '!node_modules'\n    requirejs-to-esm -d \"lib/*.js\"\n    echo \"define({})\" | requirejs-to-esm\"\n\n## API\n\n    convert(source: string): { code: string, warnings: string[], name?: string }\n\nThe function `convert` converts the `source` in AMD to `code` in ESM, optionally returning `warnings`. If the AMD module is named, the name will be returned as `name`. If the conversion is impossible because the input is not an [AMD] module, it will throw `ConvertError`. If the source file cannot be parsed, it will throw `SyntaxError`.\n\n```js\nimport { convert } from 'requirejs-to-esm'\n\nconst input =`define([\"test\"], function (test) {\n  \"use strict\";\n  console.log('imported:', test);\n  return 42; // ultimate answer\n});`\nconst { code } = convert(input)\nconsole.log(code)\n\n// Result:\n//\n// import test from \"test\";\n//\n// console.log('imported:', test);\n// export default 42; // ultimate answer\n```\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code.\n\n## License\n\nCopyright (c) 2022-2025 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[RequireJS]: http://requirejs.org\n[AMD]: https://github.com/amdjs/amdjs-api/blob/master/AMD.md#amd\n[ESM]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules\n[requirejs-babel7]: https://www.npmjs.com/package/requirejs-babel7\n[requirejs-esm]: https://www.npmjs.com/package/requirejs-esm\n[requirejs-esm-preprocessor]: https://www.npmjs.com/package/requirejs-esm-preprocessor\n[Node.js]: http://nodejs.org/\n[NPM]: https://www.npmjs.com/\n[PNPM]: https://pnpm.io/\n[Yarn]: https://yarnpkg.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Frequirejs-esm-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Frequirejs-esm-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Frequirejs-esm-converter/lists"}