@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
package/RELEASE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Release
|
|
2
|
+
|
|
3
|
+
The only supported release branch in this repo is `release/4.x` which is only maintained for legacy purposes. All the new development should be done in https://bitbucket.org/atlassianlabs/fe-server/src/master/packages/webresource-webpack-plugin/
|
|
4
|
+
|
|
5
|
+
## Stable release
|
|
6
|
+
|
|
7
|
+
1. After merging to `release/4.x`, navigate to the [Bamboo](https://ecosystem-bamboo.internal.atlassian.com/browse/WRWP-WRWPB4X).
|
|
8
|
+
2. Run `Release` stage to create a new stable release.
|
|
9
|
+
3. Override `release.version` variable to set the version
|
|
10
|
+
4. New release will be available on [npmjs](https://www.npmjs.com/package/atlassian-webresource-webpack-plugin?activeTab=versions) with `stable-4` tag.
|
|
11
|
+
|
|
12
|
+
## Hash release
|
|
13
|
+
|
|
14
|
+
1. Navigate to the Bamboo pipeline running on your feature branch
|
|
15
|
+
2. Run `Release` stage to create a new hash release
|
|
16
|
+
3. Override `release.version` variable to set the version
|
|
17
|
+
4. Override `release.versionSuffix` variable to set the suffix (defaults to last commit hash)
|
package/package.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlassian/webresource-webpack-plugin",
|
|
3
|
+
"version": "4.10.2-64a2ef2",
|
|
4
|
+
"description": "Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.",
|
|
5
|
+
"main": "src/WrmPlugin.js",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Tim Sebastian",
|
|
10
|
+
"email": "tsebastian@atlassian.com"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Felipe Reis",
|
|
14
|
+
"email": "freis@atlassian.com"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Scott Harwood",
|
|
18
|
+
"email": "sharwood@atlassian.com"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Christopher Darroch",
|
|
22
|
+
"email": "cdarroch@atlassian.com"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Maciej Adamczak",
|
|
26
|
+
"email": "madamczak@atlassian.com"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Felipe Reis",
|
|
30
|
+
"email": "freis@atlassian.com"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Dariusz Luksza",
|
|
34
|
+
"email": "dluksza@adaptavist.com"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Dick Wiggers",
|
|
38
|
+
"email": "hwiggers@atlassian.com"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Matthieu Di Berardino",
|
|
42
|
+
"email": "mdiberardino@atlassian.com"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "Pietro Pereira",
|
|
46
|
+
"email": "ppereira@atlassian.com"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"homepage": "https://bitbucket.org/atlassianlabs/atlassian-webresource-webpack-plugin",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://bitbucket.org/atlassianlabs/atlassian-webresource-webpack-plugin.git"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://bitbucket.org/atlassianlabs/atlassian-webresource-webpack-plugin/issues"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"glob": "^7.1.2",
|
|
59
|
+
"lodash": "^4.17.15",
|
|
60
|
+
"mkdirp": "^0.5.1",
|
|
61
|
+
"pretty-data": "^0.40.0",
|
|
62
|
+
"tapable": "^1.1.0",
|
|
63
|
+
"url-join": "^4.0.0",
|
|
64
|
+
"uuid": "^3.3.2",
|
|
65
|
+
"webpack-merge": "^4.2.2",
|
|
66
|
+
"webpack-sources": "^1.1.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"babel-eslint": "^10.0.1",
|
|
70
|
+
"chai": "^4.2.0",
|
|
71
|
+
"chai-string": "^1.5.0",
|
|
72
|
+
"chai-uuid": "^1.0.6",
|
|
73
|
+
"css-loader": "^1.0.1",
|
|
74
|
+
"eslint": "^5.9.0",
|
|
75
|
+
"eslint-config-prettier": "^3.3.0",
|
|
76
|
+
"eslint-plugin-babel": "^5.2.1",
|
|
77
|
+
"eslint-plugin-filenames": "^1.3.2",
|
|
78
|
+
"eslint-plugin-jasmine": "^2.10.1",
|
|
79
|
+
"eslint-plugin-mocha": "^5.2.0",
|
|
80
|
+
"eslint-plugin-node": "^8.0.0",
|
|
81
|
+
"eslint-plugin-prettier": "^3.0.0",
|
|
82
|
+
"extract-text-webpack-plugin": "4.0.0-beta.0",
|
|
83
|
+
"file-loader": "^2.0.0",
|
|
84
|
+
"jquery": "^3.4.1",
|
|
85
|
+
"mini-css-extract-plugin": "^0.4.4",
|
|
86
|
+
"mocha": "^5.2.0",
|
|
87
|
+
"mocha-junit-reporter": "^1.18.0",
|
|
88
|
+
"prettier": "^1.15.2",
|
|
89
|
+
"prettier-eslint": "^8.8.2",
|
|
90
|
+
"style-loader": "^0.23.1",
|
|
91
|
+
"underscore": "^1.9.1",
|
|
92
|
+
"webpack": "^4.41.3",
|
|
93
|
+
"webpack-cli": "^3.1.2",
|
|
94
|
+
"xml-parser": "^1.2.1"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"webpack": "^4"
|
|
98
|
+
},
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=8.12.0",
|
|
101
|
+
"npm": ">=6.9.0"
|
|
102
|
+
},
|
|
103
|
+
"keywords": [
|
|
104
|
+
"atlassian",
|
|
105
|
+
"webpack",
|
|
106
|
+
"wrm",
|
|
107
|
+
"server",
|
|
108
|
+
"web",
|
|
109
|
+
"webresource",
|
|
110
|
+
"resource",
|
|
111
|
+
"manager"
|
|
112
|
+
],
|
|
113
|
+
"scripts": {
|
|
114
|
+
"lint": "eslint .",
|
|
115
|
+
"lint:fix": "eslint . --fix",
|
|
116
|
+
"test": "mocha 'test/**/*.test.js'"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const {
|
|
2
|
+
getConditionForEntry,
|
|
3
|
+
getDataProvidersForEntry,
|
|
4
|
+
getContextForEntry,
|
|
5
|
+
getWebresourceAttributesForEntry,
|
|
6
|
+
} = require('./helpers/web-resource-entrypoints');
|
|
7
|
+
const flattenReduce = require('./flattenReduce');
|
|
8
|
+
const WebpackHelpers = require('./WebpackHelpers');
|
|
9
|
+
const { getBaseDependencies } = require('./settings/base-dependencies');
|
|
10
|
+
|
|
11
|
+
const RUNTIME_WR_KEY = 'common-runtime';
|
|
12
|
+
|
|
13
|
+
module.exports = class AppResources {
|
|
14
|
+
constructor(assetsUUID, assetNames, options, compiler, compilation) {
|
|
15
|
+
this.assetsUUID = assetsUUID;
|
|
16
|
+
this.assetNames = assetNames;
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.compiler = compiler;
|
|
19
|
+
this.compilation = compilation;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
isSingleRuntime() {
|
|
23
|
+
const options = this.compiler.options;
|
|
24
|
+
const runtimeChunkCfg = options.optimization && options.optimization.runtimeChunk;
|
|
25
|
+
return runtimeChunkCfg && runtimeChunkCfg.name && typeof runtimeChunkCfg.name === 'string';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getSingleRuntimeFiles(entrypoints) {
|
|
29
|
+
return Array.from(entrypoints.values())
|
|
30
|
+
.map(entrypoint => entrypoint.runtimeChunk.files)
|
|
31
|
+
.find(Boolean);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getAssetResourceDescriptor() {
|
|
35
|
+
const assetFiles = Object.keys(this.compilation.assets).filter(p => !/\.(js|css|soy)(\.map)?$/.test(p)); // remove anything that we know is handled differently
|
|
36
|
+
|
|
37
|
+
const assets = {
|
|
38
|
+
attributes: { key: `assets-${this.assetsUUID}` },
|
|
39
|
+
resources: assetFiles,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return assets;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Every entrypoint has an attribute called "chunks".
|
|
47
|
+
* This contains all chunks that are needed to successfully "load" this entrypoint.
|
|
48
|
+
* Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
|
|
49
|
+
* If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
|
|
50
|
+
* To get all split chunks we need to get all but the entrypoints "runtimeChunk" which is the chunk solely containing code for this entrypoint and its runtime.
|
|
51
|
+
*
|
|
52
|
+
* IMPORTANT-NOTE: async-chunks required by this entrypoint are not specified in these chunks but in the childGroups of the entry and/or split chunks.
|
|
53
|
+
*/
|
|
54
|
+
getSyncSplitChunks() {
|
|
55
|
+
const entryPoints = [...this.compilation.entrypoints.values()];
|
|
56
|
+
const syncSplitChunks = entryPoints.map(e => e.chunks.filter(c => c !== e.runtimeChunk));
|
|
57
|
+
|
|
58
|
+
return Array.from(new Set(syncSplitChunks.reduce(flattenReduce, [])));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create a key and the fully-qualified web-resource descriptor for every split chunk.
|
|
63
|
+
* This is needed to point to reference these chunks as dependency in the entrypoint chunks
|
|
64
|
+
*
|
|
65
|
+
* <web-resource>
|
|
66
|
+
* ...
|
|
67
|
+
* <dependency>this-plugin-key:split_some_chunk</dependency>
|
|
68
|
+
* ...
|
|
69
|
+
*/
|
|
70
|
+
getSyncSplitChunkDependenciesKeyMap(pluginKey, syncSplitChunks) {
|
|
71
|
+
const syncSplitChunkDependencyKeyMap = new Map();
|
|
72
|
+
for (const c of syncSplitChunks) {
|
|
73
|
+
const chunkIdentifier = WebpackHelpers.getChunkIdentifier(c);
|
|
74
|
+
const webResourceKey = `split_${chunkIdentifier}`;
|
|
75
|
+
syncSplitChunkDependencyKeyMap.set(chunkIdentifier, {
|
|
76
|
+
key: webResourceKey,
|
|
77
|
+
dependency: `${pluginKey}:${webResourceKey}`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return syncSplitChunkDependencyKeyMap;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getSyncSplitChunksResourceDescriptors() {
|
|
85
|
+
const resourceToAssetMap = this.assetNames;
|
|
86
|
+
|
|
87
|
+
const syncSplitChunks = this.getSyncSplitChunks();
|
|
88
|
+
const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(
|
|
89
|
+
this.options.pluginKey,
|
|
90
|
+
syncSplitChunks
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create descriptors for the split chunk web-resources that have to be created.
|
|
95
|
+
* These include - like other chunk-descriptors their assets and external resources etc.
|
|
96
|
+
*/
|
|
97
|
+
const sharedSplitDescriptors = syncSplitChunks.map(c => {
|
|
98
|
+
const additionalFileDeps = WebpackHelpers.getDependencyResourcesFromChunk(c, resourceToAssetMap);
|
|
99
|
+
return {
|
|
100
|
+
attributes: syncSplitChunkDependencyKeyMap.get(WebpackHelpers.getChunkIdentifier(c)),
|
|
101
|
+
externalResources: WebpackHelpers.getExternalResourcesForChunk(c),
|
|
102
|
+
resources: Array.from(new Set(c.files.concat(additionalFileDeps))),
|
|
103
|
+
dependencies: getBaseDependencies().concat(WebpackHelpers.getDependenciesForChunks([c])),
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return sharedSplitDescriptors;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getAsyncChunksResourceDescriptors() {
|
|
111
|
+
const entryPoints = [...this.compilation.entrypoints.values()];
|
|
112
|
+
const resourceToAssetMap = this.assetNames;
|
|
113
|
+
|
|
114
|
+
const asyncChunkDescriptors = WebpackHelpers.getAllAsyncChunks(entryPoints).map(c => {
|
|
115
|
+
const additionalFileDeps = WebpackHelpers.getDependencyResourcesFromChunk(c, resourceToAssetMap);
|
|
116
|
+
return {
|
|
117
|
+
attributes: { key: `${c.id}` },
|
|
118
|
+
externalResources: WebpackHelpers.getExternalResourcesForChunk(c),
|
|
119
|
+
resources: Array.from(new Set(c.files.concat(additionalFileDeps))),
|
|
120
|
+
dependencies: getBaseDependencies().concat(WebpackHelpers.getDependenciesForChunks([c])),
|
|
121
|
+
contexts: this.options.addAsyncNameAsContext && c.name ? [`async-chunk-${c.name}`] : undefined,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return asyncChunkDescriptors;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getEntryPointsResourceDescriptors() {
|
|
129
|
+
const entrypoints = this.compilation.entrypoints;
|
|
130
|
+
const resourceToAssetMap = this.assetNames;
|
|
131
|
+
|
|
132
|
+
const syncSplitChunks = this.getSyncSplitChunks();
|
|
133
|
+
const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(
|
|
134
|
+
this.options.pluginKey,
|
|
135
|
+
syncSplitChunks
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const singleRuntimeWebResourceKey = this.options.singleRuntimeWebResourceKey || RUNTIME_WR_KEY;
|
|
139
|
+
|
|
140
|
+
// Used in prod
|
|
141
|
+
const prodEntryPoints = [...entrypoints].map(([name, entrypoint]) => {
|
|
142
|
+
const webResourceAttrs = getWebresourceAttributesForEntry(name, this.options.webresourceKeyMap);
|
|
143
|
+
const entrypointChunks = entrypoint.chunks;
|
|
144
|
+
const runtimeChunk = entrypoint.runtimeChunk;
|
|
145
|
+
|
|
146
|
+
// Retrieve all split chunks this entrypoint depends on. These must be added as "<dependency>"s to the web-resource of this entrypoint
|
|
147
|
+
const sharedSplitDeps = entrypointChunks
|
|
148
|
+
.map(c => syncSplitChunkDependencyKeyMap.get(WebpackHelpers.getChunkIdentifier(c)))
|
|
149
|
+
.filter(Boolean)
|
|
150
|
+
.map(val => val.dependency);
|
|
151
|
+
|
|
152
|
+
const additionalFileDeps = entrypointChunks.map(c =>
|
|
153
|
+
WebpackHelpers.getDependencyResourcesFromChunk(c, resourceToAssetMap)
|
|
154
|
+
);
|
|
155
|
+
// Construct the list of resources to add to this web-resource
|
|
156
|
+
const resourceList = [].concat(...additionalFileDeps);
|
|
157
|
+
const dependencyList = [].concat(
|
|
158
|
+
getBaseDependencies(),
|
|
159
|
+
WebpackHelpers.getDependenciesForChunks([runtimeChunk]),
|
|
160
|
+
sharedSplitDeps
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (this.isSingleRuntime()) {
|
|
164
|
+
dependencyList.unshift(`${this.options.pluginKey}:${singleRuntimeWebResourceKey}`);
|
|
165
|
+
} else {
|
|
166
|
+
resourceList.unshift(...runtimeChunk.files);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
attributes: webResourceAttrs,
|
|
171
|
+
contexts: getContextForEntry(name, this.options.contextMap, this.options.addEntrypointNameAsContext),
|
|
172
|
+
conditions: getConditionForEntry(name, this.options.conditionMap),
|
|
173
|
+
dataProviders: getDataProvidersForEntry(name, this.options.dataProvidersMap),
|
|
174
|
+
externalResources: WebpackHelpers.getExternalResourcesForChunk(runtimeChunk),
|
|
175
|
+
resources: Array.from(new Set(resourceList)),
|
|
176
|
+
dependencies: Array.from(new Set(dependencyList)),
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (this.isSingleRuntime()) {
|
|
181
|
+
prodEntryPoints.push({
|
|
182
|
+
attributes: { key: singleRuntimeWebResourceKey },
|
|
183
|
+
dependencies: getBaseDependencies(),
|
|
184
|
+
resources: this.getSingleRuntimeFiles(entrypoints),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return prodEntryPoints;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
getResourceDescriptors() {
|
|
192
|
+
return []
|
|
193
|
+
.concat(this.getSyncSplitChunksResourceDescriptors())
|
|
194
|
+
.concat(this.getAsyncChunksResourceDescriptors())
|
|
195
|
+
.concat(this.getEntryPointsResourceDescriptors())
|
|
196
|
+
.concat(this.getAssetResourceDescriptor());
|
|
197
|
+
}
|
|
198
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const glob = require('glob');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const { extractPathPrefixForXml } = require('./helpers/options-parser');
|
|
5
|
+
const { getWebresourceAttributesForEntry } = require('./helpers/web-resource-entrypoints');
|
|
6
|
+
const logger = require('./logger');
|
|
7
|
+
const qUnitRequireMock = require('./shims/qunit-require-shim');
|
|
8
|
+
const WebpackHelpers = require('./WebpackHelpers');
|
|
9
|
+
|
|
10
|
+
const RESOURCE_JOINER = '__RESOURCE__JOINER__';
|
|
11
|
+
module.exports = class QUnitTestResources {
|
|
12
|
+
constructor(assetsUUID, options, compiler, compilation) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.compiler = compiler;
|
|
15
|
+
this.compilation = compilation;
|
|
16
|
+
this.qunitRequireMockPath = `qunit-require-shim-${assetsUUID}.js`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
createAllFileTestWebResources() {
|
|
20
|
+
return [...this.compilation.entrypoints.entries()].map(([name, entryPoint]) => {
|
|
21
|
+
const webResourceAttrs = getWebresourceAttributesForEntry(name, this.options.webresourceKeyMap);
|
|
22
|
+
const allEntryPointChunks = [...entryPoint.chunks, ...WebpackHelpers.getAllAsyncChunks([entryPoint])];
|
|
23
|
+
|
|
24
|
+
const testFiles = Array.from(
|
|
25
|
+
WebpackHelpers.extractAllFilesFromChunks(
|
|
26
|
+
allEntryPointChunks,
|
|
27
|
+
this.compiler.options.context,
|
|
28
|
+
RESOURCE_JOINER
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.map(resource => {
|
|
32
|
+
if (resource.includes(RESOURCE_JOINER)) {
|
|
33
|
+
return resource.split(RESOURCE_JOINER);
|
|
34
|
+
}
|
|
35
|
+
return [resource, resource];
|
|
36
|
+
})
|
|
37
|
+
.map(resourcePair => {
|
|
38
|
+
return { name: resourcePair[0], location: resourcePair[1] };
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// require mock to allow imports like "wr-dependency!context"
|
|
42
|
+
const pathPrefix = extractPathPrefixForXml('');
|
|
43
|
+
testFiles.unshift({
|
|
44
|
+
name: `${pathPrefix}${this.qunitRequireMockPath}`,
|
|
45
|
+
location: `${pathPrefix}${this.qunitRequireMockPath}`,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const testDependencies = Array.from(WebpackHelpers.getDependenciesForChunks(allEntryPointChunks));
|
|
49
|
+
return {
|
|
50
|
+
attributes: { key: `__test__${webResourceAttrs.key}`, name: webResourceAttrs.name },
|
|
51
|
+
externalResources: testFiles,
|
|
52
|
+
dependencies: testDependencies,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
injectQUnitShim() {
|
|
58
|
+
this.compilation.assets[this.qunitRequireMockPath] = {
|
|
59
|
+
source: () => new Buffer(qUnitRequireMock),
|
|
60
|
+
size: () => Buffer.byteLength(qUnitRequireMock),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getTestFiles() {
|
|
65
|
+
const context = this.compiler.options.context;
|
|
66
|
+
const testGlobs = this.options.__testGlobs__;
|
|
67
|
+
|
|
68
|
+
if (!testGlobs) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
logger.warn(`
|
|
73
|
+
******************************************************************************
|
|
74
|
+
The option "__testGlobs__" is only available to allow migrating old code. Consider
|
|
75
|
+
this option deprecated and try to migrate your code to a proper JS-Testrunner.
|
|
76
|
+
******************************************************************************
|
|
77
|
+
`);
|
|
78
|
+
return testGlobs
|
|
79
|
+
.map(g => glob.sync(g, { absolute: true })) // get all matching files
|
|
80
|
+
.reduce((_, _v, _i, files) => {
|
|
81
|
+
// flatten them and make them unique
|
|
82
|
+
const uniqueFiles = new Set([].concat(...files));
|
|
83
|
+
files.length = 0; // prevent further iteration ??MAGNETS??
|
|
84
|
+
return Array.from(uniqueFiles);
|
|
85
|
+
})
|
|
86
|
+
.map(file => path.relative(context, file)); // make them relative to the context
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
const ProvidedExternalDependencyModule = require('./webpack-modules/ProvidedExternalDependencyModule');
|
|
4
|
+
const WrmDependencyModule = require('./webpack-modules/WrmDependencyModule');
|
|
5
|
+
const WrmResourceModule = require('./webpack-modules/WrmResourceModule');
|
|
6
|
+
|
|
7
|
+
const logger = require('./logger');
|
|
8
|
+
const flattenReduce = require('./flattenReduce');
|
|
9
|
+
|
|
10
|
+
module.exports = class WebpackHelpers {
|
|
11
|
+
static getAllAsyncChunks(entryPoints) {
|
|
12
|
+
const seenChunkGroups = new Set();
|
|
13
|
+
const recursivelyGetAllAsyncChunks = chunkGroups => {
|
|
14
|
+
if (!chunkGroups.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return chunkGroups
|
|
19
|
+
.filter(cg => {
|
|
20
|
+
// circuit breaker
|
|
21
|
+
// dont use a chunk group more than once
|
|
22
|
+
const alreadySeen = seenChunkGroups.has(cg);
|
|
23
|
+
seenChunkGroups.add(cg);
|
|
24
|
+
return !alreadySeen;
|
|
25
|
+
})
|
|
26
|
+
.map(cg => [...cg.chunks, ...recursivelyGetAllAsyncChunks(cg.getChildren())])
|
|
27
|
+
.reduce(flattenReduce, []);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// get all async chunks "deep"
|
|
31
|
+
const allAsyncChunks = entryPoints
|
|
32
|
+
.map(e => recursivelyGetAllAsyncChunks(e.getChildren()))
|
|
33
|
+
.reduce(flattenReduce, []);
|
|
34
|
+
|
|
35
|
+
// dedupe
|
|
36
|
+
return Array.from(new Set(allAsyncChunks));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static _getExternalResourceModules(chunk) {
|
|
40
|
+
return chunk
|
|
41
|
+
.getModules()
|
|
42
|
+
.filter(m => m instanceof WrmResourceModule)
|
|
43
|
+
.map(m => m.getResource());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static getExternalResourcesForChunk(chunk) {
|
|
47
|
+
const externalResources = new Set();
|
|
48
|
+
|
|
49
|
+
for (const dep of WebpackHelpers._getExternalResourceModules(chunk)) {
|
|
50
|
+
externalResources.add(dep);
|
|
51
|
+
}
|
|
52
|
+
return Array.from(externalResources);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static _getExternalDependencyModules(chunk) {
|
|
56
|
+
return chunk
|
|
57
|
+
.getModules()
|
|
58
|
+
.filter(m => {
|
|
59
|
+
return m instanceof ProvidedExternalDependencyModule || m instanceof WrmDependencyModule;
|
|
60
|
+
})
|
|
61
|
+
.sort((a, b) => a.index - b.index)
|
|
62
|
+
.map(m => m.getDependency());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static getDependenciesForChunks(chunks) {
|
|
66
|
+
const externalDeps = new Set();
|
|
67
|
+
for (const chunk of chunks) {
|
|
68
|
+
for (const dep of WebpackHelpers._getExternalDependencyModules(chunk)) {
|
|
69
|
+
externalDeps.add(dep);
|
|
70
|
+
}
|
|
71
|
+
// TODO: figure out how to pass this "properly" as a module
|
|
72
|
+
if (chunk.needsWrmRequire) {
|
|
73
|
+
externalDeps.add('com.atlassian.plugins.atlassian-plugins-webresource-rest:web-resource-manager');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return Array.from(externalDeps);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static extractAdditionalAssetsFromChunk(chunk) {
|
|
80
|
+
const ownDeps = chunk.getModules().map(m => m.resource);
|
|
81
|
+
const ownDepsSet = new Set(ownDeps);
|
|
82
|
+
const fileDeps = chunk
|
|
83
|
+
.getModules()
|
|
84
|
+
.filter(m => m.buildInfo.fileDependencies)
|
|
85
|
+
.map(m => [...m.buildInfo.fileDependencies])
|
|
86
|
+
.reduce(flattenReduce, []);
|
|
87
|
+
const fileDepsSet = new Set(fileDeps);
|
|
88
|
+
return Array.from(fileDepsSet).filter(
|
|
89
|
+
filename => !ownDepsSet.has(filename) && !/\.(js|css|soy)(\.map)?$/.test(filename)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static getDependencyResourcesFromChunk(chunk, resourceToAssetMap) {
|
|
94
|
+
const deps = WebpackHelpers.extractAdditionalAssetsFromChunk(chunk);
|
|
95
|
+
return deps.filter(dep => resourceToAssetMap.has(dep)).map(dep => resourceToAssetMap.get(dep));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// get all files used in a chunk
|
|
99
|
+
// this is needed to create a web-resource that can be used by qunit tests.
|
|
100
|
+
// this is a "sledgehammer approach" to avoid having to create an entry point per qunit tests and building it via webpack.
|
|
101
|
+
static extractAllFilesFromChunks(chunks, context, RESOURCE_JOINER) {
|
|
102
|
+
const circularDepCheck = new Set();
|
|
103
|
+
const addModule = (mod, container) => {
|
|
104
|
+
if (circularDepCheck.has(mod)) {
|
|
105
|
+
logger.warn(`
|
|
106
|
+
*********************************************************************************
|
|
107
|
+
Circular dependency detected.
|
|
108
|
+
The module ${mod.userRequest}/${mod.resource} is involved in a circular dependency.
|
|
109
|
+
This might be worth looking into as it could be an issue.
|
|
110
|
+
*********************************************************************************
|
|
111
|
+
|
|
112
|
+
`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
circularDepCheck.add(mod);
|
|
116
|
+
|
|
117
|
+
mod.dependencies
|
|
118
|
+
.map(d => d.module || d.originModule)
|
|
119
|
+
.filter(Boolean)
|
|
120
|
+
.filter(m => {
|
|
121
|
+
// filter out all "virtual" modules that do not reference an actual file (or a wrm web-resource)
|
|
122
|
+
if (m.resource) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
if (m instanceof WrmResourceModule) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
.filter(actualModule => !actualModule.resource || !actualModule.resource.includes('node_modules')) // if it references a file remove it if it comes from "node_modules"
|
|
132
|
+
.forEach(localModule => addModule(localModule, container)); // recursively add modules own dependencies first
|
|
133
|
+
|
|
134
|
+
if (mod.resource && !mod.resource.includes('node_modules')) {
|
|
135
|
+
const reference = path.relative(context, mod.resource);
|
|
136
|
+
container.add(reference);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// handle imports of resources through "wr-resource!..."-syntax
|
|
140
|
+
if (mod instanceof WrmResourceModule) {
|
|
141
|
+
container.add(mod.getResourcePair().join(RESOURCE_JOINER));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
let dependencyTreeSet = new Set();
|
|
146
|
+
for (const chunk of chunks) {
|
|
147
|
+
for (const mod of chunk.getModules()) {
|
|
148
|
+
addModule(mod, dependencyTreeSet);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return dependencyTreeSet;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static getChunkIdentifier(chunk) {
|
|
155
|
+
return chunk.name || chunk.id;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Checks if webpack compiler is running in production mode
|
|
160
|
+
*
|
|
161
|
+
* @param {Object} compiler Webpack compiler
|
|
162
|
+
* @returns {Boolean} Returns true if webpack is running in production mode, false otherwise
|
|
163
|
+
*/
|
|
164
|
+
static isRunningInProductionMode(compiler) {
|
|
165
|
+
const { options } = compiler;
|
|
166
|
+
|
|
167
|
+
if (options.mode) {
|
|
168
|
+
if (options.mode === 'production') {
|
|
169
|
+
return true;
|
|
170
|
+
} else if (options.mode === 'none') {
|
|
171
|
+
return process.env.NODE_ENV === 'production';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module.exports = class WebpackRuntimeHelpers {
|
|
2
|
+
static hookIntoNormalModuleFactory(compiler, cb) {
|
|
3
|
+
compiler.hooks.compile.tap('RuntimeHelper Compiler', params => {
|
|
4
|
+
params.normalModuleFactory.hooks.factory.tap('RuntimeHelper NormalModuleFactory', cb);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
};
|