@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,69 @@
|
|
|
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-transformation', function() {
|
|
11
|
+
const config = require('./webpack.extend-tranformations.config');
|
|
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 getTransformation(node) {
|
|
22
|
+
return node.children.filter(childNode => childNode.name === 'transformation');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getTransformationByExtension(transformations, extname) {
|
|
26
|
+
return transformations.filter(transformation => transformation.attributes.extension === extname)[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeEach(done => {
|
|
30
|
+
webpack(config, (err, st) => {
|
|
31
|
+
error = err;
|
|
32
|
+
stats = st;
|
|
33
|
+
|
|
34
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
35
|
+
const results = parse(xmlFile);
|
|
36
|
+
wrNodes = results.root.children;
|
|
37
|
+
done();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('extending transformations', () => {
|
|
42
|
+
let entryJsTrans, lessTrans, svgTrans;
|
|
43
|
+
|
|
44
|
+
beforeEach(function() {
|
|
45
|
+
const entrypointTransformations = getTransformation(getWebresourceLike('app-one'));
|
|
46
|
+
const assetTransformations = getTransformation(getWebresourceLike('assets'));
|
|
47
|
+
|
|
48
|
+
assert.ok(entrypointTransformations);
|
|
49
|
+
assert.ok(assetTransformations);
|
|
50
|
+
|
|
51
|
+
entryJsTrans = getTransformationByExtension(entrypointTransformations, 'js');
|
|
52
|
+
|
|
53
|
+
lessTrans = getTransformationByExtension(assetTransformations, 'less');
|
|
54
|
+
svgTrans = getTransformationByExtension(assetTransformations, 'svg');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should include default transformations', () => {
|
|
58
|
+
assert.include(entryJsTrans.children.map(c => c.attributes.key), 'jsI18n');
|
|
59
|
+
assert.include(lessTrans.children.map(c => c.attributes.key), 'lessTransformer');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should contain additional transformers', () => {
|
|
63
|
+
assert.include(entryJsTrans.children.map(c => c.attributes.key), 'custom-transformer');
|
|
64
|
+
assert.include(entryJsTrans.children.map(c => c.attributes.key), 'foo-transformer');
|
|
65
|
+
|
|
66
|
+
assert.include(svgTrans.children.map(c => c.attributes.key), 'bar');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
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-transformation', function() {
|
|
11
|
+
const config = require('./webpack.specify-transformations.config');
|
|
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 getTransformation(node) {
|
|
22
|
+
return node.children.filter(childNode => childNode.name === 'transformation');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getTransformationByExtension(transformations, extname) {
|
|
26
|
+
return transformations.filter(transformation => transformation.attributes.extension === extname)[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeEach(done => {
|
|
30
|
+
webpack(config, (err, st) => {
|
|
31
|
+
error = err;
|
|
32
|
+
stats = st;
|
|
33
|
+
|
|
34
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
35
|
+
const results = parse(xmlFile);
|
|
36
|
+
wrNodes = results.root.children;
|
|
37
|
+
done();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should run without error', () => {
|
|
42
|
+
assert.ok(wrNodes);
|
|
43
|
+
assert.equal(stats.hasErrors(), false, error);
|
|
44
|
+
assert.equal(stats.hasWarnings(), false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('add transformation for file extensions', () => {
|
|
48
|
+
let entryJsTrans, entrySoyTrans, entryLessTrans;
|
|
49
|
+
let jsTrans, htmlTrans, lessTrans, soyTrans, svgTrans, txtTrans;
|
|
50
|
+
|
|
51
|
+
beforeEach(function() {
|
|
52
|
+
const entrypointTransformations = getTransformation(getWebresourceLike('app-one'));
|
|
53
|
+
const assetTransformations = getTransformation(getWebresourceLike('assets'));
|
|
54
|
+
|
|
55
|
+
assert.ok(entrypointTransformations);
|
|
56
|
+
assert.ok(assetTransformations);
|
|
57
|
+
|
|
58
|
+
entryJsTrans = getTransformationByExtension(entrypointTransformations, 'js');
|
|
59
|
+
entrySoyTrans = getTransformationByExtension(entrypointTransformations, 'soy');
|
|
60
|
+
entryLessTrans = getTransformationByExtension(entrypointTransformations, 'less');
|
|
61
|
+
|
|
62
|
+
jsTrans = getTransformationByExtension(assetTransformations, 'js');
|
|
63
|
+
htmlTrans = getTransformationByExtension(assetTransformations, 'html');
|
|
64
|
+
lessTrans = getTransformationByExtension(assetTransformations, 'less');
|
|
65
|
+
soyTrans = getTransformationByExtension(assetTransformations, 'soy');
|
|
66
|
+
svgTrans = getTransformationByExtension(assetTransformations, 'svg');
|
|
67
|
+
txtTrans = getTransformationByExtension(assetTransformations, 'txt');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should remove default transformations from web-resources', () => {
|
|
71
|
+
assert.equal(entrySoyTrans, null);
|
|
72
|
+
assert.equal(entryLessTrans, null);
|
|
73
|
+
assert.notInclude(entryJsTrans.children.map(c => c.attributes.key), 'jsI18n');
|
|
74
|
+
|
|
75
|
+
// the defaults should not end up on the assets web-resource either,
|
|
76
|
+
// since there aren't any assets of those types in the graph.
|
|
77
|
+
assert.equal(jsTrans, null);
|
|
78
|
+
assert.equal(lessTrans, null);
|
|
79
|
+
assert.equal(soyTrans, null);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should add custom transformations to web-resources', () => {
|
|
83
|
+
assert.include(entryJsTrans.children.map(c => c.attributes.key), 'foo');
|
|
84
|
+
assert.include(entryJsTrans.children.map(c => c.attributes.key), 'bar');
|
|
85
|
+
|
|
86
|
+
assert.include(txtTrans.children.map(c => c.attributes.key), 'bar');
|
|
87
|
+
|
|
88
|
+
assert.include(htmlTrans.children.map(c => c.attributes.key), 'stuff');
|
|
89
|
+
assert.include(htmlTrans.children.map(c => c.attributes.key), 'n stuff');
|
|
90
|
+
|
|
91
|
+
assert.equal(svgTrans, null);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should not produce duplicated transformations', () => {
|
|
95
|
+
const transformationNames = txtTrans.children.map(c => c.attributes.key);
|
|
96
|
+
|
|
97
|
+
assert.equal(transformationNames.length, 1);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import text from './test.txt';
|
|
3
|
+
import styles from './test.less';
|
|
4
|
+
import body from './test.html';
|
|
5
|
+
import rect from './rect.svg';
|
|
6
|
+
|
|
7
|
+
$(() => {
|
|
8
|
+
$('body')
|
|
9
|
+
.text(text)
|
|
10
|
+
.html(body)
|
|
11
|
+
.css(styles)
|
|
12
|
+
.append(rect);
|
|
13
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p>hello there again!</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.foo { color: red; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hello, world!
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.(?!js)/,
|
|
15
|
+
use: '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
|
+
transformationMap: false,
|
|
24
|
+
verbose: false,
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
output: {
|
|
28
|
+
filename: '[name].js',
|
|
29
|
+
path: OUTPUT_DIR,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.(?!js)/,
|
|
15
|
+
use: '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
|
+
transformationMap: WrmPlugin.extendTransformations({
|
|
24
|
+
js: ['custom-transformer', 'foo-transformer'],
|
|
25
|
+
svg: ['bar'],
|
|
26
|
+
}),
|
|
27
|
+
verbose: false,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
output: {
|
|
31
|
+
filename: '[name].js',
|
|
32
|
+
path: OUTPUT_DIR,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.(?!js)/,
|
|
15
|
+
use: '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
|
+
transformationMap: {
|
|
24
|
+
js: ['foo', 'bar'],
|
|
25
|
+
html: ['stuff', 'n stuff'],
|
|
26
|
+
txt: ['bar', 'bar'],
|
|
27
|
+
},
|
|
28
|
+
verbose: false,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
output: {
|
|
32
|
+
filename: '[name].js',
|
|
33
|
+
path: OUTPUT_DIR,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
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('split-chunks', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let error;
|
|
15
|
+
let entryApp;
|
|
16
|
+
let entryApp2;
|
|
17
|
+
let splitChunkShared;
|
|
18
|
+
let testEntryApp;
|
|
19
|
+
let testEntryApp2;
|
|
20
|
+
|
|
21
|
+
function getChild(node, name) {
|
|
22
|
+
return node.children.filter(n => n.name === name);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getContent(nodes) {
|
|
26
|
+
return nodes.map(n => n.content);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
before(done => {
|
|
30
|
+
webpack(config, (err, st) => {
|
|
31
|
+
error = err;
|
|
32
|
+
stats = st;
|
|
33
|
+
|
|
34
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
35
|
+
const results = parse(xmlFile);
|
|
36
|
+
entryApp = results.root.children.find(n => n.attributes.key === 'entrypoint-app');
|
|
37
|
+
entryApp2 = results.root.children.find(n => n.attributes.key === 'entrypoint-app2');
|
|
38
|
+
splitChunkShared = results.root.children.find(n => n.attributes.key === 'split_app~app2');
|
|
39
|
+
testEntryApp = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app');
|
|
40
|
+
testEntryApp2 = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app2');
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should create a webresources with dependencies and resources as appropriate', () => {
|
|
46
|
+
assert.ok(entryApp);
|
|
47
|
+
assert.ok(entryApp2);
|
|
48
|
+
assert.ok(splitChunkShared);
|
|
49
|
+
|
|
50
|
+
assert.equal(error, null);
|
|
51
|
+
assert.equal(stats.hasErrors(), false);
|
|
52
|
+
assert.equal(stats.hasWarnings(), false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('split chunk for shared modules', () => {
|
|
56
|
+
it('should create a web-resource for the split chunk', () => {
|
|
57
|
+
assert.ok(splitChunkShared);
|
|
58
|
+
assert.equal(
|
|
59
|
+
getChild(splitChunkShared, 'resource').length,
|
|
60
|
+
1,
|
|
61
|
+
'split chunk contains unexpected amount of resources'
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should contain all dependencies specified in at least 2 entry-points', () => {
|
|
66
|
+
const deps = getContent(getChild(splitChunkShared, 'dependency'));
|
|
67
|
+
assert.include(deps, 'jira.webresources:jquery', 'jquery dependency not found in split chunk');
|
|
68
|
+
assert.include(
|
|
69
|
+
deps,
|
|
70
|
+
'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
71
|
+
'underscore dependency not found in split chunk'
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('entry points', () => {
|
|
77
|
+
let depsApp;
|
|
78
|
+
let depsApp2;
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
depsApp = getContent(getChild(entryApp, 'dependency'));
|
|
81
|
+
depsApp2 = getContent(getChild(entryApp2, 'dependency'));
|
|
82
|
+
});
|
|
83
|
+
it('should not have direct dependency to shared deps', () => {
|
|
84
|
+
assert.notInclude(depsApp, 'jira.webresources:jquery', 'unexpected dependency found');
|
|
85
|
+
assert.notInclude(depsApp, 'com.atlassian.plugin.jslibs:underscore-1.4.4', 'unexpected dependency found');
|
|
86
|
+
assert.notInclude(depsApp2, 'jira.webresources:jquery', 'unexpected dependency found');
|
|
87
|
+
assert.notInclude(depsApp2, 'com.atlassian.plugin.jslibs:underscore-1.4.4', 'unexpected dependency found');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should have dependency to split chunks', () => {
|
|
91
|
+
assert.include(depsApp, 'com.atlassian.plugin.test:split_app~app2', 'expected dependency not found');
|
|
92
|
+
assert.include(depsApp2, 'com.atlassian.plugin.test:split_app~app2', 'expected dependency not found');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('test web-resources', () => {
|
|
97
|
+
it('should not have any test entries', () => {
|
|
98
|
+
assert.equal(testEntryApp, undefined, 'test entrypoint is undefined');
|
|
99
|
+
assert.equal(testEntryApp2, undefined, 'test entrypoint is undefined');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
4
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src');
|
|
5
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
6
|
+
|
|
7
|
+
const providedDependencies = new Map();
|
|
8
|
+
providedDependencies.set('jquery', {
|
|
9
|
+
dependency: 'jira.webresources:jquery',
|
|
10
|
+
import: "require('jquery')",
|
|
11
|
+
});
|
|
12
|
+
providedDependencies.set('underscore', {
|
|
13
|
+
dependency: 'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
14
|
+
import: "require('underscore')",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
mode: 'development',
|
|
19
|
+
devtool: false,
|
|
20
|
+
entry: {
|
|
21
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
22
|
+
app2: path.join(FRONTEND_SRC_DIR, 'app2.js'),
|
|
23
|
+
},
|
|
24
|
+
optimization: {
|
|
25
|
+
splitChunks: {
|
|
26
|
+
minSize: 0,
|
|
27
|
+
chunks: 'all',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
plugins: [
|
|
31
|
+
new WrmPlugin({
|
|
32
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
33
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
34
|
+
verbose: false,
|
|
35
|
+
providedDependencies,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
output: {
|
|
39
|
+
filename: '[name].js',
|
|
40
|
+
path: OUTPUT_DIR,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
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('split-chunks-with-runtime', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let error;
|
|
15
|
+
let entryApp;
|
|
16
|
+
let entryApp2;
|
|
17
|
+
let splitChunkApp;
|
|
18
|
+
let splitChunkApp2;
|
|
19
|
+
let splitChunkShared;
|
|
20
|
+
let testEntryApp;
|
|
21
|
+
let testEntryApp2;
|
|
22
|
+
|
|
23
|
+
function getChild(node, name) {
|
|
24
|
+
return node.children.filter(n => n.name === name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getContent(nodes) {
|
|
28
|
+
return nodes.map(n => n.content);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getAttribute(nodes, attribute) {
|
|
32
|
+
return nodes.map(n => n.attributes[attribute]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
before(done => {
|
|
36
|
+
webpack(config, (err, st) => {
|
|
37
|
+
error = err;
|
|
38
|
+
stats = st;
|
|
39
|
+
|
|
40
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
41
|
+
const results = parse(xmlFile);
|
|
42
|
+
entryApp = results.root.children.find(n => n.attributes.key === 'entrypoint-app');
|
|
43
|
+
entryApp2 = results.root.children.find(n => n.attributes.key === 'entrypoint-app2');
|
|
44
|
+
splitChunkApp = results.root.children.find(n => n.attributes.key === 'split_app');
|
|
45
|
+
splitChunkApp2 = results.root.children.find(n => n.attributes.key === 'split_app2');
|
|
46
|
+
splitChunkShared = results.root.children.find(n => n.attributes.key === 'split_app~app2');
|
|
47
|
+
testEntryApp = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app');
|
|
48
|
+
testEntryApp2 = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app2');
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create a webresources with dependencies and resources as appropriate', () => {
|
|
54
|
+
assert.ok(entryApp);
|
|
55
|
+
assert.ok(entryApp2);
|
|
56
|
+
assert.ok(splitChunkApp);
|
|
57
|
+
assert.ok(splitChunkApp2);
|
|
58
|
+
assert.ok(splitChunkShared);
|
|
59
|
+
|
|
60
|
+
assert.equal(error, null);
|
|
61
|
+
assert.equal(stats.hasErrors(), false);
|
|
62
|
+
assert.equal(stats.hasWarnings(), false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('split chunk for shared modules', () => {
|
|
66
|
+
it('should create a web-resource for the split chunk', () => {
|
|
67
|
+
assert.ok(splitChunkShared);
|
|
68
|
+
assert.equal(
|
|
69
|
+
getChild(splitChunkShared, 'resource').length,
|
|
70
|
+
1,
|
|
71
|
+
'split chunk contains unexpected amount of resources'
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should contain all dependencies specified in at least 2 entry-points', () => {
|
|
76
|
+
const deps = getContent(getChild(splitChunkShared, 'dependency'));
|
|
77
|
+
assert.include(deps, 'jira.webresources:jquery', 'jquery dependency not found in split chunk');
|
|
78
|
+
assert.include(
|
|
79
|
+
deps,
|
|
80
|
+
'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
81
|
+
'underscore dependency not found in split chunk'
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('entry points', () => {
|
|
87
|
+
let depsApp;
|
|
88
|
+
let depsApp2;
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
depsApp = getContent(getChild(entryApp, 'dependency'));
|
|
91
|
+
depsApp2 = getContent(getChild(entryApp2, 'dependency'));
|
|
92
|
+
});
|
|
93
|
+
it('should not have direct dependency to shared deps', () => {
|
|
94
|
+
assert.notInclude(depsApp, 'jira.webresources:jquery', 'unexpected dependency found');
|
|
95
|
+
assert.notInclude(depsApp, 'com.atlassian.plugin.jslibs:underscore-1.4.4', 'unexpected dependency found');
|
|
96
|
+
assert.notInclude(depsApp2, 'jira.webresources:jquery', 'unexpected dependency found');
|
|
97
|
+
assert.notInclude(depsApp2, 'com.atlassian.plugin.jslibs:underscore-1.4.4', 'unexpected dependency found');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should have dependency to split chunks', () => {
|
|
101
|
+
assert.include(depsApp, 'com.atlassian.plugin.test:split_app', 'expected dependency not found');
|
|
102
|
+
assert.include(depsApp, 'com.atlassian.plugin.test:split_app~app2', 'expected dependency not found');
|
|
103
|
+
assert.include(depsApp2, 'com.atlassian.plugin.test:split_app2', 'expected dependency not found');
|
|
104
|
+
assert.include(depsApp2, 'com.atlassian.plugin.test:split_app~app2', 'expected dependency not found');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('test web-resources', () => {
|
|
109
|
+
it('should not have any test entries', () => {
|
|
110
|
+
assert.equal(testEntryApp, undefined, 'test entrypoint is undefined');
|
|
111
|
+
assert.equal(testEntryApp2, undefined, 'test entrypoint is undefined');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
4
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src');
|
|
5
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
6
|
+
|
|
7
|
+
const providedDependencies = new Map();
|
|
8
|
+
providedDependencies.set('jquery', {
|
|
9
|
+
dependency: 'jira.webresources:jquery',
|
|
10
|
+
import: "require('jquery')",
|
|
11
|
+
});
|
|
12
|
+
providedDependencies.set('underscore', {
|
|
13
|
+
dependency: 'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
14
|
+
import: "require('underscore')",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
mode: 'development',
|
|
19
|
+
devtool: false,
|
|
20
|
+
entry: {
|
|
21
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
22
|
+
app2: path.join(FRONTEND_SRC_DIR, 'app2.js'),
|
|
23
|
+
},
|
|
24
|
+
optimization: {
|
|
25
|
+
runtimeChunk: true,
|
|
26
|
+
splitChunks: {
|
|
27
|
+
minSize: 0,
|
|
28
|
+
chunks: 'all',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
plugins: [
|
|
32
|
+
new WrmPlugin({
|
|
33
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
34
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
35
|
+
verbose: false,
|
|
36
|
+
providedDependencies,
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
filename: '[name].js',
|
|
41
|
+
path: OUTPUT_DIR,
|
|
42
|
+
},
|
|
43
|
+
};
|