npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@atlassian/soy-loader

v5.3.7

Published

Soy loader for webpack using the Atlassian Soy CLI compiler

Downloads

11,534

Readme

@atlassian/soy-loader

node version webpack peer dependency version npm downloads

Compiles Soy Templates templates with @atlassian/soy-template-plugin-js package and allows to load them with webpack

Installation

You can install the library using NPM:

npm install @atlassian/soy-loader

or by Yarn:

yarn add @atlassian/soy-loader

Usage example

// webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.soy/,
        use: [
          {
            loader: '@atlassian/soy-loader',
            options: {
              // ... see Options below ...
            },
          },
        ],
      },
    ],
  },
};

Options

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.

Recipes

Using with *.properties webpack loader

This 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',
          },
        ],
      },
    ],
  },
};

Using 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.

Additional links

Minimum requirements

This plugin is compatible with:

  • webpack 4.0+ and 5.0+
  • Node 12+