{"id":22423393,"url":"https://github.com/prantlf/babel-plugin-module-resolver-standalone","last_synced_at":"2025-08-01T07:32:18.754Z","repository":{"id":143845993,"uuid":"178681175","full_name":"prantlf/babel-plugin-module-resolver-standalone","owner":"prantlf","description":"Module resolver plugin for Babel usable in both Node.js the web browser environments","archived":false,"fork":false,"pushed_at":"2022-01-03T06:21:43.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-25T15:28:35.604Z","etag":null,"topics":["babel","babel-plugin","browser","mapping","module","plugin","requirejs","resolver"],"latest_commit_sha":null,"homepage":null,"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":"2019-03-31T11:50:59.000Z","updated_at":"2022-01-03T06:21:46.000Z","dependencies_parsed_at":"2023-05-18T00:45:32.425Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/babel-plugin-module-resolver-standalone","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fbabel-plugin-module-resolver-standalone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fbabel-plugin-module-resolver-standalone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fbabel-plugin-module-resolver-standalone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fbabel-plugin-module-resolver-standalone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/babel-plugin-module-resolver-standalone/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":["babel","babel-plugin","browser","mapping","module","plugin","requirejs","resolver"],"created_at":"2024-12-05T18:11:06.757Z","updated_at":"2024-12-05T18:11:09.497Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-module-resolver-standalone\n\n[![Latest version](https://img.shields.io/npm/v/babel-plugin-imodule-resolver-standalone)\n ![Dependency status](https://img.shields.io/librariesio/release/npm/babel-plugin-module-resolver-standalone)\n](https://www.npmjs.com/package/babel-plugin-module-resolver-standalone)\n\nA [Babel] plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to transform the path of each source module using a custom JavaScript function.\n\nThis plugin can be used instead of [babel-plugin-module-resolver], if the target environment is a web browser using [@babel/standalone], with which the original plugin does not work. This plugin supports only the method [resolvePath] for the time being.\n\n### Table of Contents\n\n- [Installation](#installation-and-getting-started)\n- [Babel Configuration Examples](#babel-configuration-examples)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nThis module can be installed in your project using [NPM], [PNPM or [Yarn]. Make sure, that you use [Node.js] version 6 or newer.\n\n```sh\nnpm i -D babel-plugin-module-resolver-standalone\npnpm i -D babel-plugin-module-resolver-standalone\nyarn add babel-plugin-module-resolver-standalone\n```\n\n## Babel Configuration Examples\n\nPrepend path to utility modules to be able to import them from `utils/...` without always providing the actual full path:\n\n```js\n{\n  plugins: [\n    [\n      'module-resolver',\n      {\n        resolvePath: function (sourcePath, currentFile, opts) {\n          if (sourcePath.startsWith('utils/')) {\n            return '../../'+ sourcePath\n          }\n        }\n      }\n    ]\n  ]\n}\n```\n\nEnsure, that all JavaScript module paths are prefixed by `es6!`, so that [requirejs-babel] will be applied by [RequireJS] to nested modules too:\n\n```js\n{\n  plugins: [\n    'transform-modules-amd',\n    [\n      'module-resolver',\n      {\n        resolvePath: function (sourcePath, currentFile, opts) {\n          // Avoid prefixing modules handled by other plugins.\n          if (sourcePath.indexOf('!') \u003c 0) {\n            return 'es6!' + sourcePath;\n          }\n        }\n      }\n    ]\n  ]\n}\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) 2019-2022 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[Node.js]: http://nodejs.org/\n[NPM]: https://www.npmjs.com/\n[PNPM]: https://pnpm.io/\n[Yarn]: https://yarnpkg.com/\n[RequireJS]: https://requirejs.org/\n[Babel]: http://babeljs.io\n[@babel/standalone]: https://github.com/babel/babel/tree/master/packages/babel-standalone\n[babel-plugin-module-resolver]: https://github.com/tleunen/babel-plugin-module-resolver\n[resolvePath]: https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#resolvepath\n[requirejs-babel]: https://github.com/prantlf/requirejs-babel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fbabel-plugin-module-resolver-standalone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fbabel-plugin-module-resolver-standalone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fbabel-plugin-module-resolver-standalone/lists"}