Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@atlassian/soy-loader
Advanced tools
Compiles Soy Templates templates with @atlassian/soy-template-plugin-js package and allows to load them with webpack
You can install the library using NPM:
npm install @atlassian/soy-loader
or by Yarn:
yarn add @atlassian/soy-loader
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.soy/,
use: [
{
loader: '@atlassian/soy-loader',
options: {
// ... see Options below ...
},
},
],
},
],
},
};
data
<string
> (optional)Example: 'foo:bar,moo:goo'
Data to pass to the soy renderer (soy rendering only) in the form :,:
functions
<string>
(optional)Example: '/foo/bar/path'
Locations of custom soy functions, usually a path to a *.jar
file.
expose
<boolean>
(optional)Default: true
Indicates whether the generated namespace should be exposed to the window or not. If not, the module must be required to call the templates.
modularize
<boolean>
(optional)Default: false
Indicates whether to convert template calls and definitions to ES6 module imports and exports. Allows Webpack to track the chain of template calls, but assumes a naming convention that maps namespace strings to file paths. See [#Using-modularize](Using modularize) for details.
customModuleMap
Map<string, string | boolean>
(optional)Example: { 'foo.bar.Template': 'foo/baz', 'moo.foo': false }
To be used with the modularize
option. An object mapping namespaces to module names when using modularize. Explicit false
ignores a module and leaves it as a global reference. Other falsy values fallback to default resolution handling.
modulePathResolver
: <Function>
(optional)Example:
function customModulePathResolver(namespace, context) {
return namespace.replace(/\./g, '/');
}
function customModuleRelativePathResolver(namespace, context) {
return path.relative(context, namespace.replace(/\./g, '/'));
}
To be used with the modularize
option. A function that takes a namespace
[string
], context
[string
], and outputs a module path when using modularize.
You can read more about the value of context
here: https://webpack.js.org/api/loaders/#thiscontext
Returning an explicit false
ignores a module and leaves it as a global reference. Return other falsy or undefined
values to fallback to default resolution handling.
*.properties
webpack loaderThis package can be used with the @atlassian/i18n-properties-loader
when you run your code with webpack dev server:
// webpack.config.js
const myI18nFiles = [
'foo/i18n/my-translation-file.properties',
'foo/bar/i18n/my-other-translation-file.properties',
'bar/i18n/some-translation-file.properties',
];
module.exports = {
module: {
rules: [
{
test: /\.soy/,
use: [
{
loader: '@atlassian/i18n-properties-loader',
options: {
i18nFiles: myI18nFiles,
},
},
{
loader: '@atlassian/soy-loader',
},
],
},
],
},
};
modularize
Modularize is a specialized case that can be used when your {namespace}s and Soy files are 1-to-1. It converts any external templates references to ES6 module imports (and conversely any defined templates become named exports from this module). This allows Webpack to trace dependencies between Soy files, rather than having to specify this manually.
By default, the camelCase
namespace becomes the kebab-case
, dot separators become directories, and .soy
suffix is appended.
Example: The {namespace a.bCD}
namespace is converted to import 'a/b-c-d.soy';
module path.
This can be overridden using the customModuleMap
option for one-off exceptions, and/or the modulePathResolver
function to change the naming scheme entirely. NOTE: the modules MUST be unique per namespace.
Currently, the AUI-provided namespaces are ignored and left as global variable references, and thus dependencies on AUI can't be tracked. If you want to handle this differently, check out the DEFAULT_MAPPINGS
in the modular-soy.js
file, and replace each false
with a module name.
This plugin is compatible with:
FAQs
Soy loader for webpack using the Atlassian Soy CLI compiler
The npm package @atlassian/soy-loader receives a total of 523 weekly downloads. As such, @atlassian/soy-loader popularity was classified as not popular.
We found that @atlassian/soy-loader 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.