Babel plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)
Server-side code for Salesforce Commerce Cloud uses non-standard module resolution patterns:
- first matching cartridge from cartridge path
- current cartridge
Also there is a non-standard extension
to reference the next match in cartridge path for the current module.
Node.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.
$ yarn add babel-plugin-sfcc-modules --dev
Add to your Babel configuration:
||the cartridge path used for lookup|
||path to the folder containing the cartridges|
️️⚠️️️️⚠️⚠️ Warning ⚠️⚠️⚠️
In my opinion the best way to handle frontend code is to have a clean configuration of Webpack aliases.
The cartridge path concept isn't common for Node.js/frontend code. This plugin will work for it but I won't officially support it.
MIT © 2020 Jens Simon