
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
babel-plugin-sfcc-modules
Advanced tools
Babel plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)
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:
require('*/cartridge/scripts/foo')
require('~/cartridge/scripts/bar')
Also there is a non-standard extension
module.superModule
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.
This plugin removes the pain of dealing with modules like proxyquire or sandboxed-module.
$ yarn add babel-plugin-sfcc-modules --dev
Add to your Babel configuration:
"plugins": [
["babel-plugin-sfcc-modules", {
"cartridgePath": [
"app_brand",
"app_core",
"app_storefront_base"
],
"basePath": "./path/to/cartridges"
}]
]
Option | Type | Description |
---|---|---|
cartridgePath | Array | the cartridge path used for lookup |
basePath | string | path to the folder containing the cartridges |
You shouldn't use it for frontend code. There are better alternatives to deal with a cartridge path, NODE_PATH and the handling of frontend assets in sgmf-scripts.
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 © 2023 Jens Simon
FAQs
Babel plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)
The npm package babel-plugin-sfcc-modules receives a total of 214 weekly downloads. As such, babel-plugin-sfcc-modules popularity was classified as not popular.
We found that babel-plugin-sfcc-modules demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.