@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,40 @@
|
|
|
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
|
+
const providedDependencies = new Map();
|
|
7
|
+
providedDependencies.set('jquery', {
|
|
8
|
+
dependency: 'jira.webresources:jquery',
|
|
9
|
+
import: "require('jquery')",
|
|
10
|
+
});
|
|
11
|
+
providedDependencies.set('underscore', {
|
|
12
|
+
dependency: 'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
13
|
+
import: "require('underscore')",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
mode: 'development',
|
|
18
|
+
entry: {
|
|
19
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
20
|
+
},
|
|
21
|
+
optimization: {
|
|
22
|
+
runtimeChunk: true,
|
|
23
|
+
splitChunks: {
|
|
24
|
+
minSize: 0,
|
|
25
|
+
chunks: 'all',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
plugins: [
|
|
29
|
+
new WrmPlugin({
|
|
30
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
31
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
32
|
+
providedDependencies,
|
|
33
|
+
verbose: false,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
output: {
|
|
37
|
+
filename: '[name].js',
|
|
38
|
+
path: OUTPUT_DIR,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
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('async-chunks-named-context', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let runtime;
|
|
15
|
+
let runtime2;
|
|
16
|
+
let app;
|
|
17
|
+
let app2;
|
|
18
|
+
let splitAppAndApp2;
|
|
19
|
+
let asyncBar;
|
|
20
|
+
let asyncFoo;
|
|
21
|
+
let asyncAsyncBar;
|
|
22
|
+
let asyncAsyncBarTwo;
|
|
23
|
+
let asyncAsyncAsyncBar;
|
|
24
|
+
|
|
25
|
+
function getDependencies(node) {
|
|
26
|
+
return node.children.filter(n => n.name === 'dependency');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getContent(nodes) {
|
|
30
|
+
return nodes.map(n => n.content);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
beforeEach(done => {
|
|
34
|
+
webpack(config, (err, st) => {
|
|
35
|
+
stats = st;
|
|
36
|
+
|
|
37
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
38
|
+
const results = parse(xmlFile);
|
|
39
|
+
runtime = results.root.children.find(n => n.attributes.key === 'entrypoint-app');
|
|
40
|
+
runtime2 = results.root.children.find(n => n.attributes.key === 'entrypoint-app2');
|
|
41
|
+
app = results.root.children.find(n => n.attributes.key === 'split_app');
|
|
42
|
+
app2 = results.root.children.find(n => n.attributes.key === 'split_app2');
|
|
43
|
+
splitAppAndApp2 = results.root.children.find(n => n.attributes.key === 'split_app~app2');
|
|
44
|
+
asyncBar = results.root.children.find(n => n.attributes.key === 'async-bar');
|
|
45
|
+
asyncFoo = results.root.children.find(n => n.attributes.key === 'async-foo');
|
|
46
|
+
asyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-bar');
|
|
47
|
+
asyncAsyncBarTwo = results.root.children.find(n => n.attributes.key === 'async-async-bar-two');
|
|
48
|
+
asyncAsyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-async-bar');
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should compile correctly', () => {
|
|
54
|
+
assert.ok(runtime, 'runtime does not exist');
|
|
55
|
+
assert.ok(runtime2, 'runtime2 does not exist');
|
|
56
|
+
assert.ok(app, 'app does not exist');
|
|
57
|
+
assert.ok(app2, 'app2 does not exist');
|
|
58
|
+
assert.ok(splitAppAndApp2, 'splitAppAndApp2 does not exist');
|
|
59
|
+
assert.ok(asyncBar, '"async-bar" does not exist');
|
|
60
|
+
assert.ok(asyncFoo, '"async-foo" does not exist');
|
|
61
|
+
assert.ok(asyncAsyncBar, '"async-async-bar" does not exist');
|
|
62
|
+
assert.ok(asyncAsyncBarTwo, '"async-async-bar-two" does not exist');
|
|
63
|
+
assert.ok(asyncAsyncAsyncBar, '"async-async-async-bar" does not exist');
|
|
64
|
+
assert.equal(stats.hasErrors(), false, 'should not have errors');
|
|
65
|
+
assert.equal(stats.hasWarnings(), false, 'should not have warnings');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('has a context named after the entry point', () => {
|
|
69
|
+
const getContext = node => node.children.filter(n => n.name === 'context')[0];
|
|
70
|
+
assert.nestedPropertyVal(getContext(asyncBar), 'content', 'async-chunk-async-bar');
|
|
71
|
+
assert.nestedPropertyVal(getContext(asyncFoo), 'content', 'async-chunk-async-foo');
|
|
72
|
+
assert.nestedPropertyVal(getContext(asyncAsyncBar), 'content', 'async-chunk-async-async-bar');
|
|
73
|
+
assert.nestedPropertyVal(getContext(asyncAsyncBarTwo), 'content', 'async-chunk-async-async-bar-two');
|
|
74
|
+
assert.nestedPropertyVal(getContext(asyncAsyncAsyncBar), 'content', 'async-chunk-async-async-async-bar');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'async-async-bar-two';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
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
|
+
entry: {
|
|
20
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
21
|
+
app2: path.join(FRONTEND_SRC_DIR, 'app2.js'),
|
|
22
|
+
},
|
|
23
|
+
optimization: {
|
|
24
|
+
runtimeChunk: true,
|
|
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
|
+
providedDependencies,
|
|
35
|
+
verbose: false,
|
|
36
|
+
}),
|
|
37
|
+
new webpack.NamedChunksPlugin(),
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
filename: '[name].js',
|
|
41
|
+
path: OUTPUT_DIR,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
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('async-chunks-of-async-chunks', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let runtime;
|
|
15
|
+
let app;
|
|
16
|
+
let asyncBar;
|
|
17
|
+
let asyncFoo;
|
|
18
|
+
let asyncAsyncBar;
|
|
19
|
+
let asyncAsyncBarTwo;
|
|
20
|
+
let asyncAsyncAsyncBar;
|
|
21
|
+
|
|
22
|
+
function getDependencies(node) {
|
|
23
|
+
return node.children.filter(n => n.name === 'dependency');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getContent(nodes) {
|
|
27
|
+
return nodes.map(n => n.content);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
beforeEach(done => {
|
|
31
|
+
webpack(config, (err, st) => {
|
|
32
|
+
stats = st;
|
|
33
|
+
|
|
34
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
35
|
+
const results = parse(xmlFile);
|
|
36
|
+
runtime = results.root.children.find(n => n.attributes.key.startsWith('entry'));
|
|
37
|
+
app = results.root.children.find(n => n.attributes.key === 'split_app');
|
|
38
|
+
asyncBar = results.root.children.find(n => n.attributes.key === 'async-bar');
|
|
39
|
+
asyncFoo = results.root.children.find(n => n.attributes.key === 'async-foo');
|
|
40
|
+
asyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-bar');
|
|
41
|
+
asyncAsyncBarTwo = results.root.children.find(n => n.attributes.key === 'async-async-bar-two');
|
|
42
|
+
asyncAsyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-async-bar');
|
|
43
|
+
done();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should create a webresource for each async chunk', () => {
|
|
48
|
+
assert.ok(runtime, 'runtime does not exist');
|
|
49
|
+
assert.ok(app, 'app does not exist');
|
|
50
|
+
assert.ok(asyncBar, '"async-bar" does not exist');
|
|
51
|
+
assert.ok(asyncFoo, '"async-foo" does not exist');
|
|
52
|
+
assert.ok(asyncAsyncBar, '"async-async-bar" does not exist');
|
|
53
|
+
assert.ok(asyncAsyncBarTwo, '"async-async-bar-two" does not exist');
|
|
54
|
+
assert.ok(asyncAsyncAsyncBar, '"async-async-async-bar" does not exist');
|
|
55
|
+
assert.equal(stats.hasErrors(), false, 'should not have errors');
|
|
56
|
+
assert.equal(stats.hasWarnings(), false, 'should not have warnings');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should inject a WRM pre-condition checker into the webpack runtime', () => {
|
|
60
|
+
// setup
|
|
61
|
+
const bundleFile = fs.readFileSync(path.join(targetDir, 'runtime~app.js'), 'utf-8');
|
|
62
|
+
const expectedRuntimeAdjustment = `
|
|
63
|
+
/******/ var promises = [];
|
|
64
|
+
/******/
|
|
65
|
+
/******/ if(installedChunks[chunkId] === 0) { // 0 means "already installed".
|
|
66
|
+
/******/ return Promise.resolve();
|
|
67
|
+
/******/ }
|
|
68
|
+
/******/
|
|
69
|
+
/******/ if (installedChunks[chunkId]) {
|
|
70
|
+
/******/ return installedChunks[chunkId][2];
|
|
71
|
+
/******/ }
|
|
72
|
+
/******/
|
|
73
|
+
/******/ promises.push(
|
|
74
|
+
/******/ new Promise(function(resolve, reject) {
|
|
75
|
+
/******/ installedChunks[chunkId] = [resolve, reject];
|
|
76
|
+
/******/ }),
|
|
77
|
+
/******/ new Promise(function(resolve, reject) {
|
|
78
|
+
/******/ WRM.require('wrc!com.atlassian.plugin.test:' + chunkId).then(resolve, reject);
|
|
79
|
+
/******/ })
|
|
80
|
+
/******/ );
|
|
81
|
+
/******/ return installedChunks[chunkId][2] = Promise.all(promises);`;
|
|
82
|
+
|
|
83
|
+
assert.include(bundleFile, expectedRuntimeAdjustment);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('adds shared provided dependencies only to the entry point', () => {
|
|
87
|
+
const appDeps = getContent(getDependencies(app));
|
|
88
|
+
const asyncBarDeps = getContent(getDependencies(asyncBar));
|
|
89
|
+
const asyncFooDeps = getContent(getDependencies(asyncFoo));
|
|
90
|
+
const asyncAsyncBarDeps = getContent(getDependencies(asyncAsyncBar));
|
|
91
|
+
const asyncAsyncBarTwoDeps = getContent(getDependencies(asyncAsyncBarTwo));
|
|
92
|
+
const asyncAsyncAsyncBarDeps = getContent(getDependencies(asyncAsyncAsyncBar));
|
|
93
|
+
|
|
94
|
+
assert.ok(appDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'));
|
|
95
|
+
assert.notEqual(asyncBarDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'), true);
|
|
96
|
+
assert.notEqual(asyncFooDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'), true);
|
|
97
|
+
assert.notEqual(asyncAsyncBarDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'), true);
|
|
98
|
+
assert.notEqual(asyncAsyncBarTwoDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'), true);
|
|
99
|
+
assert.notEqual(asyncAsyncAsyncBarDeps.includes('com.atlassian.plugin.jslibs:underscore-1.4.4'), true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('adds async-chunk-only deps only to the async-chunk-webresource', () => {
|
|
103
|
+
const entryDeps = getContent(getDependencies(app));
|
|
104
|
+
const asyncBarDeps = getContent(getDependencies(asyncBar));
|
|
105
|
+
const asyncFooDeps = getContent(getDependencies(asyncFoo));
|
|
106
|
+
const asyncAsyncBarDeps = getContent(getDependencies(asyncAsyncBar));
|
|
107
|
+
const asyncAsyncBarTwoDeps = getContent(getDependencies(asyncAsyncBarTwo));
|
|
108
|
+
const asyncAsyncAsyncBarDeps = getContent(getDependencies(asyncAsyncAsyncBar));
|
|
109
|
+
|
|
110
|
+
assert.notEqual(entryDeps.includes('jira.webresources:jquery'));
|
|
111
|
+
assert.ok(asyncBarDeps.includes('jira.webresources:jquery'), true);
|
|
112
|
+
assert.notEqual(asyncFooDeps.includes('jira.webresources:jquery'), true);
|
|
113
|
+
assert.notEqual(asyncAsyncBarDeps.includes('jira.webresources:jquery'), true);
|
|
114
|
+
assert.notEqual(asyncAsyncBarTwoDeps.includes('jira.webresources:jquery'), true);
|
|
115
|
+
assert.notEqual(asyncAsyncAsyncBarDeps.includes('jira.webresources:jquery'), true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'async-async-bar-two';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
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
|
+
},
|
|
23
|
+
optimization: {
|
|
24
|
+
runtimeChunk: true,
|
|
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
|
+
providedDependencies,
|
|
35
|
+
verbose: false,
|
|
36
|
+
}),
|
|
37
|
+
new webpack.NamedChunksPlugin(),
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
filename: '[name].js',
|
|
41
|
+
path: OUTPUT_DIR,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
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('async-chunks-of-async-chunks-with-multiple-entrypoints', function() {
|
|
11
|
+
const config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
let stats;
|
|
14
|
+
let runtime;
|
|
15
|
+
let runtime2;
|
|
16
|
+
let app;
|
|
17
|
+
let app2;
|
|
18
|
+
let splitAppAndApp2;
|
|
19
|
+
let asyncBar;
|
|
20
|
+
let asyncFoo;
|
|
21
|
+
let asyncAsyncBar;
|
|
22
|
+
let asyncAsyncBarTwo;
|
|
23
|
+
let asyncAsyncAsyncBar;
|
|
24
|
+
|
|
25
|
+
function getDependencies(node) {
|
|
26
|
+
return node.children.filter(n => n.name === 'dependency');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getContent(nodes) {
|
|
30
|
+
return nodes.map(n => n.content);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
beforeEach(done => {
|
|
34
|
+
webpack(config, (err, st) => {
|
|
35
|
+
stats = st;
|
|
36
|
+
|
|
37
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
38
|
+
const results = parse(xmlFile);
|
|
39
|
+
runtime = results.root.children.find(n => n.attributes.key === 'entrypoint-app');
|
|
40
|
+
runtime2 = results.root.children.find(n => n.attributes.key === 'entrypoint-app2');
|
|
41
|
+
app = results.root.children.find(n => n.attributes.key === 'split_app');
|
|
42
|
+
app2 = results.root.children.find(n => n.attributes.key === 'split_app2');
|
|
43
|
+
splitAppAndApp2 = results.root.children.find(n => n.attributes.key === 'split_app~app2');
|
|
44
|
+
asyncBar = results.root.children.find(n => n.attributes.key === 'async-bar');
|
|
45
|
+
asyncFoo = results.root.children.find(n => n.attributes.key === 'async-foo');
|
|
46
|
+
asyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-bar');
|
|
47
|
+
asyncAsyncBarTwo = results.root.children.find(n => n.attributes.key === 'async-async-bar-two');
|
|
48
|
+
asyncAsyncAsyncBar = results.root.children.find(n => n.attributes.key === 'async-async-async-bar');
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create a webresource for each async chunk', () => {
|
|
54
|
+
assert.ok(runtime, 'runtime does not exist');
|
|
55
|
+
assert.ok(runtime2, 'runtime2 does not exist');
|
|
56
|
+
assert.ok(app, 'app does not exist');
|
|
57
|
+
assert.ok(app2, 'app2 does not exist');
|
|
58
|
+
assert.ok(splitAppAndApp2, 'splitAppAndApp2 does not exist');
|
|
59
|
+
assert.ok(asyncBar, '"async-bar" does not exist');
|
|
60
|
+
assert.ok(asyncFoo, '"async-foo" does not exist');
|
|
61
|
+
assert.ok(asyncAsyncBar, '"async-async-bar" does not exist');
|
|
62
|
+
assert.ok(asyncAsyncBarTwo, '"async-async-bar-two" does not exist');
|
|
63
|
+
assert.ok(asyncAsyncAsyncBar, '"async-async-async-bar" does not exist');
|
|
64
|
+
assert.equal(stats.hasErrors(), false, 'should not have errors');
|
|
65
|
+
assert.equal(stats.hasWarnings(), false, 'should not have warnings');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should inject a WRM pre-condition checker into the webpack runtime', () => {
|
|
69
|
+
// setup
|
|
70
|
+
const bundleFile = fs.readFileSync(path.join(targetDir, 'runtime~app.js'), 'utf-8');
|
|
71
|
+
const expectedRuntimeAdjustment = `
|
|
72
|
+
/******/ var promises = [];
|
|
73
|
+
/******/
|
|
74
|
+
/******/ if(installedChunks[chunkId] === 0) { // 0 means "already installed".
|
|
75
|
+
/******/ return Promise.resolve();
|
|
76
|
+
/******/ }
|
|
77
|
+
/******/
|
|
78
|
+
/******/ if (installedChunks[chunkId]) {
|
|
79
|
+
/******/ return installedChunks[chunkId][2];
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/
|
|
82
|
+
/******/ promises.push(
|
|
83
|
+
/******/ new Promise(function(resolve, reject) {
|
|
84
|
+
/******/ installedChunks[chunkId] = [resolve, reject];
|
|
85
|
+
/******/ }),
|
|
86
|
+
/******/ new Promise(function(resolve, reject) {
|
|
87
|
+
/******/ WRM.require('wrc!com.atlassian.plugin.test:' + chunkId).then(resolve, reject);
|
|
88
|
+
/******/ })
|
|
89
|
+
/******/ );
|
|
90
|
+
/******/ return installedChunks[chunkId][2] = Promise.all(promises);`;
|
|
91
|
+
|
|
92
|
+
assert.include(bundleFile, expectedRuntimeAdjustment);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('dependencies per web-resource', () => {
|
|
96
|
+
let runtimeDeps;
|
|
97
|
+
let runtimeDeps2;
|
|
98
|
+
let appDeps;
|
|
99
|
+
let appDeps2;
|
|
100
|
+
let splitAppAndApp2Deps;
|
|
101
|
+
let asyncBarDeps;
|
|
102
|
+
let asyncFooDeps;
|
|
103
|
+
let asyncAsyncBarDeps;
|
|
104
|
+
let asyncAsyncBarTwoDeps;
|
|
105
|
+
let asyncAsyncAsyncBarDeps;
|
|
106
|
+
|
|
107
|
+
beforeEach(() => {
|
|
108
|
+
runtimeDeps = getContent(getDependencies(runtime));
|
|
109
|
+
runtimeDeps2 = getContent(getDependencies(runtime2));
|
|
110
|
+
appDeps = getContent(getDependencies(app));
|
|
111
|
+
appDeps2 = getContent(getDependencies(app2));
|
|
112
|
+
splitAppAndApp2Deps = getContent(getDependencies(splitAppAndApp2));
|
|
113
|
+
asyncBarDeps = getContent(getDependencies(asyncBar));
|
|
114
|
+
asyncFooDeps = getContent(getDependencies(asyncFoo));
|
|
115
|
+
asyncAsyncBarDeps = getContent(getDependencies(asyncAsyncBar));
|
|
116
|
+
asyncAsyncBarTwoDeps = getContent(getDependencies(asyncAsyncBarTwo));
|
|
117
|
+
asyncAsyncAsyncBarDeps = getContent(getDependencies(asyncAsyncAsyncBar));
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('adds the correct split chunk dependencies to the entrypoints', () => {
|
|
121
|
+
assert.include(runtimeDeps, 'com.atlassian.plugin.test:split_app~app2');
|
|
122
|
+
assert.include(runtimeDeps, 'com.atlassian.plugin.test:split_app');
|
|
123
|
+
|
|
124
|
+
assert.include(runtimeDeps2, 'com.atlassian.plugin.test:split_app~app2');
|
|
125
|
+
assert.include(runtimeDeps2, 'com.atlassian.plugin.test:split_app2');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('adds shared provided dependencies only to the entry point', () => {
|
|
129
|
+
assert.include(splitAppAndApp2Deps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
130
|
+
|
|
131
|
+
assert.notInclude(runtimeDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
132
|
+
assert.notInclude(runtimeDeps2, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
133
|
+
assert.notInclude(appDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
134
|
+
assert.notInclude(appDeps2, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
135
|
+
assert.notInclude(asyncBarDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
136
|
+
assert.notInclude(asyncFooDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
137
|
+
assert.notInclude(asyncAsyncBarDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
138
|
+
assert.notInclude(asyncAsyncBarTwoDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
139
|
+
assert.notInclude(asyncAsyncAsyncBarDeps, 'com.atlassian.plugin.jslibs:underscore-1.4.4');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('adds async-chunk-only deps only to the async-chunk-webresource', () => {
|
|
143
|
+
assert.include(asyncBarDeps, 'jira.webresources:jquery');
|
|
144
|
+
|
|
145
|
+
assert.notInclude(splitAppAndApp2Deps, 'jira.webresources:jquery');
|
|
146
|
+
assert.notInclude(runtimeDeps, 'jira.webresources:jquery');
|
|
147
|
+
assert.notInclude(runtimeDeps2, 'jira.webresources:jquery');
|
|
148
|
+
assert.notInclude(appDeps, 'jira.webresources:jquery');
|
|
149
|
+
assert.notInclude(appDeps2, 'jira.webresources:jquery');
|
|
150
|
+
assert.notInclude(asyncFooDeps, 'jira.webresources:jquery');
|
|
151
|
+
assert.notInclude(asyncAsyncBarDeps, 'jira.webresources:jquery');
|
|
152
|
+
assert.notInclude(asyncAsyncBarTwoDeps, 'jira.webresources:jquery');
|
|
153
|
+
assert.notInclude(asyncAsyncAsyncBarDeps, 'jira.webresources:jquery');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'async-async-bar-two';
|
package/test/use-cases/async-chunks-of-async-chunks-with-multiple-entrypoints/webpack.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
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
|
+
entry: {
|
|
20
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
21
|
+
app2: path.join(FRONTEND_SRC_DIR, 'app2.js'),
|
|
22
|
+
},
|
|
23
|
+
optimization: {
|
|
24
|
+
runtimeChunk: true,
|
|
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
|
+
providedDependencies,
|
|
35
|
+
verbose: false,
|
|
36
|
+
}),
|
|
37
|
+
new webpack.NamedChunksPlugin(),
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
filename: '[name].js',
|
|
41
|
+
path: OUTPUT_DIR,
|
|
42
|
+
},
|
|
43
|
+
};
|