{"id":21190781,"url":"https://github.com/jenssimon/babel-plugin-sfcc-modules","last_synced_at":"2025-10-23T20:32:49.215Z","repository":{"id":34548525,"uuid":"180242913","full_name":"jenssimon/babel-plugin-sfcc-modules","owner":"jenssimon","description":"Babel plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)","archived":false,"fork":false,"pushed_at":"2024-05-28T22:02:54.000Z","size":268752,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-29T13:39:19.654Z","etag":null,"topics":["babel","babel-plugin","cartridge","commercecloud","demandware","import","module","require","salesforce","sfcc","sfra","supermodule"],"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/jenssimon.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T22:32:57.000Z","updated_at":"2024-06-01T08:03:21.403Z","dependencies_parsed_at":"2023-10-01T17:18:51.292Z","dependency_job_id":"b5e49994-78c3-41ef-8d9d-42c0ac724cb7","html_url":"https://github.com/jenssimon/babel-plugin-sfcc-modules","commit_stats":{"total_commits":257,"total_committers":5,"mean_commits":51.4,"dds":"0.31906614785992216","last_synced_commit":"f85bb64a65e26fa72e0247100873f22bc4a9833f"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssimon%2Fbabel-plugin-sfcc-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssimon%2Fbabel-plugin-sfcc-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssimon%2Fbabel-plugin-sfcc-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenssimon%2Fbabel-plugin-sfcc-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenssimon","download_url":"https://codeload.github.com/jenssimon/babel-plugin-sfcc-modules/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225615195,"owners_count":17496942,"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","cartridge","commercecloud","demandware","import","module","require","salesforce","sfcc","sfra","supermodule"],"created_at":"2024-11-20T19:01:00.044Z","updated_at":"2025-10-23T20:32:49.210Z","avatar_url":"https://github.com/jenssimon.png","language":"JavaScript","readme":"[![NPM version][npm-image]][npm-url] [![Downloads][npm-downloads-image]][npm-url] [![star this repo][gh-stars-image]][gh-url] [![fork this repo][gh-forks-image]][gh-url] [![CI][gh-status-image]][gh-status-url] [![Coverage Status][coveralls-image]][coveralls-url]\n\n# babel-plugin-sfcc-modules\n\n\u003e Babel plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)\n\nServer-side code for Salesforce Commerce Cloud uses non-standard module resolution patterns:\n\n- first matching cartridge from cartridge path\n```javascript\nrequire('*/cartridge/scripts/foo')\n```\n\n- current cartridge\n```javascript\nrequire('~/cartridge/scripts/bar')\n```\n\nAlso there is a non-standard extension\n```javascript\nmodule.superModule\n```\n\nto reference the next match in cartridge path for the current module.\n\nNode.js does not have solutions for these cases.. This can cause problems when you need to run this code in a Node.js environment. The most common case should be for unit testing.\n\nThis plugin removes the pain of dealing with modules like [proxyquire](https://www.npmjs.com/package/proxyquire) or [sandboxed-module](https://www.npmjs.com/package/sandboxed-module).\n\n## Install\n\n```sh\nyarn add babel-plugin-sfcc-modules --dev\n```\n\n## Usage\n\nAdd to your Babel configuration:\n\n```json\n\"plugins\": [\n  [\"babel-plugin-sfcc-modules\", {\n    \"cartridgePath\": [\n      \"app_brand\",\n      \"app_core\",\n      \"app_storefront_base\"\n    ],\n    \"basePath\": \"./path/to/cartridges\"\n  }]\n]\n```\n\n## Options\n\nOption          | Type     | Description\n----------------|----------|-------------\n`cartridgePath` | `Array`  | the cartridge path used for lookup\n`basePath`      | `string` | path to the folder containing the cartridges\n\n## ️️⚠️️️️⚠️⚠️ Warning ⚠️⚠️⚠️\n\n![kitten.png](https://github.com/jenssimon/babel-plugin-sfcc-modules/raw/main/kitten.png)\n\nYou shouldn't use it for frontend code. There are better alternatives to deal with a cartridge path, [NODE_PATH](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) and the handling of frontend assets in [sgmf-scripts](https://www.npmjs.com/package/sgmf-scripts).\n\nIn my opinion the best way to handle frontend code is to have a clean configuration of Webpack aliases.\n\nThe cartridge path concept isn't common for Node.js/frontend code. This plugin will work for it but I won't officially support it.\n\n## License\n\nMIT © 2023 [Jens Simon](https://github.com/jenssimon)\n\n[npm-url]: https://www.npmjs.com/package/babel-plugin-sfcc-modules\n[npm-image]: https://badgen.net/npm/v/babel-plugin-sfcc-modules\n[npm-downloads-image]: https://badgen.net/npm/dw/babel-plugin-sfcc-modules\n\n[gh-url]: https://github.com/jenssimon/babel-plugin-sfcc-modules\n[gh-stars-image]: https://badgen.net/github/stars/jenssimon/babel-plugin-sfcc-modules\n[gh-forks-image]: https://badgen.net/github/forks/jenssimon/babel-plugin-sfcc-modules\n[gh-status-image]: https://github.com/jenssimon/babel-plugin-sfcc-modules/actions/workflows/ci.yml/badge.svg\n[gh-status-url]: https://github.com/jenssimon/babel-plugin-sfcc-modules/actions/workflows/ci.yml\n\n[coveralls-url]: https://coveralls.io/github/jenssimon/babel-plugin-sfcc-modules?branch=main\n[coveralls-image]: https://coveralls.io/repos/github/jenssimon/babel-plugin-sfcc-modules/badge.svg?branch=main\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenssimon%2Fbabel-plugin-sfcc-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenssimon%2Fbabel-plugin-sfcc-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenssimon%2Fbabel-plugin-sfcc-modules/lists"}