Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

atlassian-webresource-webpack-plugin

atlassianlabs21.5kApache-2.07.0.1TypeScript support: included

Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.

atlassian, webpack, wrm, server, web, webresource, resource, manager

readme

Atlassian Web-Resource webpack Plugin

node npm webpack

Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.

Why?

Atlassian's P2 plugin system was shipped in 2008. At the time, the dependency management system in P2 -- the Web Resource Manager, or WRM -- was a godsend for managing the growing complexity of the front-end resources. It offered, amongst other things:

  • The ability to specify bundles of related resources, called a "web-resource".
  • The ability to specify inter-dependencies of web-resources, so that
  • Batching of necessary code in production could be achieved, and
  • Source order could be maintained.

Fast-forward to 2017, and front-end development is drastically different from it was back then. JavaScript module systems and webpack have solved many of the problems the WRM initially set out to.

Unfortunately, Atlassian's plugin system doesn't speak webpack. Happily, though, we can teach webpack to speak Atlassian-Plugin. That's what this plugin does.

What does it do?

When you add this plugin to your webpack configuration, it will generate an XML file with the various WRM configuration necessary to make your code run in an Atlassian product.

You will be able to write your plugin's front-end code using any JavaScript module system. This plugin will figure out how to turn all of it in to the correct <web-resource> declarations, along with the appropriate <dependency> declarations so that your code ends up loading in the right order at a product's runtime.

This plugin supports and generates correct WRM output for the following webpack behaviours:

  • a <web-resource> per webpack entry point
  • correct <web-resource>s for code-splitting / loading asynchronous chunks
  • loading of non-JavaScript resources (via ExtractTextPlugin and friends).

How to use the plugin

Basic setup

Add this plugin to your webpack config. For every entry point webpack generates, an appropriate <web-resource> definition will be generated in an XML file for you, which can then be bundled in to your Atlassian product or plugin, ready to be served to the browser at product runtime.

Given this webpack config:

const WrmPlugin = require('atlassian-webresource-webpack-plugin');

module.exports = {
  entry: {
    'my-feature': path.join(FRONTEND_SRC_DIR, 'simple.js'),
  },
  plugins: [
    new WrmPlugin({
      pluginKey: 'my.full.plugin.artifact-id',
      contextMap: {
        'my-feature': ['atl.general'],
      },
      xmlDescriptors: path.resolve(OUTPUT_DIR, 'META-INF', 'plugin-descriptors', 'wr-defs.xml'),
    }),
  ],
  output: {
    filename: 'bundled.[name].js',
    path: path.resolve(OUTPUT_DIR),
  },
};

The output will go to <OUTPUT_DIR>/META-INF/plugin-descriptors/wr-defs.xml, and look something like this:

<bundles>

        <web-resource key="entrypoint-my-feature">
            <transformation extension="js">
                <transformer key="jsI18n"/>
            </transformation>
            <context>atl.general</context>
            <resource name="bundled.my-feature.js" type="download" location="bundled.my-feature.js" />
        </web-resource>

</bundles>

Also, <OUTPUT_DIR>/META-INF/fe-manifest-associations/ will include list of resources created by this webpack build and NPM package name for AMPs resource association feature.

Package name can be specified by passing packageName field to WrmPlugin directly, otherwise it is taken automatically from the closest parent package.json of Webpack context directory.

Association is automatically detected by AMPs in P2 plugins and is expected to be in target/classes/META-INF/fe-manifest-associations of plugin build.

Consuming the output in your P2 plugin

In your P2 plugin project's pom.xml file, add the META-INF/plugin-descriptors directory as a value to an <Atlassian-Scan-Folders> tag in the <instruction> section of the AMPS plugin's build configuration.

<build>
  <plugins>
    <plugin>
      <!-- START of a bunch of stuff that is probably different for your plugin, but is outside
           the scope of this demonstration -->
      <groupId>com.atlassian.maven.plugins</groupId>
      <artifactId>maven-amps-plugin</artifactId>
      <version>6.2.11</version>
      <!-- END differences with your plugin -->
      <configuration>
        <instructions>
          <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
        </instructions>
      </configuration>
    </plugin>
  </plugins>
</build>

Demonstration P2 plugin usage

You can see a demonstration P2 plugin using the webpack plugin here: sao4fed-bundle-the-ui

  • Watch this AtlasCamp 2018 talk which uses this plugin amongst others to make your devloop super fast: https://youtu.be/VamdjcJCc0Y
  • Watch this AtlasCamp 2017 talk about how to build and integrate your own front-end devtooling on top of P2, which introduced the alpha version of this plugin: https://youtu.be/2yf-TzKerVQ?t=537

Features

Code splitting

If you write your code using any of webpack's code-splitting techniques, such as calling require.ensure, this plugin will automatically generate <web-resource> definitions for them, and automatically translate them in to the appropriate calls to load them asynchronously at an Atlassian product's runtime.

In other words, there's practically no effort on your part to make your critical path small :)

Flexible generation of web-resource definitions

By default, a generated web-resource will have:

  • A key based on the name of your webpack entry-point, and
  • Will be included in a <context> named after your entry-point.

For example, an entry point named "my-feature" will yield a web-resource like this:

<web-resource key="entrypoint-my-feature">
  <context>my-feature</context>
  <!-- the resources for your entry-point -->
</web-resource>

For new code, this should be enough to get your feature loading in to a place you want it to in your plugin or product -- assuming the appropriate call on the server-side is made to include your web-resource.

Sometimes, in order to ensure your code loads when it's expected to, you will need to override the values generated for you. To do this, when defining the WrmPlugin's config, you can provide either:

  • A webresourceKeyMap to change the web-resource's key or name to whatever you need it to be, or
  • A contextMap to include the web-resource in any number of web-resource contexts you expect it to load in to.

It's most likely that you'll want to specify additional contexts for a web-resource to load in to. When all of your web-resources are automatically generated and loaded via contexts, there is no need to know its key. You would typically provide your own web-resource key when refactoring old code to webpack, in order to keep the dependencies working in any pre-existing code.

Module-mapping to web-resources

If you use a common library or module -- for example, 'jquery' or 'backbone' -- and you know that this module is provided by a P2 plugin in the product's runtime, you can map your usage of the module to the web-resource that provides it.

All you need to do is declare the appropriate webpack external for your module, and add an entry for the external in the providedDependencies configuration of this plugin. When your code is compiled, this plugin will automatically add an appropriate web-resource dependency that will guarantee your code loads after its dependants, and will prevent your bundle from getting too large.

For details, check the providedDependencies section in the configuration section.

Legacy web-resource inclusion

90% of the time, your JavaScript code should be declaring explicit dependencies on other modules. In the remaining 10% of cases, you may need to lean on the WRM at runtime to ensure your code loads in the right order. 9% of the time, the module-mapping feature should be enough for you. In the remaining 1%, you may just need to add a web-resource dependency to force the ordering.

You can add import statements to your code that will add a <dependency> to your generated web-resource.

To include web-resources from exported by this plugin you can use short notation like:

// in AMD syntax
define(function (require) {
  require('wr-dependency!my-webresource');
  console.log('my-webresource will have been loaded synchronously with the page');
});

// in ES6
import 'wr-dependency!my-webresource';

console.log('my-webresource will have been loaded synchronously with the page');

To include resources exported by other plugins, provide full plugin key:

// in AMD syntax
define(function (require) {
  require('wr-dependency!com.atlassian.auiplugin:dialog2');
  console.log('webresource will have been loaded synchronously with the page');
});

// in ES6 syntax
import 'wr-dependency!com.atlassian.auiplugin:dialog2';

console.log('webresource will have been loaded synchronously with the page');

Legacy runtime resource inclusion

95% of the time, your application's non-JavaScript resources -- CSS, images, templates, etc. -- are possible to bundle and include via webpack loaders. Sometimes, though, you will have resources that only work during an Atlassian product's runtime -- think things like Atlassian Soy templates and a product's Less files for look-and-feel styles -- and it isn't possible to make them work during ahead-of-time compilation.

In these cases, you can add import statements to your code that will add a <resource> to your generated web-resource:

// in AMD syntax
define(function (require) {
  require('wr-resource!my-runtime-styles.css!path/to/the/styles.less');
  require('wr-resource!my-compiled-templates.js!path/to/the/templates.soy');

  console.log('these styles and templates will be transformed to CSS and JS at product runtime.');
});

// in ES6 syntax
import 'wr-resource!my-runtime-styles.css!path/to/the/styles.less';
import 'wr-resource!my-compiled-templates.js!path/to/the/templates.soy';

console.log('these styles and templates will be transformed to CSS and JS at product runtime.');

Configuring the plugin

The Atlassian Web-Resource webpack Plugin has a number of configuration options.

pluginKey (Required)

The fully-qualified groupId and artifactId of your P2 plugin. Due to the way the WRM works, this value is necessary to provide in order to support loading of asynchronous chunks, as well as arbitrary (non-JavaScript) resources.

xmlDescriptors (Required)

An absolute filepath to where the generated XML should be output to. This should point to a sub-directory of the Maven project's ${project.build.outputDirectory} (which evaluates to target/classes in a standard Maven project).

The sub-directory part of this configuration value needs to be configured in the project's pom.xml, as demonstrated in the basic usage section above.

addEntrypointNameAsContext (Optional)

Default is false.

When set to true, all generated web-resources will be added to a context with the same name as the entrypoint.

addAsyncNameAsContext (Optional)

Default is false.

When set to true, all generated web-resources for async chunks that have a name (specified via webpackChunkName on import) will be added to a context of the name "async-chunk-<name as specified in webpackChunkName>".

contextMap (Optional)

A set of key-value pairs that allows you to specify which webpack entry-points should be present in what web-resource contexts at an Atlassian product runtime.

You can provide either a single web-resource context as a string, or an array of context strings.

conditionMap (Optional)

An object specifying what conditions should be applied to a certain entry-point. Simple example:

conditionMap: {
  "my-first-entry-point": {
    "class": "foo.bar"
  },
}

will yield:

<condition class="foo.bar" />

Complex nested example with params:

conditionMap: {
  "my-first-entry-point": {
    "type": "AND",
    "conditions": [
      {
        "type": "OR",
        "conditions": [
          {
            "class": "foo.bar.baz",
            "invert": true,
            "params": [
              {
                "attributes": {
                  "name": "permission"
                },
                "value": "admin"
              }
            ]
          },
          {
            "class": "foo.bar.baz2",
            "params": [
              {
                "attributes": {
                  "name": "permission"
                },
                "value": "project"
              }
            ]
          }
        ]
      },
      {
        "class": "foo.bar.baz3",
        "params": [
          {
            "attributes": {
              "name": "permission"
            },
            "value": "admin"
          }
        ]
      }
    ]
  }
}

will yield:

<conditions type="AND">
  <conditions type="OR">
    <condition class="foo.bar.baz" invert="true">
      <param name="permission">admin</param>
    </condition>
    <condition class="foo.bar.baz2" >
      <param name="permission">project</param>
    </condition>
  </conditions>
  <condition class="foo.bar.baz3" >
    <param name="permission">admin</param>
  </condition>
</conditions>

dataProvidersMap (Optional)

The dataProvidersMap option allows configuring the association between entrypoint and a list of data providers.

Data providers can be used to provide a data from the server-side to the frontend, and claimed using WRM.data.claim API. To read more about data providers refer to the official documentation.

To associate the entrypoint with list of data providers you can configure the webpack configuration as follow:

module.exports = {
  entrypoints: {
    'my-first-entry-point': './first-entry-point.js',
    'my-second-entry-point': './first-entry-point.js',
  },

  plugins: [
    WrmPlugin({
      pluginKey: 'my.full.plugin.artifact-id',
      dataProvidersMap: {
        'my-first-entry-point': [
          {
            key: 'my-foo-data-provider',
            class: 'com.example.myplugin.FooDataProvider',
          },
        ],

        'my-second-entry-point': [
          {
            key: 'my-bar-data-provider',
            class: 'com.example.myplugin.BarDataProvider',
          },

          {
            key: 'my-bizbaz-data-provider',
            class: 'com.example.myplugin.BizBazDataProvider',
          },
        ],
      },
    }),
  ],
};

will yield:

<atlassian-plugin>
    <web-resource key="<<key-of-my-first-entry-point>>">
        <resource  />
        <resource  />

        <data key="my-foo-data-provider" class="com.example.myplugin.FooDataProvider" />
    </web-resource>

    <web-resource key="<<key-of-my-first-entry-point>>">
        <resource  />
        <resource  />

        <data key="my-bar-data-provider" class="com.example.myplugin.BarDataProvider" />
        <data key="my-bizbaz-data-provider" class="com.example.myplugin.BizBazDataProvider" />
    </web-resource>
</atlassian-plugin>

deprecatedEntrypoints (Optional)

An object specifying which entry-points should be marked as being deprecated.

A true value may be used instead to simply mark an entry-point as being deprecated without providing any additional information.

Otherwise an object may be used to provide additional context as to when and why the entry-point was deprecated. For the alternative key, the value should either be in the format of plugin-key:web-resource, or be a reference to another entry-point in the same plugin.

module.exports = {
  entrypoints: {
    'my-first-entry-point': './first-entry-point.js',
    'my-second-entry-point': './second-entry-point.js',
    'my-third-entry-point': './third-entry-point.js',
  },

  plugins: [
    WrmPlugin({
      pluginKey: 'my.full.plugin.artifact-id',
      deprecatedEntrypoints: {
        'my-first-entry-point': true,
        'my-second-entry-point': {
          sinceVersion: '3.0',
          removeInVersion: '4.0',
          // alternative could also reference another entrypoint i.e. 'my-third-entry-point'
          alternative: 'some.other.plugin:replacement-resource',
          extraInfo: 'We moved all functionality to some.other.plugin',
        },
      },
    }),
  ],
};

will yield:

<atlassian-plugin>
    <web-resource key="entrypoint-my-first-entry-point">
        <!-- ... rest of definition ... -->
        <deprecated />
    </web-resource>
    <web-resource key="entrypoint-my-second-entry-point">
        <!-- ... rest of definition ... -->
        <deprecated since="3.0"
                    remove="4.0"
                    alternative="some.other.plugin:replacement-resource"
        >
            We moved all functionality to some.other.plugin
        </deprecated>
    </web-resource>
</atlassian-plugin>

transformationMap (Optional)

An object specifying transformations to be applied to file types. The default transformations are:

  • *.js files => jsI18n
  • *.soy files => soyTransformer, jsI18n

Example configuration for custom transformations:

{
  "transformationMap": {
    "js": ["myOwnJsTransformer"],
    "sass": ["myOwnSassTransformer"]
  }
}

This would set the following transformations to every generated web-resource:

<web-resource key="...">
    <transformation extension="js">
      <transformer key="myOwnJsTransformer"/>
    </transformation>
    <transformation extension="sass">
      <transformer key="myOwnSassTransformer"/>
    </transformation>
</web-resource>

If you wish to extend the default transformations you can use the build-in extendTransformations function provided by the plugin. It will merge the default transformations with your custom config:

const WrmPlugin = require('atlassian-webresource-webpack-plugin');

new WrmPlugin({
  pluginKey: 'my.full.plugin.artifact-id',
  transformationMap: WrmPlugin.extendTransformations({
    js: ['myOwnJsTransformer'],
    sass: ['myOwnSassTransformer'],
  }),
});

You can also completely disable the transformations by passing false value to the plugin configuration:

{
  "transformationMap": false
}

webresourceKeyMap (Optional)

Allows you to change the name of the web-resource that is generated for a given webpack entry-point.

This is useful when you expect other plugins will need to depend on your auto-generated web-resources directly, such as when you refactor an existing feature (and its web-resource) to be generated via webpack.

This parameter can take either string or object with properties key, name and state which corresponds to key, name and state attributes of web-resource XML element. name and state properties are optional.

Mapping as follows:

{
  "webresourceKeyMap": {
    "firstWebResource": "first-web-resource",
    "secondWebResource": {
      "key": "second-web-resource",
      "name": "Second WebResource",
      "state": "disabled"
    }
  }
}

will result in the following web-resources:

<atlassian-plugin>
<web-resource key="first-web-resource" name="" state="enabled">
  <!-- your resources definitions -->
</web-resource>
<web-resource key="second-web-resource" name="Second WebResource" state="disabled">
  <!-- your resources definitions -->
</web-resource>
</atlassian-plugin>

providedDependencies (Optional)

A map of objects that let you associate what web-resources house particular external JS dependencies.

The format of an external dependency mapping is as follows:

{
  'dependency-name': {
    dependency: 'atlassian.plugin.key:webresource-key',
    import: {
      // externals configuration
    },
  },
}

In this example, externals is a JSON object following the webpack externals format.

When your code is compiled through webpack, any occurrence of dependency-name found in a module import statement will be replaced in the webpack output, and an appropriate web-resource <dependency> will be added to the generated web-resource.

wrmManifestPath (Optional)

A path to a WRM manifest file where the plugin will store a map of objects. Under the providedDependencies property is a map of dependencies, including the generated web-resource keys. This map is the exact same format that is accepted with the providedDependencies option above, so one can use this map as a source for providedDependencies in another build:

{
  "providedDependencies": {
    "dependency-name": {
      "dependency": "atlassian.plugin.key:webresource-key",
      "import": {
        "var": "require('dependency-amd-module-name')",
        "amd": "dependency-amd-module-name"
      }
    }
  }
}

Notes and limitations

  • Both output.library and output.libraryTarget must be set for the WRM manifest file to be created.
  • output.library must not contain [chunk] or [hash], however [name] is allowed
  • output.libraryTarget must be set to amd
  • More properties might be added to the WRM manifest file in future

Example configuration

{
  "output": {
    "library": "[name]",
    "libraryTarget": "amd"
  }
}

resourceParamMap (Optional)

An object specifying additional parameters (<param/>) for resources.

To specify for example content-types the server should respond with for a certain assets file-type (e.g. images/fonts):

{
  "resourceParamMap": {
    "svg": [
      {
        "name": "content-type",
        "value": "image/svg+xml"
      }
    ]
  }
}

Setting specific content-types may be required by certain Atlassian products depending on the file-type to load. Contains content-type for svg as "image/svg+xml" by default

locationPrefix (Optional)

Adds given prefix value to location attribute of resource node. Use this option when your webpack output is placed in a subdirectory of the plugin's ultimate root folder.

devAssetsHash (Optional)

Uses provided value (instead of DEV_PSEUDO_HASH) in the webresource name that contains all of the assets needed in development mode.

watch and watchPrepare (Optional)

Activates "watch-mode". This must be run in conjunction with a webpack-dev-server.

watchPrepare

Creates "proxy"-Resources and references them in the XML-descriptor. These proxy-resources will redirect to a webpack-dev-server that has to be run too. In order for this to work properly, ensure that the webpack-config "options.output.publicPath" points to the webpack-dev-server - including its port. (e.g. http://localhost:9000)

watch (Optional)

Use when running the process with a webpack-dev-server.

useDocumentWriteInWatchMode (Optional)

When set to true, the generated watch mode modules will add the script tags to the document synchronously with document.write while the document is loading, rather than always relying on asynchronously appended script tags (default behaviour).

This is useful when bundles are expected to be available on the page early, e.g. when code in a template relies on javascript to be loaded blockingly.

noWRM (Optional)

Will not add any WRM-specifics to the webpack-runtime or try to redirect async-chunk requests while still handling requests to wr-dependency and wr-resource. This can be useful to develop frontend outside of a running product that provides the WRM functionality.

singleRuntimeWebResourceKey (Optional)

Set a specific web-resource key for the webpack runtime when using the webpack option optimization.runtimeChunk to single (see runtimeChunk documentation). Default is common-runtime.

verbose (Optional)

Indicate verbosity of log output. Default is false.

Minimum requirements

This plugin has been built to work with the following versions of the external build tools:

This plugin is tested with webpack 5.0+.

  • To compile CSS, use css-loader >= 5 along with mini-css-extract-plugin >= 2.
  • When using mini-css-extract-plugin runtime option needs to be set to false. This will prevent mini-css-extract-plugin from injecting extracted css to document head, which is done by WRM.

Upgrade guides

Troubleshooting and known problems

Self troubleshooting tool

We provide a tool that helps troubleshoot the configuration of webpack and Atlassian P2 projects.

To check if your project was configured correctly, open a terminal and navigate to the root directory of your project. Next, run the troubleshooting command:

npx @atlassian/wrm-troubleshooting

The tool will ask you a few questions and guide you if it finds issues with your projects' configuration.

You can read more about the troubleshooting tool on the NPM page for the @atlassian/wrm-troubleshooting package.

webpack-sources compatibility

If you install webpack-sources@3 along with webpack@4, you'll likely get this error:

/project/path/node_modules/webpack/node_modules/webpack-sources/lib/ConcatSource.js:59
                        return typeof item === "string" ? item : item.node(options);

TypeError: item.node is not a function
    at /project/path/node_modules/webpack/node_modules/webpack-sources/lib/ConcatSource.js:59:50
    at Array.map (<anonymous>)
    at ConcatSource.node (/project/path/node_modules/webpack/node_modules/webpack-sources/lib/ConcatSource.js:58:63)
    at proto.sourceAndMap (/project/path/node_modules/webpack/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18)
    at CachedSource.sourceAndMap (/project/path/node_modules/webpack/node_modules/webpack-sources/lib/CachedSource.js:58:31)
    at getTaskForFile (/project/path/node_modules/webpack/lib/SourceMapDevToolPlugin.js:65:30)
    at /project/path/node_modules/webpack/lib/SourceMapDevToolPlugin.js:215:20
    at Array.forEach (<anonymous>)
    at /project/path/node_modules/webpack/lib/SourceMapDevToolPlugin.js:186:12
    at SyncHook.eval [as call] (eval at create (/project/path/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)

A solution is to downgrade to webpack-sources@2

Other problems

Check that your build and bundle works as you expect without this plugin enabled. You can disable the WRM webpack plugin and bundle the code to verify no errors or warnings are present in the webpack output.

This plugin makes very few changes to what webpack ultimately outputs. If your bundles have content errors, it may be due to version incompatibilities between webpack and the loader plugins in your build configuration.

Known problems with this plugin are listed in the Atlassian Ecosystem issue tracker. Our development team review all open issues and triage on a monthly basis.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

7.0.1 (2025-04-17)

Note: Version bump only for package atlassian-webresource-webpack-plugin

7.0.0 (2024-11-19)

⚠ BREAKING CHANGES

  • webresource-webpack-plugin: less-transformer is no longer included in default transformations map. Please use Webpack's less-loader instead

Features

  • webresource-webpack-plugin: drop support for less transformer (134a7b2)

Reverts

  • Revert "chore: changelog linting and postrelease step" (9eb1420)

6.0.3 (2024-06-25)

Bug Fixes

  • soy-loader: SPFE-1067 - ensure soy-loader accepts webpack 4 as a peer dependency and add system-level tests for working with all supported webpack versions (3d8fe4e)

6.0.2 (2024-05-28)

Bug Fixes

6.0.1 (2024-05-13)

Bug Fixes

  • webresource-webpack-plugin: add warning if minicssextract runtime enabled (d502167)
  • webresource-webpack: do not concatenate provided dependencies (c710c8d)
  • webresource-webpack: rename test (db77fb9)

Reverts

  • webresource-webpack-plugin: dep versions (428378c)
  • webresource-webpack-plugin: ts-ignore (b251a36)
  • webresource-webpack-plugin: xml-formatter (c72f0af)

6.0.0 (2024-04-05)

⚠ BREAKING CHANGES

  • Removed support for Webpack v4

Features

  • SPFE-968 - Removed the V4 functions call and support in webpackv4or5 function (e269e77)
  • webresource-webpack-plugin: introduce association generation for resource files. Automatically pick up the associated package name from Webpack context path (a129ce4)

Bug Fixes

  • SPFE-1059 - Moved glob dependency to devDeps in webresource-webpack-plugin (b052336)
  • SPFE-907: Add provided dependency for WRM i18n module (4e720e8)
  • BSP-4677 updated the event (dd2deba)
  • webresource-webpack: fix typo in hookIntoCompileDoneToGenerateReports: Comple -> Compile (9496c8a)

5.2.11 (2023-02-07)

Bug Fixes

  • BSP-4677 updated the event (dd2deba)

5.2.10 (2022-08-09)

Note: Version bump only for package atlassian-webresource-webpack-plugin

5.2.9 (2022-06-06)

Bug Fixes

5.2.8 (2022-02-10)

Note: Version bump only for package atlassian-webresource-webpack-plugin

5.2.7 (2021-11-17)

Bug Fixes

  • Update webpack depndency (00fc73e)

5.2.6 (2021-10-14)

Note: Version bump only for package atlassian-webresource-webpack-plugin

5.2.5 (2021-10-08)

Bug Fixes

  • webresource-webpack-plugin: issue-11 - defer overwriting of files only on webpack5 (f7360b0)
  • webresource-webpack-plugin: update test to ensure files are properly overwritten (401d06b)

5.2.4 (2021-09-30)

Bug Fixes

  • webresource-webpack-plugin: fix webpack 4 incompatibility (8f4f351)
  • webresource-webpack-plugin: remove unused files (c56cf09)
  • webresource-webpack-plugin: use esbuild-register to run typescript from node (dd4cd29)

5.2.3 (2021-09-27)

Note: Version bump only for package atlassian-webresource-webpack-plugin

5.2.2 (2021-09-24)

Note: Version bump only for package atlassian-webresource-webpack-plugin

5.2.1 (2021-09-22)

  • fix: Make sure devtools are set to "false" in watch-prepare step, to prevent falsy sourcemaps from being generated
  • Update internal dependencies

5.2.0 (September 6, 2021)

  • chore: Upgrade internal dependencies
  • docs: Add info about the WRM troubleshooting tool

5.1.1 (July 2, 2021)

  • feat: Migrated codebase to TypeScript
  • feat: Update internal project dependencies
  • fix: Fixed issue where compilations that had child-compilations would fail due to multiple assets with the same name being emited (see Issue #87)
  • fix: Fixed issue where files using [contenthash] were referenced incorrectly in the xml and manifest files (see Issue #89)

5.1.0 (June 29, 2021)

Broken release.

5.0.1 (May 14, 2021)

Fixed

  • fix: Correct the information about supported version of Node. The project is using Node 12 and requires min. Node 12 version.

5.0.0 (May 6, 2021) (deprecated)

Added

Fixed

  • fix: Fix document.write behaviour when "useDocumentWriteInWatchMode" is used. Ensure document.write is not used when a script is loaded async via javascript.

Removed

  • [BREAKING]: We dropped support for Node 6. The atlassian-webresource-webpack-plugin requires a Node version 12 or newer.
  • [BREAKING] delete: Removed __testGlobs__ configuration option.
  • [BREAKING] delete: Removed assetContentTypes configuration option. Use resourceParamMap instead.
  • [BREAKING] delete: Removed standalone configuration option.
  • [BREAKING] feat: The default values of addEntrypointNameAsContext and addAsyncNameAsContext have been flipped to false.

4.9.0 (July 23, 2020)

  • feat: added dataProvidersMap option that adds missing support for data providers. Data providers can be used to provide a data from the server-side to the frontend, and claimed using WRM.data.claim API.

4.8.0 (January 29, 2020)

  • feat: the WRM.require function and associated web-resource dependency will only be added to chunks that need it (i.e., any chunk that lazy-loads other chunks). This makes compiled web-resources with no code-splitting a bit smaller at product runtime.
  • fix: assets served from webpack's public path will receive cache headers.

4.7.2 (December 20, 2019)

  • feat: if webpack mode is set to none determine the environment from process.env.NODE_ENV
  • feat: adds ability to provide custom hash name for dev assets

4.7.1 (December 16, 2019)

  • chore: updated various module dependencies.
  • fix: added webpack-sources as a first-order dependency.

4.7.0 (September 11, 2019)

  • feature: added addAsyncNameAsContext option to add an auto-generated web-resource context to all async chunks.

4.6.1 (August 29, 2019)

  • fix: enable cross-origin loading of resources in development mode only.

4.6.0 (August 7, 2019)

4.5.0 (May 30, 2019)

  • feature: added addEntrypointNameAsContext option to control whether generated web-resources are added to a context by default or not.

4.4.4 (May 30, 2019)

  • bugfix: The generated loader code works in older browsers that don't like trailing commas in their JavaScript.

4.4.2/4.4.3 (April 15, 2019)

  • bugfix: Fix bug introduced due to changes in 4.4.1 where undefined was returned by require.ensure instead of a promise.

4.4.1 (April 12, 2019)

  • bugfix: Using the mini-css-extract-plugin will no longer trigger unwanted requests trying to load style files.

4.4.0 (April 11, 2019)

  • feature: added singleRuntimeWebResourceKey option to allow changing the webpack runtime name. Check the readme for usage details.
  • feature: added useDocumentWriteInWatchMode option to control how code is rendered via the WRM during webpack watch mode. Check the readme for usage details.

4.3.0 (March 21, 2019)

  • bugfix: locationPrefix is now added to legacy web-resource inclusions as well.

4.2.0 (March 20, 2019)

  • feature: Added a resourceParamMap configuration option that allows adding <param> blocks to <resource>s.
  • bugfix: the runtime chunk filename now follows the output filename naming pattern (fixes #57).
  • deprecated: The assetContentTypes configuration has been replaced by resourceParamMap.

4.1.0 (February 4, 2019)

  • Assets hash UUID is correctly generated for production (fixes #59).
  • Fixed a bug in watch mode with provided dependencies, dynamic imports, and named chunks.
  • [New] Added a new wrmManifestPath configuration option, which will create a JSON file with a map of web-resource keys and the proper way to import them. This JSON file can be used as an input for the providedDependencies configuration option, which is particularly useful when stringing together interdependent webpack configurations. See README.md for more details on how to make use of this option.

4.0.0 (December 7, 2018)

  • feature: Added a new locationPrefix configuration option, intended to use when webpack's output will be in a sub-directory of the ultimate plugin's root directory.
  • [BREAKING]: The way that compiled output works has changed.
    • No special handling occurs for Maven-based project output directories (i.e., target/classes).
    • It is now assumed that your webpack output is placed in the root of your plugin.
    • If your compiled code is in a sub-directory of your plugin's ultimate root directory, set locationPrefix to point to that sub-directory.

3.3.0 (November 19, 2018)

  • feature: allow to specify state attribute on web-resources.
  • feature: allow to declare wr-dependency! on same-plugin web-resources without explicit plugin key.

3.2.0 (November 12, 2018)

  • Transformations are only added to web-resources that have files with matching extensions (fixes #54).
  • Assets will be added to the correct web-resources when using the mini-css-extract-plugin v0.4.3 and higher (fixes #52).

3.1.0 (November 12, 2018)

  • feature: Allow to completely disable all the transformations by passing a false value to the transformationMap config.
  • [BREAKING]: Passing the custom transformationMap will no longer extend the default transformations.
    • You can use the WrmPlugin.extendTransformations(customTransformationMap) function to extend the default transformers with a custom mapping.

3.0.0 (September 3, 2018)

  • expose "prepare"-step for watch-mode as explicit flag, instead of assuming anything at runtime.
  • remove mandatory "amdProvider"-option again as it is cause of confusion with little to no-benefit.

2.1.0 (June 25, 2018)

  • add support for single runtime chunk (fixes #47).

2.0.0 (June 7, 2018)

  • change api and require "amdProvider" to be provided. This is needed to enable cross-product usage.

1.2.0 (June 7, 2018)

  • add "noWRM" mode to allow development outside of a WRM environment. E.g. standalone frontends later integrated into a product running WRM.

1.1.0 (May 17, 2018)

  • add experimental "standalone" mode which allows for special lib like lean compilations. Mainly removes clutter from the XML-file.

1.0.6 (May 17, 2018)

  • add repository/homepage link to package.json
  • add context-path dependency to base-dependencies to ensure AJS.contextPath is always available

1.0.5 (May 15, 2018)

  • Add almond to base-context to ensure it is always loaded
  • Change sorting for provided dependencies to ensure correct loading order

1.0.3 (April 4, 2018)

  • Ensure "tapable" version via peerDependency.

1.0.3 (April 4, 2018)

  • Rename everything commons-chunks to split chunks

1.0.2 (March 29, 2018)

  • Fixed issue that web-resources might have duplicate keys due to edge case in webpack 4 where split chunks are not getting their chunk name set.

1.0.1 (March 29, 2018)

  • noop version due to network issues during release

1.0.0 (March 29, 2018)

  • Migrate plugin to support webpack 4

0.6.2 (January 15, 2018)

  • bug: fix issue with generated test resources required from async chunks

0.6.1 (January 10, 2018)

  • bug: fix issue where async chunks of async chunks were not correctly considered

0.6.0 (December 18, 2017)

Some more features needed to allow internal adoption.

0.5.0 (December 11, 2017)

The plugin just got a whole lot more modular and module-friendly!

  • refactor: the plugin's behaviour is now composed of multiple smaller modules (closes #21).
  • refactor: cleanup of gitignore files. (@fgdreis in PR #31).
  • bugfix: multiple webpack runtimes on the same page will now work, thanks to the jsonp function being given a unique name per compilation (fixes #23). (@timse2 in PR #23).
  • bugfix: circular dependencies will be handled appropriately -- namely, they won't crash the plugin :P (fixes #29).
  • bugfix: soy templates should be translated correctly, since we now load the i18n transformer at runtime (fixes #26). (@timse2 in PR #25).

0.4.2 (September 11, 2017)

  • bugfix: Common assets extracted via CommonsChunkPlugin are correctly de-duplicated across generated web-resource definitions (fixes #20). (@timse2 in PR #21).

0.4.1 (September 6, 2017)

  • bugfix: Allows NamedModulesPlugin to work correctly (fixes #22). (@timse2 in PR #20).

0.4.0 (September 5, 2017)

  • feature: Legacy QUnit tests that only run during an Atlassian product's runtime are now supported through a (deprecated) configuration option (fixes #12). (@timse2 in PR #12).

The QUnit test bridge is a deprecated feature that will be removed in the v1.0 of this plugin. It is included to provide a graceful rollover period for developers wanting to compile their front-end and keep the assurance of some existing tests around while they refactor to a build-time testing solution.

See the README for how to configure and use this behaviour.

0.3.0 (September 1, 2017)

  • feature: Can load legacy resources with side-effects from an existing Atlassian Plugin's XML using the wrm-resource! loader prefix (addresses #19). ((@timse2 and @chrisdarroch in PR #16).

This feature affords developers a rollover period where they can reference resources from their existing plugin's code in their to-be-compiled code.

By using wrm-resource! and wrm-dependency!, developers will be able to move the canonical dependency graph of their front-end application in to the JavaScript layer. From here, they can be considered a code smell to be refactored away over time by incrementally adopting more plugins and capabilities for ahead-of-time compilation via webpack.

0.2.2 (August 31, 2017)

  • feature: Can provide a plain javascript object for the providedDependencies option.
  • feature: Can explicity name the generated web-resources via the webresourceKeyMap config option (fixes #9). (@chrisdarroch in PR #15).
  • bugfix: Allow to compile directly in to target/classes without warning user (fixes #16) (@timse2 in PR #18).
  • bugfix: Only add assets that belong to a chunk to the chunk (fixes #15, #17). (@timse2 in PR #19).

0.2.1 (July 21, 2017)

  • Stop wr-dependency! import statements from throwing JavaScript exceptions (fixes #11)

0.2.0 (July 21, 2017)

Thanks to @timse2, the plugin has been re-implemented in order to introduce a bunch of sweet behaviours!

  • Can specify multiple WRM contexts for an entrypoint (closes #1)
  • Can inject conditions in to generated web-resources (addresses #2)
  • Support for asynchronous chunks! (addresses #5)
  • Support for bundling non-JavaScript resources like CSS and images! (closes #7)
  • An entrypoint's web-resource dependencies are injected in to the same web-resource instead of a separate one (fixes #3)
  • Reworked support for importing web-resource dependencies; they should now be declared in JavaScript with wr-dependency! prefix. (addresses #13)
  • Reworked support for external dependencies; the correct JavaScript value and WRM dependency will be injected depending on the webpack output config (fixes #6)

The new configuration options for the plugin are as follows:

  • Mapping an entry point to a context is done through the contextMap option. The format is as follows:

    new WrmPlugin({
      contextMap: {
        'entrypoint-name': ['context-A', 'context-B'],
      },
    });
  • Mappings of web-resource keys to external JS dependencies is provided via the providededDependencies option. It accepts an array of javascript objects describing the dependency mapping. The format of these external dependency mappings has changed, too.

    The new external dependency format is plain JavaScript instead of JSON. This allows us a bit more flexibility in the future. The basic format is as follows:

    {
      dependencyKey: {
        dependency: "atlassian.plugin.key:webresource-key",
        import: {
          var: "require('dependency-amd-module-name')",
          amd: "dependency-amd-module-name"
        }
      }
    }

This re-implementation of the plugin necessitates some changes to how it is configured:

  • All options for the plugin are provided in a flat JavaScript object structure; no more options key in the options any more.
  • The Atlassian plugin's full plugin key must be provided to this webpack plugin now via the pluginKey option.
  • The xmlDescriptors configuration option must be an absolute filepath.

Some behaviours have been removed:

  • The ability to provide an external dependenciesFile option is gone.
  • You can no longer specify web-resource dependencies that will be added to every automatically-generated web-resource.
    • The wrmDependencies configuration option is gone.
    • The * mapping in the external dependencies file is gone. Instead, web-resource dependencies should be declared in each entry-point.

Why did the global dependencies behaviour go away (aka: why did we address #13)? Simple: it improves your application's correctness.

The web-resource manager is lenient since dependencies are loaded at runtime. Though useful, this behaviour leads to developers making assumptions about what code will be available to them at runtime, and crucial dependencies are often omitted from their plugin xml. The net effect of this would be that a developer's code would mysteriously stop working. Any number of things could cause this, including:

  • a product's web-resource descriptions changed
  • a page started pulling in different combinations of web-resources or contexts
  • a resource was removed from the superbatch
  • the WRM starts to load resources in a different order

To mitigate the risk of these changes breaking your code, all dependencies for a given part of your app should be discoverable by the compiler. By knowing the dependencies ahead of time, it's possible to make a guarantee that your application code will work no matter where or when it is loaded.

0.1.2 (11 July, 2017)

  • Added automated testing via Bitbucket Pipelines
  • Code cleanup and simplification (@timse2 in PR #1)

0.1.1 (May 1, 2017)

  • First release on npmjs.com

0.1.0 (April 14, 2017)

  • Initial public release