@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,216 @@
|
|
|
1
|
+
const chai = require('chai');
|
|
2
|
+
const parse = require('xml-parser');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
chai.use(require('chai-uuid'));
|
|
8
|
+
const assert = chai.assert;
|
|
9
|
+
|
|
10
|
+
const targetDir = path.join(__dirname, 'target');
|
|
11
|
+
const webresourceOutput = path.join(targetDir, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml');
|
|
12
|
+
|
|
13
|
+
const uuidLength = require('uuid/v4')().length;
|
|
14
|
+
|
|
15
|
+
describe('split-chunks-with-tests', function() {
|
|
16
|
+
this.timeout(10000);
|
|
17
|
+
const config = require('./webpack.config.js');
|
|
18
|
+
|
|
19
|
+
let stats;
|
|
20
|
+
let error;
|
|
21
|
+
let entryApp;
|
|
22
|
+
let entryApp2;
|
|
23
|
+
let splitChunkShared;
|
|
24
|
+
let testEntryApp;
|
|
25
|
+
let testEntryApp2;
|
|
26
|
+
|
|
27
|
+
function getChild(node, name) {
|
|
28
|
+
return node.children.filter(n => n.name === name);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getContent(nodes) {
|
|
32
|
+
return nodes.map(n => n.content);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getAttribute(nodes, attribute) {
|
|
36
|
+
return nodes.map(n => n.attributes[attribute]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
before(done => {
|
|
40
|
+
webpack(config, (err, st) => {
|
|
41
|
+
error = err;
|
|
42
|
+
stats = st;
|
|
43
|
+
|
|
44
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
45
|
+
const results = parse(xmlFile);
|
|
46
|
+
entryApp = results.root.children.find(n => n.attributes.key === 'entrypoint-app');
|
|
47
|
+
entryApp2 = results.root.children.find(n => n.attributes.key === 'entrypoint-app2');
|
|
48
|
+
splitChunkShared = results.root.children.find(n => n.attributes.key === 'split_app~app2');
|
|
49
|
+
testEntryApp = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app');
|
|
50
|
+
testEntryApp2 = results.root.children.find(n => n.attributes.key === '__test__entrypoint-app2');
|
|
51
|
+
done();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should create a webresources with dependencies and resources as appropriate', () => {
|
|
56
|
+
assert.ok(entryApp, 'has entrypoint for app');
|
|
57
|
+
assert.ok(entryApp2, 'has entrypoint for app2');
|
|
58
|
+
assert.ok(splitChunkShared, 'has entrypoint for split chunk');
|
|
59
|
+
|
|
60
|
+
assert.equal(error, null, 'has no error output');
|
|
61
|
+
assert.equal(stats.hasErrors(), false, 'has no errors');
|
|
62
|
+
assert.equal(stats.hasWarnings(), false, 'has no warnings');
|
|
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~app2', 'expected dependency not found');
|
|
102
|
+
assert.include(depsApp2, 'com.atlassian.plugin.test:split_app~app2', 'expected dependency not found');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('test web-resources', () => {
|
|
107
|
+
let depsTestApp;
|
|
108
|
+
let depsTestApp2;
|
|
109
|
+
let resourcesTestApp;
|
|
110
|
+
let resourcesTestApp2;
|
|
111
|
+
beforeEach(() => {
|
|
112
|
+
depsTestApp = getContent(getChild(testEntryApp, 'dependency'));
|
|
113
|
+
depsTestApp2 = getContent(getChild(testEntryApp2, 'dependency'));
|
|
114
|
+
resourcesTestApp = getAttribute(getChild(testEntryApp, 'resource'), 'name');
|
|
115
|
+
resourcesTestApp2 = getAttribute(getChild(testEntryApp2, 'resource'), 'name');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should contain the dependencies as specified in the split chunks', () => {
|
|
119
|
+
assert.include(depsTestApp, 'jira.webresources:jquery', 'expected dependency not found');
|
|
120
|
+
assert.include(
|
|
121
|
+
depsTestApp,
|
|
122
|
+
'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
123
|
+
'expected dependency not found'
|
|
124
|
+
);
|
|
125
|
+
assert.include(depsTestApp2, 'jira.webresources:jquery', 'expected dependency not found');
|
|
126
|
+
assert.include(
|
|
127
|
+
depsTestApp2,
|
|
128
|
+
'com.atlassian.plugin.jslibs:underscore-1.4.4',
|
|
129
|
+
'expected dependency not found'
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should contain the resources as specified in its entry point - including those from split chunks', () => {
|
|
134
|
+
const extLength = 3;
|
|
135
|
+
|
|
136
|
+
const assetsResourceKeyApp1 = resourcesTestApp[0];
|
|
137
|
+
const assetsResourcePrefixApp1 = assetsResourceKeyApp1.substr(
|
|
138
|
+
0,
|
|
139
|
+
assetsResourceKeyApp1.length - uuidLength - extLength
|
|
140
|
+
);
|
|
141
|
+
const assetsResourceUuidApp1 = assetsResourceKeyApp1.substr(-(uuidLength + extLength), uuidLength);
|
|
142
|
+
|
|
143
|
+
assert.strictEqual(assetsResourcePrefixApp1, 'qunit-require-shim-', 'expected resource not found');
|
|
144
|
+
assert.uuid(assetsResourceUuidApp1, 'v4', 'expected resource not found');
|
|
145
|
+
|
|
146
|
+
assert.strictEqual(
|
|
147
|
+
resourcesTestApp[1],
|
|
148
|
+
'test/use-cases/split-chunks-with-tests/src/bar.js',
|
|
149
|
+
'expected resource not found'
|
|
150
|
+
);
|
|
151
|
+
assert.strictEqual(
|
|
152
|
+
resourcesTestApp[2],
|
|
153
|
+
'test/use-cases/split-chunks-with-tests/src/foo.js',
|
|
154
|
+
'expected resource not found'
|
|
155
|
+
);
|
|
156
|
+
assert.strictEqual(
|
|
157
|
+
resourcesTestApp[3],
|
|
158
|
+
'test/use-cases/split-chunks-with-tests/src/app.js',
|
|
159
|
+
'expected resource not found'
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const assetsResourceKeyApp2 = resourcesTestApp[0];
|
|
163
|
+
const assetsResourcePrefixApp2 = assetsResourceKeyApp2.substr(
|
|
164
|
+
0,
|
|
165
|
+
assetsResourceKeyApp2.length - uuidLength - extLength
|
|
166
|
+
);
|
|
167
|
+
const assetsResourceUuidApp2 = assetsResourceKeyApp2.substr(-(uuidLength + extLength), uuidLength);
|
|
168
|
+
|
|
169
|
+
assert.strictEqual(assetsResourcePrefixApp2, 'qunit-require-shim-', 'expected resource not found');
|
|
170
|
+
assert.uuid(assetsResourceUuidApp2, 'v4', 'expected resource not found');
|
|
171
|
+
|
|
172
|
+
assert.strictEqual(
|
|
173
|
+
resourcesTestApp2[1],
|
|
174
|
+
'test/use-cases/split-chunks-with-tests/src/bar.js',
|
|
175
|
+
'expected resource not found'
|
|
176
|
+
);
|
|
177
|
+
assert.strictEqual(
|
|
178
|
+
resourcesTestApp2[2],
|
|
179
|
+
'test/use-cases/split-chunks-with-tests/src/foo2.js',
|
|
180
|
+
'expected resource not found'
|
|
181
|
+
);
|
|
182
|
+
assert.strictEqual(
|
|
183
|
+
resourcesTestApp2[3],
|
|
184
|
+
'test/use-cases/split-chunks-with-tests/src/app2.js',
|
|
185
|
+
'expected resource not found'
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
assert.strictEqual(resourcesTestApp.length, 4, 'unexpected number of resources');
|
|
189
|
+
assert.strictEqual(resourcesTestApp2.length, 4, 'unexpected number of resources');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should not contain resources from other entry points', () => {
|
|
193
|
+
assert.notInclude(
|
|
194
|
+
resourcesTestApp2,
|
|
195
|
+
'test/use-cases/split-chunks-with-tests/src/foo.js',
|
|
196
|
+
'unexpected resource found'
|
|
197
|
+
);
|
|
198
|
+
assert.notInclude(
|
|
199
|
+
resourcesTestApp2,
|
|
200
|
+
'test/use-cases/split-chunks-with-tests/src/app.js',
|
|
201
|
+
'unexpected resource found'
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
assert.notInclude(
|
|
205
|
+
resourcesTestApp,
|
|
206
|
+
'test/use-cases/split-chunks-with-tests/src/foo2.js',
|
|
207
|
+
'unexpected resource found'
|
|
208
|
+
);
|
|
209
|
+
assert.notInclude(
|
|
210
|
+
resourcesTestApp,
|
|
211
|
+
'test/use-cases/split-chunks-with-tests/src/app2.js',
|
|
212
|
+
'unexpected resource found'
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// nothing
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// nothing
|
|
@@ -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: 'production',
|
|
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
|
+
verbose: false,
|
|
35
|
+
providedDependencies,
|
|
36
|
+
__testGlobs__: ['**/split-chunks-with-tests/src/*_test.js'],
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
output: {
|
|
40
|
+
filename: '[name].js',
|
|
41
|
+
path: OUTPUT_DIR,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'x';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'y';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const assert = require('chai').assert;
|
|
2
|
+
const PrettyData = require('pretty-data').pd;
|
|
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('standalone', 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('xml-descriptor', function() {
|
|
26
|
+
let xmlFile;
|
|
27
|
+
|
|
28
|
+
before(done => {
|
|
29
|
+
webpack(config, (err, stats) => {
|
|
30
|
+
xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
31
|
+
done();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('is lean', function() {
|
|
36
|
+
assert.equal(
|
|
37
|
+
xmlFile,
|
|
38
|
+
PrettyData.xml(
|
|
39
|
+
`
|
|
40
|
+
<bundles>
|
|
41
|
+
<web-resource key="entrypoint-standalone-1">
|
|
42
|
+
<resource type="download" name="standalone-1.js" location="standalone-1.js"/>
|
|
43
|
+
</web-resource>
|
|
44
|
+
<web-resource key="entrypoint-standalone-2">
|
|
45
|
+
<resource type="download" name="standalone-2.js" location="standalone-2.js"/>
|
|
46
|
+
</web-resource>
|
|
47
|
+
</bundles>
|
|
48
|
+
`
|
|
49
|
+
).trim()
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
'standalone-1': path.join(FRONTEND_SRC_DIR, 'standalone-1.js'),
|
|
11
|
+
'standalone-2': path.join(FRONTEND_SRC_DIR, 'standalone-2.js'),
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
new WrmPlugin({
|
|
15
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
16
|
+
xmlDescriptors: path.join(__dirname, 'target', 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
17
|
+
verbose: false,
|
|
18
|
+
standalone: true,
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
output: {
|
|
22
|
+
filename: '[name].js',
|
|
23
|
+
path: path.resolve(OUTPUT_DIR),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src-amd');
|
|
4
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: {
|
|
9
|
+
'app-amd': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
},
|
|
11
|
+
plugins: [
|
|
12
|
+
new WrmPlugin({
|
|
13
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
14
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
15
|
+
verbose: false,
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
output: {
|
|
19
|
+
filename: '[name].js',
|
|
20
|
+
path: OUTPUT_DIR,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src-es6');
|
|
4
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: {
|
|
9
|
+
'app-es6': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
},
|
|
11
|
+
plugins: [
|
|
12
|
+
new WrmPlugin({
|
|
13
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
14
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
15
|
+
verbose: false,
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
output: {
|
|
19
|
+
filename: '[name].js',
|
|
20
|
+
path: OUTPUT_DIR,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
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('wrm-dependency-loading', function() {
|
|
11
|
+
let stats;
|
|
12
|
+
let entry;
|
|
13
|
+
let dependencies;
|
|
14
|
+
|
|
15
|
+
function getDependencies(node) {
|
|
16
|
+
return node.children.filter(n => n.name === 'dependency');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getContent(nodes) {
|
|
20
|
+
return nodes.map(n => n.content);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function runWebpack(config, done) {
|
|
24
|
+
webpack(config, (err, st) => {
|
|
25
|
+
stats = st;
|
|
26
|
+
|
|
27
|
+
const xmlFile = fs.readFileSync(webresourceOutput, 'utf-8');
|
|
28
|
+
const results = parse(xmlFile);
|
|
29
|
+
entry = results.root.children.find(n => n.attributes.key.startsWith('entry'));
|
|
30
|
+
dependencies = getContent(getDependencies(entry));
|
|
31
|
+
done();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function runTheTestsFor(config) {
|
|
36
|
+
beforeEach(done => runWebpack(config, done));
|
|
37
|
+
|
|
38
|
+
it('should create a webresource with dependencies', () => {
|
|
39
|
+
assert.ok(entry);
|
|
40
|
+
assert.ok(dependencies);
|
|
41
|
+
assert.equal(stats.hasErrors(), false);
|
|
42
|
+
assert.equal(stats.hasWarnings(), false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('add a dependency for each requested web-resource', () => {
|
|
46
|
+
assert.include(dependencies, 'some.weird:web-resource');
|
|
47
|
+
assert.include(dependencies, 'foo-bar:baz');
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('in ES6 modules', function() {
|
|
52
|
+
const config = require('./webpack.config.es6.js');
|
|
53
|
+
runTheTestsFor(config);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('in AMD', function() {
|
|
57
|
+
const config = require('./webpack.config.amd.js');
|
|
58
|
+
runTheTestsFor(config);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src');
|
|
4
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: {
|
|
9
|
+
app: path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
app2: path.join(FRONTEND_SRC_DIR, 'app2.js'),
|
|
11
|
+
},
|
|
12
|
+
plugins: [
|
|
13
|
+
new WrmPlugin({
|
|
14
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
15
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
16
|
+
verbose: false,
|
|
17
|
+
wrmManifestPath: path.join(OUTPUT_DIR, 'manifest.json'),
|
|
18
|
+
webresourceKeyMap: { app2: 'app2-custom-entrypoint-name' },
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
output: {
|
|
22
|
+
filename: '[name].js',
|
|
23
|
+
path: OUTPUT_DIR,
|
|
24
|
+
library: '[name]-with-a-custom-library-name',
|
|
25
|
+
libraryTarget: 'amd',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 wrmManifestOutput = path.join(targetDir, 'manifest.json');
|
|
9
|
+
|
|
10
|
+
describe('wrm-manifest-path', function() {
|
|
11
|
+
let config = require('./webpack.config.js');
|
|
12
|
+
|
|
13
|
+
it('generates a manifest JSON 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(wrmManifestOutput), true);
|
|
21
|
+
done();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('contains all entrypoints', done => {
|
|
26
|
+
webpack(config, err => {
|
|
27
|
+
if (err) {
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const wrmManifest = require(wrmManifestOutput).providedDependencies;
|
|
32
|
+
const entries = Object.getOwnPropertyNames(wrmManifest);
|
|
33
|
+
assert.equal(entries.length, 2);
|
|
34
|
+
assert.equal(wrmManifest.app.dependency, 'com.atlassian.plugin.test:entrypoint-app');
|
|
35
|
+
assert.equal(wrmManifest.app2.dependency, 'com.atlassian.plugin.test:app2-custom-entrypoint-name');
|
|
36
|
+
|
|
37
|
+
done();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('handles custom library [name]s', done => {
|
|
42
|
+
webpack(config, err => {
|
|
43
|
+
if (err) {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const wrmManifest = require(wrmManifestOutput).providedDependencies;
|
|
48
|
+
assert.equal(wrmManifest.app.import.var, `require('app-with-a-custom-library-name')`);
|
|
49
|
+
assert.equal(wrmManifest.app.import.amd, 'app-with-a-custom-library-name');
|
|
50
|
+
|
|
51
|
+
assert.equal(wrmManifest.app2.import.var, `require('app2-with-a-custom-library-name')`);
|
|
52
|
+
assert.equal(wrmManifest.app2.import.amd, 'app2-with-a-custom-library-name');
|
|
53
|
+
|
|
54
|
+
done();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
define('my-app', ['require', 'wr-resource!ultimate/name/at/runtime.css!src-amd/styles.less'], function(req) {
|
|
2
|
+
req('wr-resource!ultimate/name/at/runtime.js!src-amd/template.soy');
|
|
3
|
+
|
|
4
|
+
// the MySoyTemplateNamespace would be provided via the soy file. It's currently a side-effect of its generation.
|
|
5
|
+
document.body.innerHTML = MySoyTemplateNamespace.Example.sayHello({ name: 'world' });
|
|
6
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import 'wr-resource!ultimate/name/at/runtime.js!src-es6/template.soy';
|
|
2
|
+
import 'wr-resource!ultimate/name/at/runtime.css!src-es6/styles.less';
|
|
3
|
+
|
|
4
|
+
// the MySoyTemplateNamespace would be provided via the soy file. It's currently a side-effect of its generation.
|
|
5
|
+
document.body.innerHTML = MySoyTemplateNamespace.Example.sayHello({ name: 'world' });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import 'wr-resource!ultimate/name/at/runtime.js!./template.soy';
|
|
2
|
+
import 'wr-resource!ultimate/name/at/runtime.css!./styles.less';
|
|
3
|
+
|
|
4
|
+
// the MySoyTemplateNamespace would be provided via the soy file. It's currently a side-effect of its generation.
|
|
5
|
+
document.body.innerHTML = MySoyTemplateNamespace.Example.sayHello({ name: 'world' });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const WrmPlugin = require('../../../src/WrmPlugin');
|
|
3
|
+
const FRONTEND_SRC_DIR = path.join(__dirname, 'src-amd');
|
|
4
|
+
const OUTPUT_DIR = path.join(__dirname, 'target');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'development',
|
|
8
|
+
entry: {
|
|
9
|
+
'app-amd': path.join(FRONTEND_SRC_DIR, 'app.js'),
|
|
10
|
+
},
|
|
11
|
+
context: __dirname,
|
|
12
|
+
plugins: [
|
|
13
|
+
new WrmPlugin({
|
|
14
|
+
pluginKey: 'com.atlassian.plugin.test',
|
|
15
|
+
xmlDescriptors: path.join(OUTPUT_DIR, 'META-INF', 'plugin-descriptor', 'wr-webpack-bundles.xml'),
|
|
16
|
+
verbose: false,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
output: {
|
|
20
|
+
filename: '[name].js',
|
|
21
|
+
path: OUTPUT_DIR,
|
|
22
|
+
},
|
|
23
|
+
};
|