@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,83 @@
|
|
|
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('simple', function() {
|
|
11
|
+
let config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
it('compiles an xml file', done => {
|
|
14
|
+
webpack(config, (err, stats) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
assert.equal(stats.hasErrors(), false);
|
|
19
|
+
assert.equal(stats.hasWarnings(), false);
|
|
20
|
+
assert.equal(fs.existsSync(webresourceOutput), true);
|
|
21
|
+
done();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('a web-resource for a webpack entry point', function() {
|
|
26
|
+
let results, contextEntryNode;
|
|
27
|
+
|
|
28
|
+
before(done => {
|
|
29
|
+
webpack(config, (err, stats) => {
|
|
30
|
+
let xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
31
|
+
results = parse(xmlFile);
|
|
32
|
+
contextEntryNode = results.root.children.find(n => n.attributes.key === 'entrypoint-simple-entry');
|
|
33
|
+
done();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('exists', () => {
|
|
38
|
+
assert.typeOf(contextEntryNode, 'object');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('has an i18n transformation', () => {
|
|
42
|
+
let node = contextEntryNode.children[0];
|
|
43
|
+
assert.nestedPropertyVal(node, 'name', 'transformation');
|
|
44
|
+
assert.nestedPropertyVal(node, 'attributes.extension', 'js');
|
|
45
|
+
assert.nestedPropertyVal(node, 'children[0].name', 'transformer');
|
|
46
|
+
assert.nestedPropertyVal(node, 'children[0].attributes.key', 'jsI18n');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// @deprecated
|
|
50
|
+
it('has a context named after the entry point', () => {
|
|
51
|
+
let node = contextEntryNode.children
|
|
52
|
+
.filter(n => n.name === 'context')
|
|
53
|
+
.find(n => n.content === 'simple-entry');
|
|
54
|
+
assert.nestedPropertyVal(node, 'name', 'context');
|
|
55
|
+
assert.nestedPropertyVal(node, 'content', 'simple-entry');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('has a resource that references the generated bundle file', () => {
|
|
59
|
+
let node = contextEntryNode.children.find(n => n.name === 'resource');
|
|
60
|
+
assert.nestedPropertyVal(node, 'name', 'resource');
|
|
61
|
+
assert.nestedPropertyVal(node, 'attributes.type', 'download');
|
|
62
|
+
assert.nestedPropertyVal(node, 'attributes.name', 'simple-entry.js');
|
|
63
|
+
assert.nestedPropertyVal(node, 'attributes.location', 'simple-entry.js');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('a web-resource for the (web-resource) deps of an entry point', function() {
|
|
68
|
+
let results, contextDepsNode;
|
|
69
|
+
|
|
70
|
+
before(done => {
|
|
71
|
+
webpack(config, (err, stats) => {
|
|
72
|
+
let xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
73
|
+
results = parse(xmlFile);
|
|
74
|
+
contextDepsNode = results.root.children.find(n => n.attributes.key === 'entrypoint-simple-entry');
|
|
75
|
+
done();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('exists', () => {
|
|
80
|
+
assert.typeOf(contextDepsNode, 'object');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.resolve(__dirname, 'src');
|
|
4
|
+
const OUTPUT_DIR = path.resolve(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
context: FRONTEND_SRC_DIR,
|
|
9
|
+
entry: {
|
|
10
|
+
'simple-entry': path.join(FRONTEND_SRC_DIR, 'simple.js'),
|
|
11
|
+
},
|
|
12
|
+
plugins: [
|
|
13
|
+
new WrmPlugin({
|
|
14
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
15
|
+
contextMap: { 'simple-entry': [''] },
|
|
16
|
+
xmlDescriptors: path.join(__dirname, 'target', 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
17
|
+
verbose: false,
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
output: {
|
|
21
|
+
filename: '[name].js',
|
|
22
|
+
path: path.resolve(OUTPUT_DIR),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
const { setBaseDependencies } = require('../../../src/settings/base-dependencies');
|
|
7
|
+
const RUNTIME_WR_KEY = 'common-runtime';
|
|
8
|
+
const targetDir = path.join(__dirname, 'target');
|
|
9
|
+
const webresourceOutput = path.join(targetDir, 'META-INF', 'plugin-descriptor', 'wr-single.xml');
|
|
10
|
+
|
|
11
|
+
describe('single runtime chunk', function() {
|
|
12
|
+
const baseConfig = require('./webpack.config.js');
|
|
13
|
+
const PLUGIN_KEY = 'com.atlassian.plugin.test';
|
|
14
|
+
const BASE_DEPS = ['base.context:dep1', 'base.context:dep2'];
|
|
15
|
+
|
|
16
|
+
function getResources(node) {
|
|
17
|
+
return node.children.filter(n => n.name === 'resource');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getDependencies(node) {
|
|
21
|
+
return node.children.filter(n => n.name === 'dependency');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function runTheTestsFor(config, runtimeName, runtimeWrKey) {
|
|
25
|
+
let wrNodes;
|
|
26
|
+
runtimeWrKey = runtimeWrKey || RUNTIME_WR_KEY;
|
|
27
|
+
|
|
28
|
+
before(function(done) {
|
|
29
|
+
setBaseDependencies(BASE_DEPS);
|
|
30
|
+
|
|
31
|
+
webpack(config, (err, st) => {
|
|
32
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
33
|
+
const results = parse(xmlFile);
|
|
34
|
+
wrNodes = results.root.children.filter(n => n.name === 'web-resource');
|
|
35
|
+
done();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('creates a web-resource for the runtime', function() {
|
|
40
|
+
const wrKeys = wrNodes.map(n => n.attributes.key);
|
|
41
|
+
assert.include(wrKeys, runtimeWrKey, 'dedicated web-resource for the runtime not found');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('adds the runtime to the dedicated web-resource for it', function() {
|
|
45
|
+
const runtimeWR = wrNodes.find(n => n.attributes.key === runtimeWrKey);
|
|
46
|
+
const runtimeResources = getResources(runtimeWR);
|
|
47
|
+
const runtimeResourceLocations = runtimeResources.map(n => n.attributes.location);
|
|
48
|
+
assert.equal(runtimeResources.length, 1, 'should only have a single resource');
|
|
49
|
+
assert.equal(runtimeResourceLocations[0], runtimeName, 'should be the runtime');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('adds base dependencies to the runtime web-resource', function() {
|
|
53
|
+
const runtimeWR = wrNodes.find(n => n.attributes.key === runtimeWrKey);
|
|
54
|
+
const dependencies = getDependencies(runtimeWR);
|
|
55
|
+
const dependencyNames = dependencies.map(d => d.content);
|
|
56
|
+
assert.includeMembers(dependencyNames, BASE_DEPS, 'runtime should include base deps, but did not');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('does not add the runtime to more than one web-resource', function() {
|
|
60
|
+
const allResourceNodes = [].concat.apply([], wrNodes.map(getResources));
|
|
61
|
+
const allResourceLocations = allResourceNodes.map(n => n.attributes.location);
|
|
62
|
+
const runtimeCount = allResourceLocations.filter(loc => loc === runtimeName).length;
|
|
63
|
+
assert.equal(runtimeCount, 1, `${runtimeName} was added to multiple web-resources`);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('adds a dependency on the runtime to each entrypoint web-resource', function() {
|
|
67
|
+
const entrypoints = wrNodes.filter(n => n.attributes.key.startsWith('entry'));
|
|
68
|
+
entrypoints.forEach(entry => {
|
|
69
|
+
const wrName = entry.attributes.key;
|
|
70
|
+
const dependencies = getDependencies(entry);
|
|
71
|
+
const dependencyNames = dependencies.map(d => d.content);
|
|
72
|
+
assert.include(
|
|
73
|
+
dependencyNames,
|
|
74
|
+
`${PLUGIN_KEY}:${runtimeWrKey}`,
|
|
75
|
+
`web-resource ${wrName} should depend on runtime, but doesn't`
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe('when configured as "single"', function() {
|
|
82
|
+
const config = baseConfig('single', webresourceOutput);
|
|
83
|
+
|
|
84
|
+
runTheTestsFor(config, 'runtime.js');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('when configured with a static name', function() {
|
|
88
|
+
const name = 'custom';
|
|
89
|
+
const config = baseConfig({ name }, webresourceOutput);
|
|
90
|
+
|
|
91
|
+
runTheTestsFor(config, `${name}.js`);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('when configured with a name and custom output format', function() {
|
|
95
|
+
const name = 'fun';
|
|
96
|
+
const config = baseConfig({ name }, webresourceOutput);
|
|
97
|
+
config.output.filename = 'prefixed.[name].suffixed.js';
|
|
98
|
+
|
|
99
|
+
runTheTestsFor(config, `prefixed.${name}.suffixed.js`);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('when configured with a web-resource key', function() {
|
|
103
|
+
const name = 'custom';
|
|
104
|
+
const webresourceKey = 'foobar';
|
|
105
|
+
const config = baseConfig({ name }, webresourceOutput, webresourceKey);
|
|
106
|
+
|
|
107
|
+
runTheTestsFor(config, `${name}.js`, webresourceKey);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('when not configured', function() {
|
|
111
|
+
const config = baseConfig(false, webresourceOutput);
|
|
112
|
+
let wrNodes;
|
|
113
|
+
|
|
114
|
+
before(function(done) {
|
|
115
|
+
webpack(config, (err, st) => {
|
|
116
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
117
|
+
const results = parse(xmlFile);
|
|
118
|
+
wrNodes = results.root.children.filter(n => n.name === 'web-resource');
|
|
119
|
+
done();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('does not create a web-resource for the runtime', function() {
|
|
124
|
+
const wrKeys = wrNodes.map(n => n.attributes.key);
|
|
125
|
+
assert.notInclude(
|
|
126
|
+
wrKeys,
|
|
127
|
+
RUNTIME_WR_KEY,
|
|
128
|
+
'dedicated web-resource for the runtime present but should not be'
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.resolve(__dirname, 'src');
|
|
4
|
+
const OUTPUT_DIR = path.resolve(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = (runtimeChunk, webresourceOutput, singleRuntimeWebResourceKey) => ({
|
|
7
|
+
mode: 'development',
|
|
8
|
+
context: FRONTEND_SRC_DIR,
|
|
9
|
+
entry: {
|
|
10
|
+
first: path.join(FRONTEND_SRC_DIR, 'first.js'),
|
|
11
|
+
second: path.join(FRONTEND_SRC_DIR, 'second.js'),
|
|
12
|
+
third: path.join(FRONTEND_SRC_DIR, 'third.js'),
|
|
13
|
+
},
|
|
14
|
+
optimization: {
|
|
15
|
+
runtimeChunk,
|
|
16
|
+
splitChunks: {
|
|
17
|
+
minSize: 0,
|
|
18
|
+
chunks: 'all',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
new WrmPlugin({
|
|
23
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
24
|
+
xmlDescriptors: webresourceOutput,
|
|
25
|
+
verbose: false,
|
|
26
|
+
singleRuntimeWebResourceKey,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
output: {
|
|
30
|
+
filename: '[name].js',
|
|
31
|
+
path: path.resolve(OUTPUT_DIR),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
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 libraryDescriptor = path.join(targetDir, 'META-INF', 'plugin-descriptor', 'library.xml');
|
|
9
|
+
const featureDescriptor = path.join(targetDir, 'META-INF', 'plugin-descriptor', 'main.xml');
|
|
10
|
+
|
|
11
|
+
describe('specify-asset-dev-hash', function() {
|
|
12
|
+
let config = require('./webpack.config.js');
|
|
13
|
+
let results;
|
|
14
|
+
let libDevNode;
|
|
15
|
+
let featDevNode;
|
|
16
|
+
|
|
17
|
+
before(done => {
|
|
18
|
+
webpack(config, (err, stats) => {
|
|
19
|
+
let libXMLFile = fs.readFileSync(libraryDescriptor, 'utf-8');
|
|
20
|
+
let featXMLFile = fs.readFileSync(featureDescriptor, 'utf-8');
|
|
21
|
+
results = parse(libXMLFile);
|
|
22
|
+
libDevNode = results.root.children.find(n => n.attributes.key === 'assets-libDevAssets');
|
|
23
|
+
results = parse(featXMLFile);
|
|
24
|
+
featDevNode = results.root.children.find(n => n.attributes.key === 'assets-featDevAssets');
|
|
25
|
+
done();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('uses custom dev asset hashes provided in webpack config', () => {
|
|
30
|
+
assert.exists(libDevNode, 'node called assets-libDevAssets should exist');
|
|
31
|
+
assert.exists(featDevNode, 'node called assets-featDevAssets should exist');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const merge = require('webpack-merge');
|
|
3
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
4
|
+
const FRONTEND_SRC_DIR = path.resolve(__dirname, 'src');
|
|
5
|
+
const OUTPUT_DIR = path.resolve(__dirname, 'target');
|
|
6
|
+
|
|
7
|
+
const getLibraryWrmConfig = () => {
|
|
8
|
+
return {
|
|
9
|
+
webresourceKeyMap: {
|
|
10
|
+
library: 'libResource',
|
|
11
|
+
},
|
|
12
|
+
devAssetsHash: 'libDevAssets',
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getFeatureWrmConfig = () => {
|
|
17
|
+
return {
|
|
18
|
+
webresourceKeyMap: {
|
|
19
|
+
feature: 'featResource',
|
|
20
|
+
},
|
|
21
|
+
devAssetsHash: 'featDevAssets',
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const webResourcePlugin = isLibrary => {
|
|
26
|
+
const baseWrmConfig = {
|
|
27
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
28
|
+
xmlDescriptors: path.join(
|
|
29
|
+
__dirname,
|
|
30
|
+
'target',
|
|
31
|
+
'META-INF',
|
|
32
|
+
'plugin-descriptor',
|
|
33
|
+
isLibrary ? 'library.xml' : 'main.xml'
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return new WrmPlugin(merge(baseWrmConfig, isLibrary ? getLibraryWrmConfig() : getFeatureWrmConfig()));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const webpackConfigForLibrary = {
|
|
41
|
+
name: 'Library',
|
|
42
|
+
context: __dirname,
|
|
43
|
+
entry: {
|
|
44
|
+
library: path.join(FRONTEND_SRC_DIR, 'library.js'),
|
|
45
|
+
},
|
|
46
|
+
output: {
|
|
47
|
+
library: '[name]',
|
|
48
|
+
libraryTarget: 'amd',
|
|
49
|
+
filename: '[name].js',
|
|
50
|
+
path: path.resolve(OUTPUT_DIR),
|
|
51
|
+
},
|
|
52
|
+
plugins: [webResourcePlugin(true)],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const webpackConfigForFeature = {
|
|
56
|
+
name: 'Feature',
|
|
57
|
+
context: __dirname,
|
|
58
|
+
mode: 'development',
|
|
59
|
+
entry: {
|
|
60
|
+
feature: path.join(FRONTEND_SRC_DIR, 'feature.js'),
|
|
61
|
+
},
|
|
62
|
+
output: {
|
|
63
|
+
library: '',
|
|
64
|
+
libraryTarget: 'var',
|
|
65
|
+
filename: '[name].js',
|
|
66
|
+
path: path.resolve(OUTPUT_DIR),
|
|
67
|
+
},
|
|
68
|
+
plugins: [webResourcePlugin(false)],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = [webpackConfigForLibrary, webpackConfigForFeature];
|
|
@@ -0,0 +1,106 @@
|
|
|
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('specify-conditions', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let error;
|
|
15
|
+
let wrNodes;
|
|
16
|
+
|
|
17
|
+
function getWebresourceLike(needle) {
|
|
18
|
+
return wrNodes.find(n => n.attributes.key.indexOf(needle) > -1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getCondition(node) {
|
|
22
|
+
return node.children.filter(childNode => childNode.name === 'condition');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getConditions(node) {
|
|
26
|
+
return node.children.filter(childNode => childNode.name === 'conditions');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getContent(nodes) {
|
|
30
|
+
return nodes.map(n => n.content);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
beforeEach(done => {
|
|
34
|
+
webpack(config, (err, st) => {
|
|
35
|
+
error = err;
|
|
36
|
+
stats = st;
|
|
37
|
+
|
|
38
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
39
|
+
const results = parse(xmlFile);
|
|
40
|
+
wrNodes = results.root.children.filter(n => n.attributes.key.startsWith('entry'));
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should run without error', () => {
|
|
46
|
+
assert.ok(wrNodes);
|
|
47
|
+
assert.equal(stats.hasErrors(), false);
|
|
48
|
+
assert.equal(stats.hasWarnings(), false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('add conditions to entry-points', () => {
|
|
52
|
+
it('should add nextes conditions as specified in the conditionMap to app-one', () => {
|
|
53
|
+
const wrWithGoodConfig = getWebresourceLike('app-one');
|
|
54
|
+
const conditions = getConditions(wrWithGoodConfig);
|
|
55
|
+
|
|
56
|
+
assert.ok(conditions);
|
|
57
|
+
assert.equal(1, conditions.length);
|
|
58
|
+
|
|
59
|
+
const condition = conditions[0];
|
|
60
|
+
assert.equal('AND', condition.attributes.type);
|
|
61
|
+
assert.equal(2, condition.children.length);
|
|
62
|
+
|
|
63
|
+
assert.equal(
|
|
64
|
+
JSON.stringify(condition),
|
|
65
|
+
`{"name":"conditions","attributes":{"type":"AND"},"children":[{"name":"conditions","attributes":{"type":"OR"},"children":[{"name":"condition","attributes":{"class":"foo.bar.baz","invert":"true"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"admin"}],"content":""},{"name":"condition","attributes":{"class":"foo.bar.baz2"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"project"}],"content":""}],"content":""},{"name":"condition","attributes":{"class":"foo.bar.baz3"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"admin"}],"content":""}],"content":""}`
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should add simple condition as specified in condition map to app-two', () => {
|
|
70
|
+
const wrWithGoodConfig = getWebresourceLike('app-two');
|
|
71
|
+
const conditions = getCondition(wrWithGoodConfig);
|
|
72
|
+
|
|
73
|
+
assert.ok(conditions);
|
|
74
|
+
assert.equal(1, conditions.length);
|
|
75
|
+
|
|
76
|
+
const condition = conditions[0];
|
|
77
|
+
assert.equal('foo.bar.baz', condition.attributes.class);
|
|
78
|
+
assert.equal('true', condition.attributes.invert);
|
|
79
|
+
|
|
80
|
+
assert.equal(
|
|
81
|
+
JSON.stringify(condition),
|
|
82
|
+
`{"name":"condition","attributes":{"class":"foo.bar.baz","invert":"true"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"admin"}],"content":""}`
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should add multiple conditions as specified in condition map to app-three', () => {
|
|
87
|
+
const wrWithGoodConfig = getWebresourceLike('app-three');
|
|
88
|
+
const conditions = getCondition(wrWithGoodConfig);
|
|
89
|
+
|
|
90
|
+
assert.ok(conditions);
|
|
91
|
+
assert.equal(2, conditions.length);
|
|
92
|
+
|
|
93
|
+
const condition1 = conditions[0];
|
|
94
|
+
assert.equal('foo.bar.baz', condition1.attributes.class);
|
|
95
|
+
assert.equal('true', condition1.attributes.invert);
|
|
96
|
+
const condition2 = conditions[1];
|
|
97
|
+
assert.equal('foo.bar.baz2', condition2.attributes.class);
|
|
98
|
+
assert.equal(undefined, condition2.attributes.invert);
|
|
99
|
+
|
|
100
|
+
assert.equal(
|
|
101
|
+
JSON.stringify(conditions),
|
|
102
|
+
`[{"name":"condition","attributes":{"class":"foo.bar.baz","invert":"true"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"admin"}],"content":""},{"name":"condition","attributes":{"class":"foo.bar.baz2"},"children":[{"name":"param","attributes":{"name":"permission"},"children":[],"content":"project"}],"content":""}]`
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
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-one': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
'app-two': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
11
|
+
'app-three': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
new WrmPlugin({
|
|
15
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
16
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
17
|
+
conditionMap: {
|
|
18
|
+
'app-one': {
|
|
19
|
+
type: 'AND',
|
|
20
|
+
conditions: [
|
|
21
|
+
{
|
|
22
|
+
type: 'OR',
|
|
23
|
+
conditions: [
|
|
24
|
+
{
|
|
25
|
+
class: 'foo.bar.baz',
|
|
26
|
+
invert: true,
|
|
27
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
class: 'foo.bar.baz2',
|
|
31
|
+
params: [{ attributes: { name: 'permission' }, value: 'project' }],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
class: 'foo.bar.baz3',
|
|
37
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
'app-two': {
|
|
42
|
+
class: 'foo.bar.baz',
|
|
43
|
+
invert: true,
|
|
44
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
45
|
+
},
|
|
46
|
+
'app-three': [
|
|
47
|
+
{
|
|
48
|
+
class: 'foo.bar.baz',
|
|
49
|
+
invert: true,
|
|
50
|
+
params: [{ attributes: { name: 'permission' }, value: 'admin' }],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
class: 'foo.bar.baz2',
|
|
54
|
+
params: [{ attributes: { name: 'permission' }, value: 'project' }],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
verbose: false,
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
61
|
+
output: {
|
|
62
|
+
filename: '[name].js',
|
|
63
|
+
path: OUTPUT_DIR,
|
|
64
|
+
},
|
|
65
|
+
};
|