@atlassian/webresource-webpack-plugin 7.0.2 → 7.0.4-efd4a11
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/CHANGELOG.md +12 -0
- package/README.md +6 -3
- package/dist/AppResources.d.ts +63 -0
- package/dist/AppResources.js +179 -0
- package/dist/AppResources.js.map +1 -0
- package/dist/AppResourcesFactory.d.ts +10 -0
- package/dist/AppResourcesFactory.js +16 -0
- package/dist/AppResourcesFactory.js.map +1 -0
- package/dist/WebpackHelpers.d.ts +16 -0
- package/dist/WebpackHelpers.js +97 -0
- package/dist/WebpackHelpers.js.map +1 -0
- package/dist/WebpackRuntimeHelpers.d.ts +2 -0
- package/dist/WebpackRuntimeHelpers.js +10 -0
- package/dist/WebpackRuntimeHelpers.js.map +1 -0
- package/dist/WrmManifestPlugin.d.ts +9 -0
- package/dist/WrmManifestPlugin.js +44 -0
- package/dist/WrmManifestPlugin.js.map +1 -0
- package/dist/WrmPlugin.d.ts +51 -0
- package/dist/WrmPlugin.js +566 -0
- package/dist/WrmPlugin.js.map +1 -0
- package/dist/deps/base-dependencies.d.ts +8 -0
- package/dist/deps/base-dependencies.js +38 -0
- package/dist/deps/base-dependencies.js.map +1 -0
- package/dist/deps/provided-dependencies.d.ts +3 -0
- package/dist/deps/provided-dependencies.js +22 -0
- package/dist/deps/provided-dependencies.js.map +1 -0
- package/dist/helpers/file-system.d.ts +2 -0
- package/dist/helpers/file-system.js +22 -0
- package/dist/helpers/file-system.js.map +1 -0
- package/dist/helpers/isRspackCompiler.d.ts +3 -0
- package/dist/helpers/isRspackCompiler.js +9 -0
- package/dist/helpers/isRspackCompiler.js.map +1 -0
- package/dist/helpers/options-parser.d.ts +3 -0
- package/dist/helpers/options-parser.js +31 -0
- package/dist/helpers/options-parser.js.map +1 -0
- package/dist/helpers/renderCondition.d.ts +3 -0
- package/dist/helpers/renderCondition.js +32 -0
- package/dist/helpers/renderCondition.js.map +1 -0
- package/dist/helpers/renderTransformations.d.ts +10 -0
- package/dist/helpers/renderTransformations.js +34 -0
- package/dist/helpers/renderTransformations.js.map +1 -0
- package/dist/helpers/string.d.ts +1 -0
- package/dist/helpers/string.js +9 -0
- package/dist/helpers/string.js.map +1 -0
- package/dist/helpers/web-resource-entrypoints.d.ts +9 -0
- package/dist/helpers/web-resource-entrypoints.js +44 -0
- package/dist/helpers/web-resource-entrypoints.js.map +1 -0
- package/dist/helpers/web-resource-generator.d.ts +2 -0
- package/dist/helpers/web-resource-generator.js +105 -0
- package/dist/helpers/web-resource-generator.js.map +1 -0
- package/dist/helpers/web-resource-parser.d.ts +2 -0
- package/dist/helpers/web-resource-parser.js +39 -0
- package/dist/helpers/web-resource-parser.js.map +1 -0
- package/dist/helpers/xml.d.ts +6 -0
- package/dist/helpers/xml.js +37 -0
- package/dist/helpers/xml.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +26 -0
- package/dist/logger.js.map +1 -0
- package/dist/shims/require-ensure-shim.d.ts +2 -0
- package/dist/shims/require-ensure-shim.js +21 -0
- package/dist/shims/require-ensure-shim.js.map +1 -0
- package/dist/shims/runtime-load-shim.d.ts +14 -0
- package/dist/shims/runtime-load-shim.js +62 -0
- package/dist/shims/runtime-load-shim.js.map +1 -0
- package/dist/types/extracted-webpack-types.d.ts +12 -0
- package/dist/types/extracted-webpack-types.js +3 -0
- package/dist/types/extracted-webpack-types.js.map +1 -0
- package/dist/types/types.d.ts +132 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/webpack-modules/EmptyExportsModule.d.ts +14 -0
- package/dist/webpack-modules/EmptyExportsModule.js +28 -0
- package/dist/webpack-modules/EmptyExportsModule.js.map +1 -0
- package/dist/webpack-modules/ProvidedExternalDependencyModule.d.ts +20 -0
- package/dist/webpack-modules/ProvidedExternalDependencyModule.js +36 -0
- package/dist/webpack-modules/ProvidedExternalDependencyModule.js.map +1 -0
- package/dist/webpack-modules/WrmDependencyModule.d.ts +6 -0
- package/dist/webpack-modules/WrmDependencyModule.js +17 -0
- package/dist/webpack-modules/WrmDependencyModule.js.map +1 -0
- package/dist/webpack-modules/WrmResourceModule.d.ts +10 -0
- package/dist/webpack-modules/WrmResourceModule.js +29 -0
- package/dist/webpack-modules/WrmResourceModule.js.map +1 -0
- package/jest.config.js +16 -1
- package/package.json +20 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [7.0.4](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/webresource-webpack-plugin@7.0.4..@atlassian/webresource-webpack-plugin@7.0.3) (2025-08-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **BESECART-3480:** Move webpack plugin to [@atlassian](https://bitbucket.org/atlassian) scope ([cc62451](https://bitbucket.org/atlassianlabs/fe-server/commits/cc62451aabe8b63cf28645596e59ee8cef5ae560))
|
|
12
|
+
* **build:** newer TypeScript version reported issues ([3cebc02](https://bitbucket.org/atlassianlabs/fe-server/commits/3cebc02e3c68b7a6545cbbb24743f551be258df5))
|
|
13
|
+
* **lint:** update `eslint` and its plugins, update config files ([ff578f1](https://bitbucket.org/atlassianlabs/fe-server/commits/ff578f16057848f05fddbe87cff392acf5b863a2))
|
|
14
|
+
* **tests:** update Jest config and some of its dependencies after upgrade ([8f21350](https://bitbucket.org/atlassianlabs/fe-server/commits/8f21350ecd99d119341e877d7a8a6ea700e736c7))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
### [7.0.2](https://bitbucket.org/atlassianlabs/fe-server/branches/compare/@atlassian/webresource-webpack-plugin@7.0.2..@atlassian/webresource-webpack-plugin@7.0.1) (2025-05-29)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @atlassian/webresource-webpack-plugin
|
package/README.md
CHANGED
|
@@ -612,13 +612,16 @@ The format of an external dependency mapping is as follows:
|
|
|
612
612
|
}
|
|
613
613
|
```
|
|
614
614
|
|
|
615
|
-
In this example, `externals` is a JSON object following the
|
|
616
|
-
[webpack externals format][webpack-externalobjects].
|
|
617
|
-
|
|
618
615
|
When your code is compiled through webpack, any occurrence of `dependency-name` found in a module import
|
|
619
616
|
statement will be replaced in the webpack output, and an appropriate web-resource `<dependency>` will be
|
|
620
617
|
added to the generated web-resource.
|
|
621
618
|
|
|
619
|
+
The `import` property is either a string or an object that specifies how the dependency should be imported in the code.
|
|
620
|
+
|
|
621
|
+
The provided object is a JSON object following the [webpack externals format][webpack-externalobjects].
|
|
622
|
+
|
|
623
|
+
If you’re not setting the `externalsType` or `library.type` in the config, then the default property being used is `var`. Another popular option is `amd` as most of the Atlassian products use AMD for loading modules (but then the `externalsType` should be set too).
|
|
624
|
+
|
|
622
625
|
### `wrmManifestPath` (Optional)
|
|
623
626
|
|
|
624
627
|
A path to a WRM manifest file where the plugin will store a map of objects.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Chunk, Compilation, Compiler } from 'webpack';
|
|
2
|
+
import type { Entrypoint } from './types/extracted-webpack-types';
|
|
3
|
+
import type { AssetNames, ChunkResourceDescriptor, ConsolidatedOptions, WrmResource } from './types/types';
|
|
4
|
+
type SplitChunkDependenciesKeyMap = Map<Chunk, {
|
|
5
|
+
key: string;
|
|
6
|
+
dependency: string;
|
|
7
|
+
}>;
|
|
8
|
+
export type AppResourceParams = {
|
|
9
|
+
assetsUUID: string;
|
|
10
|
+
assetNames: AssetNames;
|
|
11
|
+
options: ConsolidatedOptions;
|
|
12
|
+
compiler: Compiler;
|
|
13
|
+
compilation: Compilation;
|
|
14
|
+
dependencyModuleMap: Map<string, Set<string>>;
|
|
15
|
+
resourceModuleMap: Map<string, Set<WrmResource>>;
|
|
16
|
+
};
|
|
17
|
+
export default class AppResources {
|
|
18
|
+
private readonly assetsUUID;
|
|
19
|
+
private readonly compiler;
|
|
20
|
+
private readonly compilation;
|
|
21
|
+
private readonly dependencyModuleMap;
|
|
22
|
+
private readonly resourceModuleMap;
|
|
23
|
+
private assetNames;
|
|
24
|
+
private options;
|
|
25
|
+
/**
|
|
26
|
+
* @param assetsUUID unique hash to identify the assets web-resource
|
|
27
|
+
* @param assetNames full module filepaths -> relative filepath
|
|
28
|
+
* @param options WrmPlugin configuration
|
|
29
|
+
* @param compiler Webpack compiler
|
|
30
|
+
* @param compilation Webpack compilation
|
|
31
|
+
*/
|
|
32
|
+
constructor({ assetsUUID, assetNames, options, compiler, compilation, dependencyModuleMap, resourceModuleMap, }: AppResourceParams);
|
|
33
|
+
getSingleRuntimeFiles(): string[];
|
|
34
|
+
getAssetResourceDescriptor(): ChunkResourceDescriptor;
|
|
35
|
+
getDependencyResourcesFromChunk(chunk: Chunk): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Every entrypoint has an attribute called "chunks".
|
|
38
|
+
* This contains all chunks that are needed to successfully "load" this entrypoint.
|
|
39
|
+
* Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
|
|
40
|
+
* If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
|
|
41
|
+
* 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.
|
|
42
|
+
*
|
|
43
|
+
* 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.
|
|
44
|
+
*/
|
|
45
|
+
getSyncSplitChunks(): Chunk[];
|
|
46
|
+
/**
|
|
47
|
+
* Create a key and the fully-qualified web-resource descriptor for every split chunk.
|
|
48
|
+
* This is needed to point to reference these chunks as dependency in the entrypoint chunks
|
|
49
|
+
*
|
|
50
|
+
* <web-resource>
|
|
51
|
+
* ...
|
|
52
|
+
* <dependency>this-plugin-key:split_some_chunk</dependency>
|
|
53
|
+
* ...
|
|
54
|
+
* </web-resource>
|
|
55
|
+
*/
|
|
56
|
+
getSyncSplitChunkDependenciesKeyMap(syncSplitChunks: Chunk[]): SplitChunkDependenciesKeyMap;
|
|
57
|
+
getSyncSplitChunksResourceDescriptors(): ChunkResourceDescriptor[];
|
|
58
|
+
getAsyncChunksResourceDescriptors(): ChunkResourceDescriptor[];
|
|
59
|
+
getEntryPoints(): Entrypoint[];
|
|
60
|
+
getEntryPointsResourceDescriptors(): ChunkResourceDescriptor[];
|
|
61
|
+
getResourceDescriptors(): ChunkResourceDescriptor[];
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
7
|
+
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
8
|
+
const base_dependencies_1 = require("./deps/base-dependencies");
|
|
9
|
+
const web_resource_entrypoints_1 = require("./helpers/web-resource-entrypoints");
|
|
10
|
+
const WebpackHelpers_1 = require("./WebpackHelpers");
|
|
11
|
+
const RUNTIME_WR_KEY = 'common-runtime';
|
|
12
|
+
class AppResources {
|
|
13
|
+
/**
|
|
14
|
+
* @param assetsUUID unique hash to identify the assets web-resource
|
|
15
|
+
* @param assetNames full module filepaths -> relative filepath
|
|
16
|
+
* @param options WrmPlugin configuration
|
|
17
|
+
* @param compiler Webpack compiler
|
|
18
|
+
* @param compilation Webpack compilation
|
|
19
|
+
*/
|
|
20
|
+
constructor({ assetsUUID, assetNames, options, compiler, compilation, dependencyModuleMap, resourceModuleMap, }) {
|
|
21
|
+
this.assetsUUID = assetsUUID;
|
|
22
|
+
this.assetNames = assetNames;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.compiler = compiler;
|
|
25
|
+
this.compilation = compilation;
|
|
26
|
+
this.dependencyModuleMap = dependencyModuleMap;
|
|
27
|
+
this.resourceModuleMap = resourceModuleMap;
|
|
28
|
+
}
|
|
29
|
+
getSingleRuntimeFiles() {
|
|
30
|
+
const files = this.getEntryPoints()
|
|
31
|
+
.map((entrypoint) => entrypoint.getRuntimeChunk()?.files)
|
|
32
|
+
.find(Boolean);
|
|
33
|
+
if (!files) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return Array.from(files);
|
|
37
|
+
}
|
|
38
|
+
getAssetResourceDescriptor() {
|
|
39
|
+
// remove anything that we know is handled differently
|
|
40
|
+
const assetFiles = Object.keys(this.compilation.assets).filter((p) => !/\.(js|css|soy)(\.map)?$/.test(p));
|
|
41
|
+
return {
|
|
42
|
+
attributes: { key: `assets-${this.assetsUUID}` },
|
|
43
|
+
resources: assetFiles,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
getDependencyResourcesFromChunk(chunk) {
|
|
47
|
+
return Array.from(chunk.auxiliaryFiles);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Every entrypoint has an attribute called "chunks".
|
|
51
|
+
* This contains all chunks that are needed to successfully "load" this entrypoint.
|
|
52
|
+
* Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
|
|
53
|
+
* If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
|
|
54
|
+
* 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.
|
|
55
|
+
*
|
|
56
|
+
* 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.
|
|
57
|
+
*/
|
|
58
|
+
getSyncSplitChunks() {
|
|
59
|
+
const syncSplitChunks = (0, flatMap_1.default)(this.getEntryPoints(), (e) => e.chunks.filter((c) => c !== e.getRuntimeChunk()));
|
|
60
|
+
return (0, uniq_1.default)(syncSplitChunks);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a key and the fully-qualified web-resource descriptor for every split chunk.
|
|
64
|
+
* This is needed to point to reference these chunks as dependency in the entrypoint chunks
|
|
65
|
+
*
|
|
66
|
+
* <web-resource>
|
|
67
|
+
* ...
|
|
68
|
+
* <dependency>this-plugin-key:split_some_chunk</dependency>
|
|
69
|
+
* ...
|
|
70
|
+
* </web-resource>
|
|
71
|
+
*/
|
|
72
|
+
getSyncSplitChunkDependenciesKeyMap(syncSplitChunks) {
|
|
73
|
+
const syncSplitChunkDependencyKeyMap = new Map();
|
|
74
|
+
for (const c of syncSplitChunks) {
|
|
75
|
+
const webResourceKey = `split_${c.name || c.id}`;
|
|
76
|
+
syncSplitChunkDependencyKeyMap.set(c, {
|
|
77
|
+
key: webResourceKey,
|
|
78
|
+
dependency: `${this.options.pluginKey}:${webResourceKey}`,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return syncSplitChunkDependencyKeyMap;
|
|
82
|
+
}
|
|
83
|
+
getSyncSplitChunksResourceDescriptors() {
|
|
84
|
+
const syncSplitChunks = this.getSyncSplitChunks();
|
|
85
|
+
const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(syncSplitChunks);
|
|
86
|
+
/**
|
|
87
|
+
* Create descriptors for the split chunk web-resources that have to be created.
|
|
88
|
+
* These include - like other chunk-descriptors their assets and external resources etc.
|
|
89
|
+
*/
|
|
90
|
+
return syncSplitChunks.map((c) => {
|
|
91
|
+
const additionalFileDeps = this.getDependencyResourcesFromChunk(c);
|
|
92
|
+
return {
|
|
93
|
+
attributes: syncSplitChunkDependencyKeyMap.get(c),
|
|
94
|
+
externalResources: (0, WebpackHelpers_1.getResourcesForChunks)(this.compilation, c, this.resourceModuleMap),
|
|
95
|
+
resources: (0, uniq_1.default)([...c.files, ...additionalFileDeps]),
|
|
96
|
+
dependencies: (0, uniq_1.default)([
|
|
97
|
+
...(0, base_dependencies_1.getBaseDependencies)(),
|
|
98
|
+
...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, c, this.dependencyModuleMap),
|
|
99
|
+
]),
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getAsyncChunksResourceDescriptors() {
|
|
104
|
+
return (0, WebpackHelpers_1.getAllAsyncChunks)(this.getEntryPoints()).map((c) => {
|
|
105
|
+
const additionalFileDeps = this.getDependencyResourcesFromChunk(c);
|
|
106
|
+
return {
|
|
107
|
+
attributes: { key: `${c.id}` },
|
|
108
|
+
externalResources: (0, WebpackHelpers_1.getResourcesForChunks)(this.compilation, c, this.resourceModuleMap),
|
|
109
|
+
resources: (0, uniq_1.default)([...c.files, ...additionalFileDeps]),
|
|
110
|
+
dependencies: (0, uniq_1.default)([
|
|
111
|
+
...(0, base_dependencies_1.getBaseDependencies)(),
|
|
112
|
+
...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, c, this.dependencyModuleMap),
|
|
113
|
+
]),
|
|
114
|
+
contexts: this.options.addAsyncNameAsContext && c.name ? [`async-chunk-${c.name}`] : undefined,
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
getEntryPoints() {
|
|
119
|
+
return Array.from(this.compilation.entrypoints.values());
|
|
120
|
+
}
|
|
121
|
+
getEntryPointsResourceDescriptors() {
|
|
122
|
+
const singleRuntime = (0, WebpackHelpers_1.isSingleRuntime)(this.compiler);
|
|
123
|
+
const syncSplitChunks = this.getSyncSplitChunks();
|
|
124
|
+
const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(syncSplitChunks);
|
|
125
|
+
const singleRuntimeWebResourceKey = this.options.singleRuntimeWebResourceKey || RUNTIME_WR_KEY;
|
|
126
|
+
// Used in prod
|
|
127
|
+
const prodEntryPoints = this.getEntryPoints().map((entrypoint) => {
|
|
128
|
+
const name = entrypoint.name;
|
|
129
|
+
const webResourceAttrs = (0, web_resource_entrypoints_1.getWebresourceAttributesForEntry)(name, this.options.webresourceKeyMap);
|
|
130
|
+
const entrypointChunks = entrypoint.chunks;
|
|
131
|
+
const runtimeChunk = entrypoint.getRuntimeChunk();
|
|
132
|
+
// Retrieve all split chunks this entrypoint depends on. These must be added as "<dependency>"s to the web-resource of this entrypoint
|
|
133
|
+
const sharedSplitDeps = entrypointChunks
|
|
134
|
+
.map((c) => syncSplitChunkDependencyKeyMap.get(c))
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.map((val) => val?.dependency);
|
|
137
|
+
// Construct the list of resources to add to this web-resource
|
|
138
|
+
const resourceList = (0, flatMap_1.default)(entrypointChunks, (c) => this.getDependencyResourcesFromChunk(c));
|
|
139
|
+
const dependencyList = [
|
|
140
|
+
...(0, base_dependencies_1.getBaseDependencies)(),
|
|
141
|
+
...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, runtimeChunk, this.dependencyModuleMap),
|
|
142
|
+
...sharedSplitDeps,
|
|
143
|
+
];
|
|
144
|
+
if (singleRuntime) {
|
|
145
|
+
dependencyList.unshift(`${this.options.pluginKey}:${singleRuntimeWebResourceKey}`);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
resourceList.unshift(...runtimeChunk.files);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
attributes: webResourceAttrs,
|
|
152
|
+
contexts: (0, web_resource_entrypoints_1.getContextForEntry)(name, this.options.contextMap, this.options.addEntrypointNameAsContext),
|
|
153
|
+
conditions: (0, web_resource_entrypoints_1.getConditionForEntry)(name, this.options.conditionMap),
|
|
154
|
+
dataProviders: (0, web_resource_entrypoints_1.getDataProvidersForEntry)(name, this.options.dataProvidersMap),
|
|
155
|
+
deprecationInfo: (0, web_resource_entrypoints_1.getDeprecationInfoForEntry)(name, this.options.deprecatedEntrypoints),
|
|
156
|
+
externalResources: (0, WebpackHelpers_1.getResourcesForChunks)(this.compilation, runtimeChunk, this.resourceModuleMap),
|
|
157
|
+
resources: (0, uniq_1.default)(resourceList),
|
|
158
|
+
dependencies: (0, uniq_1.default)(dependencyList).filter(Boolean),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
if (singleRuntime) {
|
|
162
|
+
prodEntryPoints.push({
|
|
163
|
+
attributes: { key: singleRuntimeWebResourceKey },
|
|
164
|
+
dependencies: (0, base_dependencies_1.getBaseDependencies)(),
|
|
165
|
+
resources: this.getSingleRuntimeFiles(),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return prodEntryPoints;
|
|
169
|
+
}
|
|
170
|
+
getResourceDescriptors() {
|
|
171
|
+
return []
|
|
172
|
+
.concat(this.getSyncSplitChunksResourceDescriptors())
|
|
173
|
+
.concat(this.getAsyncChunksResourceDescriptors())
|
|
174
|
+
.concat(this.getEntryPointsResourceDescriptors())
|
|
175
|
+
.concat(this.getAssetResourceDescriptor());
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.default = AppResources;
|
|
179
|
+
//# sourceMappingURL=AppResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppResources.js","sourceRoot":"","sources":["../src/AppResources.ts"],"names":[],"mappings":";;;;;AAAA,6DAAqC;AACrC,uDAA+B;AAG/B,gEAA+D;AAC/D,iFAM4C;AAG5C,qDAAuH;AAEvH,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAcxC,MAAqB,YAAY;IAU/B;;;;;;OAMG;IACH,YAAY,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,iBAAiB,GACC;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,iBAAiB,G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import type { AppResourceParams } from './AppResources';
|
|
3
|
+
import AppResources from './AppResources';
|
|
4
|
+
type AppResourcesFactoryParams = Omit<AppResourceParams, 'compiler' | 'compilation'>;
|
|
5
|
+
export default class AppResourceFactory {
|
|
6
|
+
private appResourcesFactoryParams;
|
|
7
|
+
constructor(appResourcesFactoryParams: AppResourcesFactoryParams);
|
|
8
|
+
build(compiler: Compiler, compilation: Compilation): AppResources;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AppResources_1 = __importDefault(require("./AppResources"));
|
|
7
|
+
class AppResourceFactory {
|
|
8
|
+
constructor(appResourcesFactoryParams) {
|
|
9
|
+
this.appResourcesFactoryParams = appResourcesFactoryParams;
|
|
10
|
+
}
|
|
11
|
+
build(compiler, compilation) {
|
|
12
|
+
return new AppResources_1.default({ ...this.appResourcesFactoryParams, compiler, compilation });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = AppResourceFactory;
|
|
16
|
+
//# sourceMappingURL=AppResourcesFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppResourcesFactory.js","sourceRoot":"","sources":["../src/AppResourcesFactory.ts"],"names":[],"mappings":";;;;;AAGA,kEAA0C;AAI1C,MAAqB,kBAAkB;IACrC,YAAoB,yBAAoD;QAApD,8BAAyB,GAAzB,yBAAyB,CAA2B;IAAG,CAAC;IAE5E,KAAK,CAAC,QAAkB,EAAE,WAAwB;QAChD,OAAO,IAAI,sBAAY,CAAC,EAAE,GAAG,IAAI,CAAC,yBAAyB,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;IACxF,CAAC;CACF;AAND,qCAMC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Chunk, Compilation, Compiler } from 'webpack';
|
|
2
|
+
import type { Entrypoint } from './types/extracted-webpack-types';
|
|
3
|
+
import type { WrmResource } from './types/types';
|
|
4
|
+
export declare const getAllAsyncChunks: (entryPoints: Entrypoint[]) => Chunk[];
|
|
5
|
+
export declare const getChunkModules: (compilation: Compilation, chunk: Chunk) => import("webpack").Module[];
|
|
6
|
+
export declare const getDependenciesForChunks: (compilation: Compilation, val: Chunk | Chunk[], dependencyModuleMap: Map<string, Set<string>>) => string[];
|
|
7
|
+
export declare const getResourcesForChunks: (compilation: Compilation, val: Chunk | Chunk[], resourceModuleMap: Map<string, Set<WrmResource>>) => WrmResource[];
|
|
8
|
+
export declare const isRunningInProductionMode: (compiler: Compiler) => boolean;
|
|
9
|
+
export declare const isSingleRuntime: (compiler: Compiler) => boolean;
|
|
10
|
+
export declare const extractLibraryDetailsFromWebpackConfig: (compiler: Compiler) => {
|
|
11
|
+
target: "module" | "import" | "var" | "assign" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "promise" | "script" | "node-commonjs" | undefined;
|
|
12
|
+
name: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
target: string;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractLibraryDetailsFromWebpackConfig = exports.isSingleRuntime = exports.isRunningInProductionMode = exports.getResourcesForChunks = exports.getDependenciesForChunks = exports.getChunkModules = exports.getAllAsyncChunks = void 0;
|
|
4
|
+
const getAllAsyncChunks = (entryPoints) => {
|
|
5
|
+
const seenAsyncChunks = new Set();
|
|
6
|
+
const recursivelyGetAllAsyncChunks = (chunk) => {
|
|
7
|
+
const asyncChunks = [...(chunk.getAllAsyncChunks() || [])];
|
|
8
|
+
const unseen = asyncChunks.filter((ac) => {
|
|
9
|
+
if (seenAsyncChunks.has(ac)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
seenAsyncChunks.add(ac);
|
|
13
|
+
return true;
|
|
14
|
+
});
|
|
15
|
+
return [...unseen, ...unseen.flatMap((ac) => recursivelyGetAllAsyncChunks(ac))];
|
|
16
|
+
};
|
|
17
|
+
return entryPoints.flatMap((ep) => {
|
|
18
|
+
return recursivelyGetAllAsyncChunks(ep.getEntrypointChunk());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.getAllAsyncChunks = getAllAsyncChunks;
|
|
22
|
+
const getChunkModules = (compilation, chunk) => {
|
|
23
|
+
return compilation.chunkGraph.getChunkModules(chunk);
|
|
24
|
+
};
|
|
25
|
+
exports.getChunkModules = getChunkModules;
|
|
26
|
+
const getDependenciesForChunks = (compilation, val, dependencyModuleMap) => {
|
|
27
|
+
const chunks = Array.isArray(val) ? val : [val];
|
|
28
|
+
const externalDeps = new Set();
|
|
29
|
+
for (const chunk of chunks) {
|
|
30
|
+
for (const module of (0, exports.getChunkModules)(compilation, chunk)) {
|
|
31
|
+
const moduleKey = module.identifier();
|
|
32
|
+
const dependenciesForModule = [...(dependencyModuleMap.get(moduleKey) || [])];
|
|
33
|
+
for (const dep of dependenciesForModule) {
|
|
34
|
+
externalDeps.add(dep);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// TODO: figure out how to pass this "properly" as a module
|
|
38
|
+
// @ts-expect-error See WrmPlugin.ts where this is set.
|
|
39
|
+
if (chunk.needsWrmRequire) {
|
|
40
|
+
externalDeps.add('com.atlassian.plugins.atlassian-plugins-webresource-rest:web-resource-manager');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Array.from(externalDeps);
|
|
44
|
+
};
|
|
45
|
+
exports.getDependenciesForChunks = getDependenciesForChunks;
|
|
46
|
+
const getResourcesForChunks = (compilation, val, resourceModuleMap) => {
|
|
47
|
+
const chunks = Array.isArray(val) ? val : [val];
|
|
48
|
+
const additionalResources = new Set();
|
|
49
|
+
for (const chunk of chunks) {
|
|
50
|
+
for (const module of (0, exports.getChunkModules)(compilation, chunk)) {
|
|
51
|
+
const moduleKey = module.identifier();
|
|
52
|
+
const resourcesForModule = [...(resourceModuleMap.get(moduleKey) || [])];
|
|
53
|
+
for (const resource of resourcesForModule) {
|
|
54
|
+
additionalResources.add(resource);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return Array.from(additionalResources);
|
|
59
|
+
};
|
|
60
|
+
exports.getResourcesForChunks = getResourcesForChunks;
|
|
61
|
+
const isRunningInProductionMode = (compiler) => {
|
|
62
|
+
const { mode } = compiler.options;
|
|
63
|
+
return mode === 'production' || (mode === 'none' && process.env.NODE_ENV === 'production');
|
|
64
|
+
};
|
|
65
|
+
exports.isRunningInProductionMode = isRunningInProductionMode;
|
|
66
|
+
const isSingleRuntime = (compiler) => {
|
|
67
|
+
const { options } = compiler;
|
|
68
|
+
const runtimeChunkCfg = options.optimization && options.optimization.runtimeChunk;
|
|
69
|
+
if (runtimeChunkCfg) {
|
|
70
|
+
if (runtimeChunkCfg === 'single') {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const { name } = runtimeChunkCfg;
|
|
74
|
+
if (typeof name === 'string') {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (typeof name === 'function') {
|
|
78
|
+
const resultA = name({ name: 'foo' });
|
|
79
|
+
const resultB = name({ name: 'bar' });
|
|
80
|
+
return resultA === resultB;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
exports.isSingleRuntime = isSingleRuntime;
|
|
86
|
+
const extractLibraryDetailsFromWebpackConfig = (compiler) => {
|
|
87
|
+
const { library } = compiler.options.output;
|
|
88
|
+
if (!library) {
|
|
89
|
+
return { target: compiler.options.externalsType, name: undefined };
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
target: library.type,
|
|
93
|
+
name: library.name,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.extractLibraryDetailsFromWebpackConfig = extractLibraryDetailsFromWebpackConfig;
|
|
97
|
+
//# sourceMappingURL=WebpackHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackHelpers.js","sourceRoot":"","sources":["../src/WebpackHelpers.ts"],"names":[],"mappings":";;;AAKO,MAAM,iBAAiB,GAAG,CAAC,WAAyB,EAAE,EAAE;IAC7D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;IAClC,MAAM,4BAA4B,GAAG,CAAC,KAAY,EAAW,EAAE;QAC7D,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE;YACvC,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;QAChC,OAAO,4BAA4B,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlBW,QAAA,iBAAiB,qBAkB5B;AAEK,MAAM,eAAe,GAAG,CAAC,WAAwB,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,EAAE,GAAG,eAAiF,CAAC;QACnG,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACtC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACtC,OAAO,OAAO,KAAK,OAAO,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B;AAEK,MAAM,sCAAsC,GAAG,CAAC,QAAkB,EAAE,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACrE,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,IAAI;QACpB,IAAI,EAAE,OAAO,CAAC,IAAc;KAC7B,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,sCAAsC,0CAUjD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hookIntoCompileDoneToGenerateReports = void 0;
|
|
4
|
+
const hookIntoCompileDoneToGenerateReports = (stageName, compiler, cb) => {
|
|
5
|
+
compiler.hooks.done.tapAsync(stageName, (stats, callback) => {
|
|
6
|
+
cb(stats.compilation, callback);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
exports.hookIntoCompileDoneToGenerateReports = hookIntoCompileDoneToGenerateReports;
|
|
10
|
+
//# sourceMappingURL=WebpackRuntimeHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackRuntimeHelpers.js","sourceRoot":"","sources":["../src/WebpackRuntimeHelpers.ts"],"names":[],"mappings":";;;AAEO,MAAM,oCAAoC,GAAG,CAClD,SAAiB,EACjB,QAAkB,EAClB,EAA4D,EAC5D,EAAE;IACF,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC1D,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,oCAAoC,wCAQ/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type AppResourceFactory from './AppResourcesFactory';
|
|
3
|
+
export default class WrmManifestPlugin {
|
|
4
|
+
private appResourcesFactory;
|
|
5
|
+
private outputPath;
|
|
6
|
+
private pluginKey;
|
|
7
|
+
constructor(appResourcesFactory: AppResourceFactory, outputPath: string, pluginKey: string);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const provided_dependencies_1 = require("./deps/provided-dependencies");
|
|
4
|
+
const file_system_1 = require("./helpers/file-system");
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
|
+
const WebpackHelpers_1 = require("./WebpackHelpers");
|
|
7
|
+
const WebpackRuntimeHelpers_1 = require("./WebpackRuntimeHelpers");
|
|
8
|
+
class WrmManifestPlugin {
|
|
9
|
+
constructor(appResourcesFactory, outputPath, pluginKey) {
|
|
10
|
+
this.pluginKey = pluginKey;
|
|
11
|
+
this.appResourcesFactory = appResourcesFactory;
|
|
12
|
+
this.outputPath = outputPath;
|
|
13
|
+
}
|
|
14
|
+
apply(compiler) {
|
|
15
|
+
const { outputPath, appResourcesFactory, pluginKey } = this;
|
|
16
|
+
const { name, target } = (0, WebpackHelpers_1.extractLibraryDetailsFromWebpackConfig)(compiler);
|
|
17
|
+
if (!name || !target) {
|
|
18
|
+
(0, logger_1.error)('Can only use wrmManifestPath in conjunction with output.library and output.libraryTarget');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (target !== 'amd') {
|
|
22
|
+
(0, logger_1.error)(`Could not create manifest mapping. LibraryTarget '${target}' is not supported. Use 'amd'`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
(0, WebpackRuntimeHelpers_1.hookIntoCompileDoneToGenerateReports)('wrm manifest - generate deps', compiler, (compilation, cb) => {
|
|
26
|
+
const appResourceGenerator = appResourcesFactory.build(compiler, compilation);
|
|
27
|
+
const wrmManifestMapping = appResourceGenerator
|
|
28
|
+
.getEntryPointsResourceDescriptors()
|
|
29
|
+
.filter(({ attributes }) => attributes.moduleId)
|
|
30
|
+
.reduce((result, { attributes: { key: resourceKey, moduleId } }) => {
|
|
31
|
+
const libraryName = compilation.getAssetPath(name, {
|
|
32
|
+
chunk: { name: moduleId, id: moduleId, hash: moduleId },
|
|
33
|
+
});
|
|
34
|
+
result[moduleId] = (0, provided_dependencies_1.buildProvidedDependency)(pluginKey, resourceKey, `require('${libraryName}')`, libraryName);
|
|
35
|
+
return result;
|
|
36
|
+
}, {});
|
|
37
|
+
const wrmManifestJSON = JSON.stringify({ providedDependencies: wrmManifestMapping }, null, 4);
|
|
38
|
+
(0, file_system_1.writeFileSync)(outputPath, wrmManifestJSON);
|
|
39
|
+
cb();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = WrmManifestPlugin;
|
|
44
|
+
//# sourceMappingURL=WrmManifestPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrmManifestPlugin.js","sourceR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AG,WAAW,CAAC,YAAY,CAAC,IAAK,EAAE;oBAClD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAS,EAAE,IAAI,EAAE,QAAS,EAAE;iBAC1D,CAAC,CAAC;gBAEH,MAAM,CAAC,QAAS,CAAC,GAAG,IAAA,+CAAuB,EAAC,SAAS,EAAE,WAAW,EAAE,YAAY,WAAW,IAAI,EAAE,WAAW,CAAC,CAAC;gBAE9G,OAAO,MAAM,CAAC;YAChB,CAAC,EAAE,EAAE,CAAC,CAAC;YAET,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAE9F,IAAA,2BAAa,EAAC,UAAU,EAAE,eAAe,CAAC,CAAC;YAE3C,EAAE,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9CD,oCA8CC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { DataProvidersMap, Options, ProvidedDependenciesMap, ResourceParamMap, TransformationMap, WrmResource } from './types/types';
|
|
3
|
+
type TransformerExtensions = {
|
|
4
|
+
[key: string]: string[];
|
|
5
|
+
};
|
|
6
|
+
declare class WrmPlugin {
|
|
7
|
+
static extendTransformations(values: TransformerExtensions): Map<any, any>;
|
|
8
|
+
private options;
|
|
9
|
+
/**
|
|
10
|
+
* A Webpack plugin that takes the compilation tree and creates <web-resource> XML definitions that mirror the
|
|
11
|
+
* dependency graph.
|
|
12
|
+
*
|
|
13
|
+
* This plugin will:
|
|
14
|
+
*
|
|
15
|
+
* - generate <web-resource> definitions for each entrypoint, along with additional <web-resource> definitions for
|
|
16
|
+
* and appropriate dependencies on all chunks generated during compilation.
|
|
17
|
+
* - Add <dependency> declarations to each generated <web-resource> as appropriate, both for internal and external
|
|
18
|
+
* dependencies in the graph.
|
|
19
|
+
* - Add appropriate metadata to the <web-resource> definition, such as appropriate <context>s,
|
|
20
|
+
* enabled/disabled state, and more.
|
|
21
|
+
* @param {Options} options
|
|
22
|
+
*/
|
|
23
|
+
constructor(options: Options);
|
|
24
|
+
/**
|
|
25
|
+
* Generate an asset uuid per build - this is used to ensure we have a new "cache" for our assets per build.
|
|
26
|
+
* As JIRA-Server does not "rebuild" too often, this can be considered reasonable.
|
|
27
|
+
*/
|
|
28
|
+
getAssetsUUID(isProduction: boolean): string;
|
|
29
|
+
ensureTransformationsAreUnique(transformations: TransformationMap): TransformationMap;
|
|
30
|
+
ensureResourceParamsAreUnique(params: ResourceParamMap): ResourceParamMap;
|
|
31
|
+
ensureProvidedDependenciesAreUnique(providedDependencies: ProvidedDependenciesMap): ProvidedDependenciesMap;
|
|
32
|
+
ensureDataProvidersMapIsValid(dataProvidersMap: DataProvidersMap): DataProvidersMap;
|
|
33
|
+
checkConfig(compiler: Compiler): void;
|
|
34
|
+
overwritePublicPath(compiler: Compiler): void;
|
|
35
|
+
dependencyModuleMap: Map<string, Set<string>>;
|
|
36
|
+
resourceModuleMap: Map<string, Set<WrmResource>>;
|
|
37
|
+
dependencyIssuerMap: Map<string, Set<string>>;
|
|
38
|
+
resourceIssuerMap: Map<string, Set<WrmResource>>;
|
|
39
|
+
private storeMapEntryInValueSet;
|
|
40
|
+
private storeModuleDependency;
|
|
41
|
+
hookUpModuleDependencies(compiler: Compiler): void;
|
|
42
|
+
injectWRMSpecificRequestTypes(compiler: Compiler): void;
|
|
43
|
+
/**
|
|
44
|
+
* Ensure the WRM.require function is available at runtime and is used to load any code-split chunks.
|
|
45
|
+
*/
|
|
46
|
+
enableAsyncLoadingWithWRM(compiler: Compiler): void;
|
|
47
|
+
shouldOverwritePublicPath(): boolean;
|
|
48
|
+
shouldEnableAsyncLoadingWithWRM(): boolean;
|
|
49
|
+
apply(compiler: Compiler): void;
|
|
50
|
+
}
|
|
51
|
+
export = WrmPlugin;
|