@atlassian/webresource-webpack-plugin 4.10.2-64a2ef2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +20 -0
- package/.eslintrc +72 -0
- package/.nvmrc +1 -0
- package/.prettierrc +6 -0
- package/CHANGELOG.md +318 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +13 -0
- package/README.md +709 -0
- package/RELEASE.md +17 -0
- package/package.json +118 -0
- package/src/AppResources.js +198 -0
- package/src/QUnitTestResources.js +88 -0
- package/src/WebpackHelpers.js +176 -0
- package/src/WebpackRuntimeHelpers.js +7 -0
- package/src/WrmPlugin.js +676 -0
- package/src/defaults/builtInProvidedDependencies.js +22 -0
- package/src/flattenReduce.js +1 -0
- package/src/helpers/options-parser.js +32 -0
- package/src/helpers/provided-dependencies.js +21 -0
- package/src/helpers/string.js +12 -0
- package/src/helpers/web-resource-entrypoints.js +66 -0
- package/src/helpers/web-resource-generator.js +138 -0
- package/src/helpers/web-resource-parser.js +44 -0
- package/src/helpers/xml.js +44 -0
- package/src/logger.js +28 -0
- package/src/mergeMaps.js +32 -0
- package/src/renderCondition.js +29 -0
- package/src/renderTransformation.js +44 -0
- package/src/settings/base-dependencies.js +42 -0
- package/src/shims/qunit-require-shim.js +19 -0
- package/src/types/typedefs.js +50 -0
- package/src/webpack-modules/EmptyExportsModule.js +26 -0
- package/src/webpack-modules/ProvidedExternalDependencyModule.js +30 -0
- package/src/webpack-modules/WrmDependencyModule.js +12 -0
- package/src/webpack-modules/WrmResourceModule.js +33 -0
- package/test/.eslintrc +11 -0
- package/test/unit/ProvidedExternalDependencyModule.test.js +63 -0
- package/test/unit/WebpackHelpers.test.js +37 -0
- package/test/unit/renderCondition.test.js +240 -0
- package/test/unit/renderTransformation.test.js +69 -0
- package/test/unit/webpack-modules/WrmDependencyModule.test.js +24 -0
- package/test/use-cases/.eslintrc +14 -0
- package/test/use-cases/asset-content-type/asset-content-type.test.js +50 -0
- package/test/use-cases/asset-content-type/src/app.js +8 -0
- package/test/use-cases/asset-content-type/src/ice.png +0 -0
- package/test/use-cases/asset-content-type/src/rect.svg +4 -0
- package/test/use-cases/asset-content-type/webpack.config.js +33 -0
- package/test/use-cases/asset-loading-via-js/asset-loading-via-js.test.js +61 -0
- package/test/use-cases/asset-loading-via-js/src/app.js +8 -0
- package/test/use-cases/asset-loading-via-js/src/ice.png +0 -0
- package/test/use-cases/asset-loading-via-js/src/rect.svg +4 -0
- package/test/use-cases/asset-loading-via-js/webpack.config.js +31 -0
- package/test/use-cases/associations-complex/associations-complex.test.js +82 -0
- package/test/use-cases/associations-complex/package-lock.json +73 -0
- package/test/use-cases/associations-complex/package.json +9 -0
- package/test/use-cases/associations-complex/src/copied-file-should-be-ignored.js +0 -0
- package/test/use-cases/associations-complex/src/entry.js +5 -0
- package/test/use-cases/associations-complex/src/entry2.js +5 -0
- package/test/use-cases/associations-complex/src/qunit.tests.js +2 -0
- package/test/use-cases/associations-complex/src/to-be-chunked.js +1 -0
- package/test/use-cases/associations-complex/webpack.config.js +48 -0
- package/test/use-cases/associations-simple/associations-simple.test.js +65 -0
- package/test/use-cases/associations-simple/package-lock.json +69 -0
- package/test/use-cases/associations-simple/package.json +5 -0
- package/test/use-cases/associations-simple/src/simple.js +3 -0
- package/test/use-cases/associations-simple/webpack.config.js +27 -0
- package/test/use-cases/async-chunks/async-chunks.test.js +113 -0
- package/test/use-cases/async-chunks/src/app.js +9 -0
- package/test/use-cases/async-chunks/src/async-bar.js +4 -0
- package/test/use-cases/async-chunks/src/async-foo.js +2 -0
- package/test/use-cases/async-chunks/webpack.config.js +40 -0
- package/test/use-cases/async-chunks-named-context/async-chunks-named-context.test.js +76 -0
- package/test/use-cases/async-chunks-named-context/src/app.js +9 -0
- package/test/use-cases/async-chunks-named-context/src/app2.js +5 -0
- package/test/use-cases/async-chunks-named-context/src/async-async-async-bar.js +4 -0
- package/test/use-cases/async-chunks-named-context/src/async-async-bar-two.js +1 -0
- package/test/use-cases/async-chunks-named-context/src/async-async-bar.js +6 -0
- package/test/use-cases/async-chunks-named-context/src/async-bar.js +7 -0
- package/test/use-cases/async-chunks-named-context/src/async-foo.js +2 -0
- package/test/use-cases/async-chunks-named-context/webpack.config.js +43 -0
- package/test/use-cases/async-chunks-of-async-chunks/async-chunks-of-async-chunks.test.js +117 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/app.js +9 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/async-async-async-bar.js +4 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/async-async-bar-two.js +1 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/async-async-bar.js +6 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/async-bar.js +7 -0
- package/test/use-cases/async-chunks-of-async-chunks/src/async-foo.js +2 -0
- package/test/use-cases/async-chunks-of-async-chunks/webpack.config.js +43 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/async-chunks-of-async-chunks-with-multiple-entrypoints.test.js +156 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/app.js +9 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/app2.js +5 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/async-async-async-bar.js +4 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/async-async-bar-two.js +1 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/async-async-bar.js +6 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/async-bar.js +7 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/src/async-foo.js +2 -0
- package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/webpack.config.js +43 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/css-and-assets-distribution-via-mini-css-extract-plugin.test.js +72 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/app.js +8 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/app2.js +6 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/ice.png +0 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/ice2.jpg +0 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/rect.svg +4 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/rect2.svg +4 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/styles.css +8 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/src/styles2.css +8 -0
- package/test/use-cases/css-and-assets-distribution-via-mini-css-extract-plugin/webpack.config.js +51 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/css-and-assets-via-extract-text-plugin.test.js +87 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/src/feature-one.css +7 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/src/feature-one.js +3 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/src/feature-two.css +3 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/src/feature-two.js +1 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/src/ice.png +0 -0
- package/test/use-cases/css-and-assets-via-extract-text-plugin/webpack.config.js +46 -0
- package/test/use-cases/css-and-assets-via-style-loader/css-and-assets-via-style-loader.test.js +46 -0
- package/test/use-cases/css-and-assets-via-style-loader/src/app.js +6 -0
- package/test/use-cases/css-and-assets-via-style-loader/src/ice.png +0 -0
- package/test/use-cases/css-and-assets-via-style-loader/src/styles.css +7 -0
- package/test/use-cases/css-and-assets-via-style-loader/webpack.config.js +46 -0
- package/test/use-cases/cyclic-dependencies/cyclic.test.js +24 -0
- package/test/use-cases/cyclic-dependencies/src/a.js +3 -0
- package/test/use-cases/cyclic-dependencies/src/b.js +3 -0
- package/test/use-cases/cyclic-dependencies/src/root.js +3 -0
- package/test/use-cases/cyclic-dependencies/webpack.config.js +24 -0
- package/test/use-cases/data-providers/data-providers.test.js +111 -0
- package/test/use-cases/data-providers/src/first.js +2 -0
- package/test/use-cases/data-providers/src/second.js +2 -0
- package/test/use-cases/data-providers/src/third.js +2 -0
- package/test/use-cases/data-providers/webpack.config.js +73 -0
- package/test/use-cases/data-providers/webpack.config.with-map.js +33 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/ensure-runtime-overwrite-of-mini-css-extract-plugin.test.js +86 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/app.js +5 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/app2.js +5 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/ice.png +0 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/ice2.jpg +0 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/rect.svg +4 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/rect2.svg +4 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/styles.css +8 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/src/styles2.css +8 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/webpack.after.config.js +51 -0
- package/test/use-cases/ensure-runtime-overwrite-of-mini-css-extract-plugin/webpack.before.config.js +51 -0
- package/test/use-cases/jsonp-function-name/jsonp-function-name.test.js +37 -0
- package/test/use-cases/jsonp-function-name/src/app.js +1 -0
- package/test/use-cases/jsonp-function-name/src/foo.js +2 -0
- package/test/use-cases/jsonp-function-name/webpack.config.js +35 -0
- package/test/use-cases/jsonp-function-name-default/jsonp-function-name-default.test.js +39 -0
- package/test/use-cases/jsonp-function-name-default/src/app.js +1 -0
- package/test/use-cases/jsonp-function-name-default/src/foo.js +2 -0
- package/test/use-cases/jsonp-function-name-default/webpack.config.js +34 -0
- package/test/use-cases/location-prefix/location-prefix.test.js +29 -0
- package/test/use-cases/location-prefix/src/simple.js +6 -0
- package/test/use-cases/location-prefix/webpack.config.js +25 -0
- package/test/use-cases/provided-module-replacement/provided-module-replacement.test.js +63 -0
- package/test/use-cases/provided-module-replacement/src/app.js +3 -0
- package/test/use-cases/provided-module-replacement/webpack.config.with-map.js +33 -0
- package/test/use-cases/provided-module-replacement/webpack.config.with-object.js +34 -0
- package/test/use-cases/provided-modules-replacement-with-amd-target/provided-modules-replacement-with-amd-target.test.js +62 -0
- package/test/use-cases/provided-modules-replacement-with-amd-target/src/app.js +3 -0
- package/test/use-cases/provided-modules-replacement-with-amd-target/webpack.config.js +41 -0
- package/test/use-cases/qunit-test-wrm-web-resource/qunit-test-wrm-web-resource.test.js +157 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/app.2.js +6 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/app.js +8 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/bar-dep.js +8 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/bar-dep_test.js +1 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/foo-async.js +3 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/foo-dep.js +4 -0
- package/test/use-cases/qunit-test-wrm-web-resource/src/foo-dep_test.js +1 -0
- package/test/use-cases/qunit-test-wrm-web-resource/webpack.config.js +24 -0
- package/test/use-cases/resource-parameters/resource-parameters.test.js +77 -0
- package/test/use-cases/resource-parameters/src/app.js +12 -0
- package/test/use-cases/resource-parameters/src/ice.png +0 -0
- package/test/use-cases/resource-parameters/src/ice2.jpg +0 -0
- package/test/use-cases/resource-parameters/src/rect.svg +4 -0
- package/test/use-cases/resource-parameters/webpack.config.js +62 -0
- package/test/use-cases/resource-parameters/webpack.svg.config.js +30 -0
- package/test/use-cases/simple/simple.test.js +83 -0
- package/test/use-cases/simple/src/simple.js +3 -0
- package/test/use-cases/simple/webpack.config.js +24 -0
- package/test/use-cases/single-runtime-chunk/single-runtime-chunk.test.js +132 -0
- package/test/use-cases/single-runtime-chunk/src/first.js +2 -0
- package/test/use-cases/single-runtime-chunk/src/second.js +2 -0
- package/test/use-cases/single-runtime-chunk/src/shared.js +3 -0
- package/test/use-cases/single-runtime-chunk/src/third.js +2 -0
- package/test/use-cases/single-runtime-chunk/webpack.config.js +33 -0
- package/test/use-cases/specify-asset-dev-hash/specify-asset-dev-hash.test.js +33 -0
- package/test/use-cases/specify-asset-dev-hash/src/feature.js +6 -0
- package/test/use-cases/specify-asset-dev-hash/src/library.js +6 -0
- package/test/use-cases/specify-asset-dev-hash/webpack.config.js +71 -0
- package/test/use-cases/specify-conditions/specify-conditions.test.js +106 -0
- package/test/use-cases/specify-conditions/src/app.js +5 -0
- package/test/use-cases/specify-conditions/webpack.config.js +65 -0
- package/test/use-cases/specify-explicit-context/specify-explicit-context.test.js +89 -0
- package/test/use-cases/specify-explicit-context/src/app.js +5 -0
- package/test/use-cases/specify-explicit-context/webpack.config.js +34 -0
- package/test/use-cases/specify-explicit-context-no-autogenerated/specify-explicit-context-no-autogenerated.test.js +84 -0
- package/test/use-cases/specify-explicit-context-no-autogenerated/src/app.js +5 -0
- package/test/use-cases/specify-explicit-context-no-autogenerated/webpack.config.js +35 -0
- package/test/use-cases/specify-explicit-name/specify-explicit-name.test.js +110 -0
- package/test/use-cases/specify-explicit-name/src/app.js +5 -0
- package/test/use-cases/specify-explicit-name/webpack.config.js +43 -0
- package/test/use-cases/specify-explicit-state/specify-explicit-state.test.js +96 -0
- package/test/use-cases/specify-explicit-state/src/app.js +5 -0
- package/test/use-cases/specify-explicit-state/webpack.config.js +51 -0
- package/test/use-cases/specify-transformation/disable-transformations.test.js +77 -0
- package/test/use-cases/specify-transformation/extend-transformations.test.js +69 -0
- package/test/use-cases/specify-transformation/specify-transformation.test.js +100 -0
- package/test/use-cases/specify-transformation/src/app.js +13 -0
- package/test/use-cases/specify-transformation/src/ice.png +0 -0
- package/test/use-cases/specify-transformation/src/rect.svg +4 -0
- package/test/use-cases/specify-transformation/src/test.html +1 -0
- package/test/use-cases/specify-transformation/src/test.less +1 -0
- package/test/use-cases/specify-transformation/src/test.txt +1 -0
- package/test/use-cases/specify-transformation/webpack.disable-tranformations.config.js +31 -0
- package/test/use-cases/specify-transformation/webpack.extend-tranformations.config.js +34 -0
- package/test/use-cases/specify-transformation/webpack.specify-transformations.config.js +35 -0
- package/test/use-cases/split-chunks/split-chunks.test.js +102 -0
- package/test/use-cases/split-chunks/src/app.js +7 -0
- package/test/use-cases/split-chunks/src/app2.js +7 -0
- package/test/use-cases/split-chunks/src/bar.js +2 -0
- package/test/use-cases/split-chunks/src/foo.js +2 -0
- package/test/use-cases/split-chunks/src/foo2.js +2 -0
- package/test/use-cases/split-chunks/webpack.config.js +42 -0
- package/test/use-cases/split-chunks-with-runtime/split-chunks-with-runtime.test.js +114 -0
- package/test/use-cases/split-chunks-with-runtime/src/app.js +7 -0
- package/test/use-cases/split-chunks-with-runtime/src/app2.js +7 -0
- package/test/use-cases/split-chunks-with-runtime/src/bar.js +2 -0
- package/test/use-cases/split-chunks-with-runtime/src/foo.js +2 -0
- package/test/use-cases/split-chunks-with-runtime/src/foo2.js +2 -0
- package/test/use-cases/split-chunks-with-runtime/webpack.config.js +43 -0
- package/test/use-cases/split-chunks-with-tests/split-chunks-with-tests.test.js +216 -0
- package/test/use-cases/split-chunks-with-tests/src/app.js +7 -0
- package/test/use-cases/split-chunks-with-tests/src/app2.js +7 -0
- package/test/use-cases/split-chunks-with-tests/src/bar.js +2 -0
- package/test/use-cases/split-chunks-with-tests/src/bar_test.js +1 -0
- package/test/use-cases/split-chunks-with-tests/src/foo.js +2 -0
- package/test/use-cases/split-chunks-with-tests/src/foo2.js +2 -0
- package/test/use-cases/split-chunks-with-tests/src/foo_test.js +1 -0
- package/test/use-cases/split-chunks-with-tests/webpack.config.js +43 -0
- package/test/use-cases/standalone/src/standalone-1.js +1 -0
- package/test/use-cases/standalone/src/standalone-2.js +1 -0
- package/test/use-cases/standalone/standalone.test.js +53 -0
- package/test/use-cases/standalone/webpack.config.js +25 -0
- package/test/use-cases/wrm-dependency-loading/src-amd/app.js +7 -0
- package/test/use-cases/wrm-dependency-loading/src-es6/app.js +7 -0
- package/test/use-cases/wrm-dependency-loading/webpack.config.amd.js +22 -0
- package/test/use-cases/wrm-dependency-loading/webpack.config.es6.js +22 -0
- package/test/use-cases/wrm-dependency-loading/wrm-dependency-loading.test.js +60 -0
- package/test/use-cases/wrm-manifest-path/src/a.js +3 -0
- package/test/use-cases/wrm-manifest-path/src/app.js +3 -0
- package/test/use-cases/wrm-manifest-path/src/app2.js +3 -0
- package/test/use-cases/wrm-manifest-path/src/b.js +3 -0
- package/test/use-cases/wrm-manifest-path/webpack.config.js +27 -0
- package/test/use-cases/wrm-manifest-path/wrm-manifest-path.test.js +57 -0
- package/test/use-cases/wrm-resource-loading/src-amd/app.js +6 -0
- package/test/use-cases/wrm-resource-loading/src-es6/app.js +5 -0
- package/test/use-cases/wrm-resource-loading/src-relative/app.js +5 -0
- package/test/use-cases/wrm-resource-loading/webpack.config.amd.js +23 -0
- package/test/use-cases/wrm-resource-loading/webpack.config.es6.js +23 -0
- package/test/use-cases/wrm-resource-loading/webpack.config.relative.js +23 -0
- package/test/use-cases/wrm-resource-loading/wrm-resource-loading.test.js +89 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const ExternalModule = require('webpack/lib/ExternalModule');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ProvidedExternalModule ensures that the `chunkCondition` is true to allow proper asyncChunk context handling
|
|
5
|
+
* ExternalModules can be defined in different ways. Some of them require the external module to be loaded in the entry point.
|
|
6
|
+
* This is generally not bad as it doesnt cost anything. However the WRM Plugin relies on ExternalModules to specify provided dependencies.
|
|
7
|
+
* These provided dependencies are then added to the context of the chunk in which they occur. Async chunks should therefore
|
|
8
|
+
* have their own dependencies to make the entrypoint as small as possible.
|
|
9
|
+
* ProvidedExternalModule ensures that.
|
|
10
|
+
*/
|
|
11
|
+
module.exports = class ProvidedExternalDependencyModule extends ExternalModule {
|
|
12
|
+
constructor(request, dependency, target) {
|
|
13
|
+
super(request, target);
|
|
14
|
+
this._request = request;
|
|
15
|
+
this._dependency = dependency;
|
|
16
|
+
this._target = target;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
libIdent() {
|
|
20
|
+
return `${this._dependency}/${this._request[this._target]}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
chunkCondition() {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getDependency() {
|
|
28
|
+
return this._dependency;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const EmptyExportsModule = require('./EmptyExportsModule');
|
|
2
|
+
|
|
3
|
+
module.exports = class extends EmptyExportsModule {
|
|
4
|
+
constructor(dependency, type, pluginKey) {
|
|
5
|
+
super(dependency, type);
|
|
6
|
+
this._dependency = dependency.includes(':') ? dependency : `${pluginKey}:${dependency}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getDependency() {
|
|
10
|
+
return this._dependency;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const EmptyExportsModule = require('./EmptyExportsModule');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
module.exports = class extends EmptyExportsModule {
|
|
5
|
+
constructor(resourceNameAndLocationPair, target, requestContext, rootContext) {
|
|
6
|
+
super(resourceNameAndLocationPair, target);
|
|
7
|
+
const resourcePair = resourceNameAndLocationPair.split('!');
|
|
8
|
+
let resPath = resourcePair[1];
|
|
9
|
+
|
|
10
|
+
// enable relative resource-paths. Still requires that this resource is correctly copied to the right location in target.
|
|
11
|
+
if (resPath.startsWith('./') || resPath.startsWith('../')) {
|
|
12
|
+
const fullResourcePath = path.join(requestContext, resPath);
|
|
13
|
+
resPath = path.relative(rootContext, fullResourcePath);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this._resource = [resourcePair[0], resPath];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @returns {{0:filename,1:filepath}} an array containing the resource's name and location
|
|
21
|
+
*/
|
|
22
|
+
getResourcePair() {
|
|
23
|
+
return this._resource;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @returns {Resource} the resource
|
|
28
|
+
*/
|
|
29
|
+
getResource() {
|
|
30
|
+
const [name, location] = this._resource;
|
|
31
|
+
return { name, location };
|
|
32
|
+
}
|
|
33
|
+
};
|
package/test/.eslintrc
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
|
|
3
|
+
const ProvidedExternalDependencyModule = require('../../src/webpack-modules/ProvidedExternalDependencyModule');
|
|
4
|
+
|
|
5
|
+
describe('ProvidedExternalDependencyModule', () => {
|
|
6
|
+
describe('libIdent', () => {
|
|
7
|
+
it("should specify a 'libIdent' method used by webpack to create a unique id", () => {
|
|
8
|
+
const pedm = new ProvidedExternalDependencyModule({ amd: 'something' }, 'some-dependency', 'amd');
|
|
9
|
+
assert.ok(pedm.libIdent(), 'libIdent did not return a valid value');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should create deterministic ids based on specified params', () => {
|
|
13
|
+
const firstProvidedModule = new ProvidedExternalDependencyModule(
|
|
14
|
+
{ amd: 'something' },
|
|
15
|
+
'some-dependency',
|
|
16
|
+
'amd'
|
|
17
|
+
);
|
|
18
|
+
const secondProvidedModule = new ProvidedExternalDependencyModule(
|
|
19
|
+
{ amd: 'something' },
|
|
20
|
+
'some-dependency',
|
|
21
|
+
'amd'
|
|
22
|
+
);
|
|
23
|
+
assert.strictEqual(
|
|
24
|
+
firstProvidedModule.libIdent(),
|
|
25
|
+
secondProvidedModule.libIdent(),
|
|
26
|
+
'libIdent did not return the expected values'
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return a unique value for unique constructor params', () => {
|
|
31
|
+
const firstProvidedModule = new ProvidedExternalDependencyModule(
|
|
32
|
+
{ amd: 'something' },
|
|
33
|
+
'some-dependency',
|
|
34
|
+
'amd'
|
|
35
|
+
);
|
|
36
|
+
const secondProvidedModule = new ProvidedExternalDependencyModule(
|
|
37
|
+
{ amd: 'something-else' },
|
|
38
|
+
'some-dependency',
|
|
39
|
+
'amd'
|
|
40
|
+
);
|
|
41
|
+
const thirdProvidedModule = new ProvidedExternalDependencyModule(
|
|
42
|
+
{ amd: 'something' },
|
|
43
|
+
'some-other-dependency',
|
|
44
|
+
'amd'
|
|
45
|
+
);
|
|
46
|
+
assert.notStrictEqual(
|
|
47
|
+
firstProvidedModule.libIdent(),
|
|
48
|
+
secondProvidedModule.libIdent(),
|
|
49
|
+
'unexpected matching libIdent values'
|
|
50
|
+
);
|
|
51
|
+
assert.notStrictEqual(
|
|
52
|
+
firstProvidedModule.libIdent(),
|
|
53
|
+
thirdProvidedModule.libIdent(),
|
|
54
|
+
'unexpected matching libIdent values'
|
|
55
|
+
);
|
|
56
|
+
assert.notStrictEqual(
|
|
57
|
+
secondProvidedModule.libIdent(),
|
|
58
|
+
thirdProvidedModule.libIdent(),
|
|
59
|
+
'unexpected matching libIdent values'
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
|
|
3
|
+
const WebpackHelpers = require('../../src/WebpackHelpers');
|
|
4
|
+
const env = Object.assign({}, process.env);
|
|
5
|
+
|
|
6
|
+
const stubCompiler = mode => ({ options: { mode } });
|
|
7
|
+
|
|
8
|
+
describe('isRunningInProductionMode', () => {
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
process.env = env;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('determines production mode from compiler settings', function() {
|
|
14
|
+
assert.equal(
|
|
15
|
+
WebpackHelpers.isRunningInProductionMode(stubCompiler('production')),
|
|
16
|
+
true,
|
|
17
|
+
'production environment not detected properly'
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('returns false if mode is different than production', function() {
|
|
22
|
+
assert.equal(
|
|
23
|
+
WebpackHelpers.isRunningInProductionMode(stubCompiler('')),
|
|
24
|
+
false,
|
|
25
|
+
'it should not detect production environment'
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('fallbacks to node.env when mode set to none', function() {
|
|
30
|
+
process.env.NODE_ENV = 'production';
|
|
31
|
+
assert.equal(
|
|
32
|
+
WebpackHelpers.isRunningInProductionMode(stubCompiler('none')),
|
|
33
|
+
true,
|
|
34
|
+
'production environment not detected properly'
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
const PrettyData = require('pretty-data').pd;
|
|
3
|
+
|
|
4
|
+
const renderCondition = require('../../src/renderCondition');
|
|
5
|
+
|
|
6
|
+
describe('renderCondition', () => {
|
|
7
|
+
describe('should correctly render condition', () => {
|
|
8
|
+
it('simple condition', () => {
|
|
9
|
+
const conditionString = PrettyData.xml(renderCondition({ class: 'foo.bar' }));
|
|
10
|
+
assert.equal(conditionString, '<condition class="foo.bar" />');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('invert condition', () => {
|
|
14
|
+
const conditionString = PrettyData.xml(renderCondition({ class: 'foo.bar', invert: true }));
|
|
15
|
+
assert.equal(conditionString, '<condition class="foo.bar" invert="true"/>');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('with params', () => {
|
|
19
|
+
it('renders param correctly', () => {
|
|
20
|
+
const conditionString = PrettyData.xml(
|
|
21
|
+
renderCondition({ class: 'foo.bar', invert: true, params: [{}] })
|
|
22
|
+
);
|
|
23
|
+
assert.equal(
|
|
24
|
+
conditionString,
|
|
25
|
+
`
|
|
26
|
+
<condition class="foo.bar" invert="true">
|
|
27
|
+
<param/>
|
|
28
|
+
</condition>
|
|
29
|
+
`.trim()
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders param with value correctly', () => {
|
|
34
|
+
const conditionString = PrettyData.xml(
|
|
35
|
+
renderCondition({ class: 'foo.bar', invert: true, params: [{ value: 'foo' }] })
|
|
36
|
+
);
|
|
37
|
+
assert.equal(
|
|
38
|
+
conditionString,
|
|
39
|
+
`
|
|
40
|
+
<condition class="foo.bar" invert="true">
|
|
41
|
+
<param>foo</param>
|
|
42
|
+
</condition>
|
|
43
|
+
`.trim()
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders param with attributes correctly', () => {
|
|
48
|
+
const conditionString = PrettyData.xml(
|
|
49
|
+
renderCondition({
|
|
50
|
+
class: 'foo.bar',
|
|
51
|
+
invert: true,
|
|
52
|
+
params: [{ attributes: { foo: 'bar', faz: 'baz' } }],
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
assert.equal(
|
|
56
|
+
conditionString,
|
|
57
|
+
`
|
|
58
|
+
<condition class="foo.bar" invert="true">
|
|
59
|
+
<param foo="bar" faz="baz"/>
|
|
60
|
+
</condition>
|
|
61
|
+
`.trim()
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('renders param with attributes and values correctly', () => {
|
|
66
|
+
const conditionString = PrettyData.xml(
|
|
67
|
+
renderCondition({
|
|
68
|
+
class: 'foo.bar',
|
|
69
|
+
invert: true,
|
|
70
|
+
params: [{ attributes: { foo: 'bar', faz: 'baz' }, value: 'more foo' }],
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
assert.equal(
|
|
74
|
+
conditionString,
|
|
75
|
+
`
|
|
76
|
+
<condition class="foo.bar" invert="true">
|
|
77
|
+
<param foo="bar" faz="baz">more foo</param>
|
|
78
|
+
</condition>
|
|
79
|
+
`.trim()
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renders multiple params correctly', () => {
|
|
84
|
+
const conditionString = PrettyData.xml(
|
|
85
|
+
renderCondition({
|
|
86
|
+
class: 'foo.bar',
|
|
87
|
+
invert: true,
|
|
88
|
+
params: [
|
|
89
|
+
{ attributes: { foo: 'bar', faz: 'baz' }, value: 'more foo' },
|
|
90
|
+
{ attributes: { foo2: 'bar2' }, value: 'more foo2' },
|
|
91
|
+
],
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
assert.equal(
|
|
95
|
+
conditionString,
|
|
96
|
+
`
|
|
97
|
+
<condition class="foo.bar" invert="true">
|
|
98
|
+
<param foo="bar" faz="baz">more foo</param>
|
|
99
|
+
<param foo2="bar2">more foo2</param>
|
|
100
|
+
</condition>
|
|
101
|
+
`.trim()
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('multiple conditions with params', () => {
|
|
107
|
+
const conditionString = PrettyData.xml(
|
|
108
|
+
renderCondition([
|
|
109
|
+
{
|
|
110
|
+
class: 'foo.bar',
|
|
111
|
+
invert: true,
|
|
112
|
+
params: [
|
|
113
|
+
{ attributes: { foo: 'bar', faz: 'baz' }, value: 'more foo' },
|
|
114
|
+
{ attributes: { foo2: 'bar2' }, value: 'more foo2' },
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
class: 'foo.bar.baz',
|
|
119
|
+
invert: true,
|
|
120
|
+
params: [
|
|
121
|
+
{ attributes: { foo: 'bar', faz: 'baz' }, value: 'more foo' },
|
|
122
|
+
{ attributes: { foo2: 'bar2' }, value: 'more foo2' },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
])
|
|
126
|
+
);
|
|
127
|
+
assert.equal(
|
|
128
|
+
conditionString,
|
|
129
|
+
`
|
|
130
|
+
<condition class="foo.bar" invert="true">
|
|
131
|
+
<param foo="bar" faz="baz">more foo</param>
|
|
132
|
+
<param foo2="bar2">more foo2</param>
|
|
133
|
+
</condition>
|
|
134
|
+
<condition class="foo.bar.baz" invert="true">
|
|
135
|
+
<param foo="bar" faz="baz">more foo</param>
|
|
136
|
+
<param foo2="bar2">more foo2</param>
|
|
137
|
+
</condition>
|
|
138
|
+
`.trim()
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('should correctly render conditions', () => {
|
|
144
|
+
it('simple conditions', () => {
|
|
145
|
+
const conditionString = PrettyData.xml(
|
|
146
|
+
renderCondition({
|
|
147
|
+
type: 'AND',
|
|
148
|
+
conditions: [],
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
assert.equal(conditionString, '<conditions type="AND"/>');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('renders conditions inside correctly', () => {
|
|
155
|
+
const conditionString = PrettyData.xml(
|
|
156
|
+
renderCondition({
|
|
157
|
+
type: 'AND',
|
|
158
|
+
conditions: [{ class: 'foo.bar', invert: true }],
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
assert.equal(
|
|
162
|
+
conditionString,
|
|
163
|
+
`
|
|
164
|
+
<conditions type="AND">
|
|
165
|
+
<condition class="foo.bar" invert="true"/>
|
|
166
|
+
</conditions>
|
|
167
|
+
`.trim()
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('renders multiple conditions inside correctly', () => {
|
|
172
|
+
const conditionString = PrettyData.xml(
|
|
173
|
+
renderCondition({
|
|
174
|
+
type: 'AND',
|
|
175
|
+
conditions: [
|
|
176
|
+
{ class: 'foo.bar', invert: true },
|
|
177
|
+
{ class: 'foo.bar', invert: true },
|
|
178
|
+
{ class: 'foo.bar', invert: true },
|
|
179
|
+
],
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
assert.equal(
|
|
183
|
+
conditionString,
|
|
184
|
+
`
|
|
185
|
+
<conditions type="AND">
|
|
186
|
+
<condition class="foo.bar" invert="true"/>
|
|
187
|
+
<condition class="foo.bar" invert="true"/>
|
|
188
|
+
<condition class="foo.bar" invert="true"/>
|
|
189
|
+
</conditions>
|
|
190
|
+
`.trim()
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('renders complex nested conditions correctly', () => {
|
|
195
|
+
const conditionString = PrettyData.xml(
|
|
196
|
+
renderCondition({
|
|
197
|
+
type: 'AND',
|
|
198
|
+
conditions: [
|
|
199
|
+
{
|
|
200
|
+
type: 'OR',
|
|
201
|
+
conditions: [
|
|
202
|
+
{
|
|
203
|
+
class: 'foo.bar.baz',
|
|
204
|
+
invert: true,
|
|
205
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
class: 'foo.bar.baz2',
|
|
209
|
+
params: [{ attributes: { name: 'permission' }, value: 'project' }],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
class: 'foo.bar.baz3',
|
|
215
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
assert.equal(
|
|
221
|
+
conditionString,
|
|
222
|
+
`
|
|
223
|
+
<conditions type="AND">
|
|
224
|
+
<conditions type="OR">
|
|
225
|
+
<condition class="foo.bar.baz" invert="true">
|
|
226
|
+
<param name="permission">admin</param>
|
|
227
|
+
</condition>
|
|
228
|
+
<condition class="foo.bar.baz2" >
|
|
229
|
+
<param name="permission">project</param>
|
|
230
|
+
</condition>
|
|
231
|
+
</conditions>
|
|
232
|
+
<condition class="foo.bar.baz3" >
|
|
233
|
+
<param name="permission">admin</param>
|
|
234
|
+
</condition>
|
|
235
|
+
</conditions>
|
|
236
|
+
`.trim()
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
const PrettyData = require('pretty-data').pd;
|
|
3
|
+
|
|
4
|
+
const renderTransformation = require('../../src/renderTransformation');
|
|
5
|
+
|
|
6
|
+
describe('renderTransformer', () => {
|
|
7
|
+
it('simple transformation', () => {
|
|
8
|
+
const transformations = { js: ['jsI18n'] };
|
|
9
|
+
const conditionString = renderTransformation(transformations);
|
|
10
|
+
assert.equal(
|
|
11
|
+
PrettyData.xml(conditionString),
|
|
12
|
+
`
|
|
13
|
+
<transformation extension="js">
|
|
14
|
+
<transformer key="jsI18n"/>
|
|
15
|
+
</transformation>
|
|
16
|
+
`.trim()
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('multiple transformers', () => {
|
|
21
|
+
const transformations = {
|
|
22
|
+
js: ['jsI18n'],
|
|
23
|
+
soy: ['soyTransformer', 'jsI18n'],
|
|
24
|
+
less: ['lessTransformer'],
|
|
25
|
+
};
|
|
26
|
+
const conditionString = renderTransformation(transformations);
|
|
27
|
+
assert.equal(
|
|
28
|
+
PrettyData.xml(conditionString),
|
|
29
|
+
`
|
|
30
|
+
<transformation extension="js">
|
|
31
|
+
<transformer key="jsI18n"/>
|
|
32
|
+
</transformation>
|
|
33
|
+
<transformation extension="soy">
|
|
34
|
+
<transformer key="soyTransformer"/>
|
|
35
|
+
<transformer key="jsI18n"/>
|
|
36
|
+
</transformation>
|
|
37
|
+
<transformation extension="less">
|
|
38
|
+
<transformer key="lessTransformer"/>
|
|
39
|
+
</transformation>
|
|
40
|
+
`.trim()
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('contextual transformers', () => {
|
|
45
|
+
const transformations = {
|
|
46
|
+
js: ['js-one', 'js-two', 'js-three'],
|
|
47
|
+
soy: ['soy-one', 'soy-two'],
|
|
48
|
+
less: ['less-one', 'less-two'],
|
|
49
|
+
png: ['png-one'],
|
|
50
|
+
};
|
|
51
|
+
const resources = [{ location: 'a.js' }, { location: 'b.not.really.soy.actually.js' }, { location: 'c.less' }];
|
|
52
|
+
const conditionString = renderTransformation(transformations, resources);
|
|
53
|
+
|
|
54
|
+
assert.equal(
|
|
55
|
+
PrettyData.xml(conditionString),
|
|
56
|
+
`
|
|
57
|
+
<transformation extension="js">
|
|
58
|
+
<transformer key="js-one"/>
|
|
59
|
+
<transformer key="js-two"/>
|
|
60
|
+
<transformer key="js-three"/>
|
|
61
|
+
</transformation>
|
|
62
|
+
<transformation extension="less">
|
|
63
|
+
<transformer key="less-one"/>
|
|
64
|
+
<transformer key="less-two"/>
|
|
65
|
+
</transformation>
|
|
66
|
+
`.trim()
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
|
|
3
|
+
const WrmDependencyModule = require('../../../src/webpack-modules/WrmDependencyModule');
|
|
4
|
+
|
|
5
|
+
describe('WrmDependencyModule', () => {
|
|
6
|
+
const type = 'static';
|
|
7
|
+
const resourceKey = 'my.atlassian.plugin';
|
|
8
|
+
|
|
9
|
+
it('should accept valid web-resource key', () => {
|
|
10
|
+
const dependency = `${resourceKey}:my-web-resource`;
|
|
11
|
+
const module = new WrmDependencyModule(dependency, type, resourceKey);
|
|
12
|
+
assert.equal(module.getDependency(), dependency);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should add resource key when ":" is missing', () => {
|
|
16
|
+
const firstDependency = 'my-web-resource';
|
|
17
|
+
const firstModule = new WrmDependencyModule(firstDependency, type, resourceKey);
|
|
18
|
+
assert.equal(firstModule.getDependency(), `${resourceKey}:${firstDependency}`);
|
|
19
|
+
|
|
20
|
+
const secondDependency = 'my.web.resource';
|
|
21
|
+
const secondModule = new WrmDependencyModule(secondDependency, type, resourceKey);
|
|
22
|
+
assert.equal(secondModule.getDependency(), `${resourceKey}:${secondDependency}`);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
const parse = require('xml-parser');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const targetDir = path.join(__dirname, 'target');
|
|
8
|
+
const webresourceOutput = path.join(targetDir, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml');
|
|
9
|
+
|
|
10
|
+
describe('asset-content-type', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let assets;
|
|
15
|
+
let resources;
|
|
16
|
+
|
|
17
|
+
beforeEach(done => {
|
|
18
|
+
webpack(config, (err, st) => {
|
|
19
|
+
stats = st;
|
|
20
|
+
|
|
21
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
22
|
+
const results = parse(xmlFile);
|
|
23
|
+
assets = results.root.children.find(n => n.attributes.key.startsWith('assets'));
|
|
24
|
+
resources = assets.children.filter(n => n.name === 'resource');
|
|
25
|
+
done();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should create an "asset"-webresource containing the asset', () => {
|
|
30
|
+
assert.ok(assets);
|
|
31
|
+
assert.equal(stats.hasErrors(), false);
|
|
32
|
+
assert.equal(stats.hasWarnings(), false);
|
|
33
|
+
assert.equal(resources[0].attributes.type, 'download');
|
|
34
|
+
assert.equal(path.extname(resources[0].attributes.name), '.png');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should add all assets to the "asset"-webresource', () => {
|
|
38
|
+
assert.ok(assets);
|
|
39
|
+
assert.equal(stats.hasErrors(), false);
|
|
40
|
+
assert.equal(stats.hasWarnings(), false);
|
|
41
|
+
assert.equal(resources.length, 2);
|
|
42
|
+
assert.equal(resources[0].attributes.type, 'download');
|
|
43
|
+
assert.equal(path.extname(resources[0].attributes.name), '.png');
|
|
44
|
+
assert.equal(resources[1].attributes.type, 'download');
|
|
45
|
+
assert.equal(path.extname(resources[1].attributes.name), '.svg');
|
|
46
|
+
assert.equal(resources[1].children.length, 1, 'should contain a "param" child.');
|
|
47
|
+
assert.equal(resources[1].children[0].attributes.name, 'content-type', 'Type of param.');
|
|
48
|
+
assert.equal(resources[1].children[0].attributes.value, 'image/svg+xml', 'Value of param.');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src');
|
|
4
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: {
|
|
9
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.(png|svg)$/,
|
|
15
|
+
loader: 'file-loader',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
new WrmPlugin({
|
|
21
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
22
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
23
|
+
verbose: false,
|
|
24
|
+
assetContentTypes: {
|
|
25
|
+
svg: 'image/svg+xml',
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
output: {
|
|
30
|
+
filename: '[name].js',
|
|
31
|
+
path: OUTPUT_DIR,
|
|
32
|
+
},
|
|
33
|
+
};
|