@atlassian/webresource-webpack-plugin 7.0.2 → 7.0.3

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.
Files changed (79) hide show
  1. package/dist/AppResources.d.ts +59 -0
  2. package/dist/AppResources.js +171 -0
  3. package/dist/AppResources.js.map +1 -0
  4. package/dist/AppResourcesFactory.d.ts +10 -0
  5. package/dist/AppResourcesFactory.js +16 -0
  6. package/dist/AppResourcesFactory.js.map +1 -0
  7. package/dist/WebpackHelpers.d.ts +16 -0
  8. package/dist/WebpackHelpers.js +115 -0
  9. package/dist/WebpackHelpers.js.map +1 -0
  10. package/dist/WebpackRuntimeHelpers.d.ts +4 -0
  11. package/dist/WebpackRuntimeHelpers.js +21 -0
  12. package/dist/WebpackRuntimeHelpers.js.map +1 -0
  13. package/dist/WrmManifestPlugin.d.ts +9 -0
  14. package/dist/WrmManifestPlugin.js +44 -0
  15. package/dist/WrmManifestPlugin.js.map +1 -0
  16. package/dist/WrmPlugin.d.ts +45 -0
  17. package/dist/WrmPlugin.js +488 -0
  18. package/dist/WrmPlugin.js.map +1 -0
  19. package/dist/deps/base-dependencies.d.ts +8 -0
  20. package/dist/deps/base-dependencies.js +38 -0
  21. package/dist/deps/base-dependencies.js.map +1 -0
  22. package/dist/deps/provided-dependencies.d.ts +3 -0
  23. package/dist/deps/provided-dependencies.js +22 -0
  24. package/dist/deps/provided-dependencies.js.map +1 -0
  25. package/dist/helpers/file-system.d.ts +2 -0
  26. package/dist/helpers/file-system.js +23 -0
  27. package/dist/helpers/file-system.js.map +1 -0
  28. package/dist/helpers/options-parser.d.ts +3 -0
  29. package/dist/helpers/options-parser.js +28 -0
  30. package/dist/helpers/options-parser.js.map +1 -0
  31. package/dist/helpers/renderCondition.d.ts +3 -0
  32. package/dist/helpers/renderCondition.js +32 -0
  33. package/dist/helpers/renderCondition.js.map +1 -0
  34. package/dist/helpers/renderTransformations.d.ts +10 -0
  35. package/dist/helpers/renderTransformations.js +34 -0
  36. package/dist/helpers/renderTransformations.js.map +1 -0
  37. package/dist/helpers/string.d.ts +1 -0
  38. package/dist/helpers/string.js +9 -0
  39. package/dist/helpers/string.js.map +1 -0
  40. package/dist/helpers/web-resource-entrypoints.d.ts +9 -0
  41. package/dist/helpers/web-resource-entrypoints.js +44 -0
  42. package/dist/helpers/web-resource-entrypoints.js.map +1 -0
  43. package/dist/helpers/web-resource-generator.d.ts +2 -0
  44. package/dist/helpers/web-resource-generator.js +105 -0
  45. package/dist/helpers/web-resource-generator.js.map +1 -0
  46. package/dist/helpers/web-resource-parser.d.ts +2 -0
  47. package/dist/helpers/web-resource-parser.js +39 -0
  48. package/dist/helpers/web-resource-parser.js.map +1 -0
  49. package/dist/helpers/xml.d.ts +6 -0
  50. package/dist/helpers/xml.js +37 -0
  51. package/dist/helpers/xml.js.map +1 -0
  52. package/dist/logger.d.ts +4 -0
  53. package/dist/logger.js +26 -0
  54. package/dist/logger.js.map +1 -0
  55. package/dist/shims/require-ensure-shim.d.ts +2 -0
  56. package/dist/shims/require-ensure-shim.js +21 -0
  57. package/dist/shims/require-ensure-shim.js.map +1 -0
  58. package/dist/shims/runtime-load-shim.d.ts +14 -0
  59. package/dist/shims/runtime-load-shim.js +62 -0
  60. package/dist/shims/runtime-load-shim.js.map +1 -0
  61. package/dist/types/extracted-webpack-types.d.ts +12 -0
  62. package/dist/types/extracted-webpack-types.js +3 -0
  63. package/dist/types/extracted-webpack-types.js.map +1 -0
  64. package/dist/types/types.d.ts +132 -0
  65. package/dist/types/types.js +3 -0
  66. package/dist/types/types.js.map +1 -0
  67. package/dist/webpack-modules/EmptyExportsModule.d.ts +14 -0
  68. package/dist/webpack-modules/EmptyExportsModule.js +28 -0
  69. package/dist/webpack-modules/EmptyExportsModule.js.map +1 -0
  70. package/dist/webpack-modules/ProvidedExternalDependencyModule.d.ts +20 -0
  71. package/dist/webpack-modules/ProvidedExternalDependencyModule.js +36 -0
  72. package/dist/webpack-modules/ProvidedExternalDependencyModule.js.map +1 -0
  73. package/dist/webpack-modules/WrmDependencyModule.d.ts +6 -0
  74. package/dist/webpack-modules/WrmDependencyModule.js +17 -0
  75. package/dist/webpack-modules/WrmDependencyModule.js.map +1 -0
  76. package/dist/webpack-modules/WrmResourceModule.d.ts +10 -0
  77. package/dist/webpack-modules/WrmResourceModule.js +29 -0
  78. package/dist/webpack-modules/WrmResourceModule.js.map +1 -0
  79. package/package.json +2 -2
@@ -0,0 +1,59 @@
1
+ import type { Chunk, Compilation, Compiler } from 'webpack';
2
+ import type { Entrypoint } from './types/extracted-webpack-types';
3
+ import type { AssetNames, ChunkResourceDescriptor, ConsolidatedOptions } from './types/types';
4
+ declare type SplitChunkDependenciesKeyMap = Map<Chunk, {
5
+ key: string;
6
+ dependency: string;
7
+ }>;
8
+ export declare type AppResourceParams = {
9
+ assetsUUID: string;
10
+ assetNames: AssetNames;
11
+ options: ConsolidatedOptions;
12
+ compiler: Compiler;
13
+ compilation: Compilation;
14
+ };
15
+ export default class AppResources {
16
+ private readonly assetsUUID;
17
+ private readonly compiler;
18
+ private readonly compilation;
19
+ private assetNames;
20
+ private options;
21
+ /**
22
+ * @param assetsUUID unique hash to identify the assets web-resource
23
+ * @param assetNames full module filepaths -> relative filepath
24
+ * @param options WrmPlugin configuration
25
+ * @param compiler Webpack compiler
26
+ * @param compilation Webpack compilation
27
+ */
28
+ constructor({ assetsUUID, assetNames, options, compiler, compilation }: AppResourceParams);
29
+ getSingleRuntimeFiles(): string[];
30
+ getAssetResourceDescriptor(): ChunkResourceDescriptor;
31
+ getDependencyResourcesFromChunk(chunk: Chunk): string[];
32
+ /**
33
+ * Every entrypoint has an attribute called "chunks".
34
+ * This contains all chunks that are needed to successfully "load" this entrypoint.
35
+ * Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
36
+ * If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
37
+ * 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.
38
+ *
39
+ * 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.
40
+ */
41
+ getSyncSplitChunks(): Chunk[];
42
+ /**
43
+ * Create a key and the fully-qualified web-resource descriptor for every split chunk.
44
+ * This is needed to point to reference these chunks as dependency in the entrypoint chunks
45
+ *
46
+ * <web-resource>
47
+ * ...
48
+ * <dependency>this-plugin-key:split_some_chunk</dependency>
49
+ * ...
50
+ * </web-resource>
51
+ */
52
+ getSyncSplitChunkDependenciesKeyMap(syncSplitChunks: Chunk[]): SplitChunkDependenciesKeyMap;
53
+ getSyncSplitChunksResourceDescriptors(): ChunkResourceDescriptor[];
54
+ getAsyncChunksResourceDescriptors(): ChunkResourceDescriptor[];
55
+ getEntryPoints(): Entrypoint[];
56
+ getEntryPointsResourceDescriptors(): ChunkResourceDescriptor[];
57
+ getResourceDescriptors(): ChunkResourceDescriptor[];
58
+ }
59
+ export {};
@@ -0,0 +1,171 @@
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 }) {
21
+ this.assetsUUID = assetsUUID;
22
+ this.assetNames = assetNames;
23
+ this.options = options;
24
+ this.compiler = compiler;
25
+ this.compilation = compilation;
26
+ }
27
+ getSingleRuntimeFiles() {
28
+ const files = this.getEntryPoints()
29
+ .map((entrypoint) => { var _a; return (_a = entrypoint.getRuntimeChunk()) === null || _a === void 0 ? void 0 : _a.files; })
30
+ .find(Boolean);
31
+ if (!files) {
32
+ return [];
33
+ }
34
+ return Array.from(files);
35
+ }
36
+ getAssetResourceDescriptor() {
37
+ // remove anything that we know is handled differently
38
+ const assetFiles = Object.keys(this.compilation.assets).filter((p) => !/\.(js|css|soy)(\.map)?$/.test(p));
39
+ return {
40
+ attributes: { key: `assets-${this.assetsUUID}` },
41
+ resources: assetFiles,
42
+ };
43
+ }
44
+ getDependencyResourcesFromChunk(chunk) {
45
+ return Array.from(chunk.auxiliaryFiles);
46
+ }
47
+ /**
48
+ * Every entrypoint has an attribute called "chunks".
49
+ * This contains all chunks that are needed to successfully "load" this entrypoint.
50
+ * Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
51
+ * If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
52
+ * 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.
53
+ *
54
+ * 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.
55
+ */
56
+ getSyncSplitChunks() {
57
+ const syncSplitChunks = (0, flatMap_1.default)(this.getEntryPoints(), (e) => e.chunks.filter((c) => c !== e.getRuntimeChunk()));
58
+ return (0, uniq_1.default)(syncSplitChunks);
59
+ }
60
+ /**
61
+ * Create a key and the fully-qualified web-resource descriptor for every split chunk.
62
+ * This is needed to point to reference these chunks as dependency in the entrypoint chunks
63
+ *
64
+ * <web-resource>
65
+ * ...
66
+ * <dependency>this-plugin-key:split_some_chunk</dependency>
67
+ * ...
68
+ * </web-resource>
69
+ */
70
+ getSyncSplitChunkDependenciesKeyMap(syncSplitChunks) {
71
+ const syncSplitChunkDependencyKeyMap = new Map();
72
+ for (const c of syncSplitChunks) {
73
+ const webResourceKey = `split_${c.name || c.id}`;
74
+ syncSplitChunkDependencyKeyMap.set(c, {
75
+ key: webResourceKey,
76
+ dependency: `${this.options.pluginKey}:${webResourceKey}`,
77
+ });
78
+ }
79
+ return syncSplitChunkDependencyKeyMap;
80
+ }
81
+ getSyncSplitChunksResourceDescriptors() {
82
+ const syncSplitChunks = this.getSyncSplitChunks();
83
+ const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(syncSplitChunks);
84
+ /**
85
+ * Create descriptors for the split chunk web-resources that have to be created.
86
+ * These include - like other chunk-descriptors their assets and external resources etc.
87
+ */
88
+ return syncSplitChunks.map((c) => {
89
+ const additionalFileDeps = this.getDependencyResourcesFromChunk(c);
90
+ return {
91
+ attributes: syncSplitChunkDependencyKeyMap.get(c),
92
+ externalResources: (0, WebpackHelpers_1.getExternalResourcesForChunk)(this.compilation, c),
93
+ resources: (0, uniq_1.default)([...c.files, ...additionalFileDeps]),
94
+ dependencies: (0, uniq_1.default)([...(0, base_dependencies_1.getBaseDependencies)(), ...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, c)]),
95
+ };
96
+ });
97
+ }
98
+ getAsyncChunksResourceDescriptors() {
99
+ return (0, WebpackHelpers_1.getAllAsyncChunks)(this.getEntryPoints()).map((c) => {
100
+ const additionalFileDeps = this.getDependencyResourcesFromChunk(c);
101
+ return {
102
+ attributes: { key: `${c.id}` },
103
+ externalResources: (0, WebpackHelpers_1.getExternalResourcesForChunk)(this.compilation, c),
104
+ resources: (0, uniq_1.default)([...c.files, ...additionalFileDeps]),
105
+ dependencies: (0, uniq_1.default)([...(0, base_dependencies_1.getBaseDependencies)(), ...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, c)]),
106
+ contexts: this.options.addAsyncNameAsContext && c.name ? [`async-chunk-${c.name}`] : undefined,
107
+ };
108
+ });
109
+ }
110
+ getEntryPoints() {
111
+ return Array.from(this.compilation.entrypoints.values());
112
+ }
113
+ getEntryPointsResourceDescriptors() {
114
+ const singleRuntime = (0, WebpackHelpers_1.isSingleRuntime)(this.compiler);
115
+ const syncSplitChunks = this.getSyncSplitChunks();
116
+ const syncSplitChunkDependencyKeyMap = this.getSyncSplitChunkDependenciesKeyMap(syncSplitChunks);
117
+ const singleRuntimeWebResourceKey = this.options.singleRuntimeWebResourceKey || RUNTIME_WR_KEY;
118
+ // Used in prod
119
+ const prodEntryPoints = this.getEntryPoints().map((entrypoint) => {
120
+ const name = entrypoint.name;
121
+ const webResourceAttrs = (0, web_resource_entrypoints_1.getWebresourceAttributesForEntry)(name, this.options.webresourceKeyMap);
122
+ const entrypointChunks = entrypoint.chunks;
123
+ const runtimeChunk = entrypoint.getRuntimeChunk();
124
+ // Retrieve all split chunks this entrypoint depends on. These must be added as "<dependency>"s to the web-resource of this entrypoint
125
+ const sharedSplitDeps = entrypointChunks
126
+ .map((c) => syncSplitChunkDependencyKeyMap.get(c))
127
+ .filter(Boolean)
128
+ .map((val) => val === null || val === void 0 ? void 0 : val.dependency);
129
+ // Construct the list of resources to add to this web-resource
130
+ const resourceList = (0, flatMap_1.default)(entrypointChunks, (c) => this.getDependencyResourcesFromChunk(c));
131
+ const dependencyList = [
132
+ ...(0, base_dependencies_1.getBaseDependencies)(),
133
+ ...(0, WebpackHelpers_1.getDependenciesForChunks)(this.compilation, runtimeChunk),
134
+ ...sharedSplitDeps,
135
+ ];
136
+ if (singleRuntime) {
137
+ dependencyList.unshift(`${this.options.pluginKey}:${singleRuntimeWebResourceKey}`);
138
+ }
139
+ else {
140
+ resourceList.unshift(...runtimeChunk.files);
141
+ }
142
+ return {
143
+ attributes: webResourceAttrs,
144
+ contexts: (0, web_resource_entrypoints_1.getContextForEntry)(name, this.options.contextMap, this.options.addEntrypointNameAsContext),
145
+ conditions: (0, web_resource_entrypoints_1.getConditionForEntry)(name, this.options.conditionMap),
146
+ dataProviders: (0, web_resource_entrypoints_1.getDataProvidersForEntry)(name, this.options.dataProvidersMap),
147
+ deprecationInfo: (0, web_resource_entrypoints_1.getDeprecationInfoForEntry)(name, this.options.deprecatedEntrypoints),
148
+ externalResources: (0, WebpackHelpers_1.getExternalResourcesForChunk)(this.compilation, runtimeChunk),
149
+ resources: (0, uniq_1.default)(resourceList),
150
+ dependencies: (0, uniq_1.default)(dependencyList).filter(Boolean),
151
+ };
152
+ });
153
+ if (singleRuntime) {
154
+ prodEntryPoints.push({
155
+ attributes: { key: singleRuntimeWebResourceKey },
156
+ dependencies: (0, base_dependencies_1.getBaseDependencies)(),
157
+ resources: this.getSingleRuntimeFiles(),
158
+ });
159
+ }
160
+ return prodEntryPoints;
161
+ }
162
+ getResourceDescriptors() {
163
+ return []
164
+ .concat(this.getSyncSplitChunksResourceDescriptors())
165
+ .concat(this.getAsyncChunksResourceDescriptors())
166
+ .concat(this.getEntryPointsResourceDescriptors())
167
+ .concat(this.getAssetResourceDescriptor());
168
+ }
169
+ }
170
+ exports.default = AppResources;
171
+ //# 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,qDAK0B;AAE1B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAYxC,MAAqB,YAAY;IAQ/B;;;;;;OAMG;IACH,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAqB;QACvF,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;IACjC,CAAC;IAED,qBAAqB;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE;aACh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,CAAC,gBAAgB,CAAC;gBAC5E,eAAe,EAAE,IAAA,qDAA0B,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;gBACrF,iBAAiB,EAAE,IAAA,6CAA4B,EAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC;gBAC/E,SAAS,EAAE,IAAA,cAAI,EAAC,YAAY,CAAC;gBAC7B,YAAY,EAAE,IAAA,cAAI,EAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa;aAC/D,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,EAAE;YACjB,eAAe,CAAC,IAAI,CAAC;gBACnB,UAAU,EAAE,EAAE,GAAG,EAAE,2BAA2B,EAAE;gBAChD,YAAY,EAAE,IAAA,uCAAmB,GAAE;gBACnC,SAAS,EAAE,IAAI,CAAC,qBAAqB,EAAE;aACxC,CAAC,CAAC;SACJ;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,sBAAsB;QACpB,OAAQ,EAAgC;aACrC,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,CAAC;aACpD,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,CAAC;aAChD,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,CAAC;aAChD,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF;AA7LD,+BA6LC"}
@@ -0,0 +1,10 @@
1
+ import type { Compilation, Compiler } from 'webpack';
2
+ import type { AppResourceParams } from './AppResources';
3
+ import AppResources from './AppResources';
4
+ declare 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, Module } 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) => Module[];
6
+ export declare const getExternalResourcesForChunk: (compilation: Compilation, chunk: Chunk) => WrmResource[];
7
+ export declare const getDependenciesForChunks: (compilation: Compilation, val: Chunk | Chunk[]) => string[];
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" | "amd" | "assign" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "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,115 @@
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
+ exports.extractLibraryDetailsFromWebpackConfig = exports.isSingleRuntime = exports.isRunningInProductionMode = exports.getDependenciesForChunks = exports.getExternalResourcesForChunk = exports.getChunkModules = exports.getAllAsyncChunks = void 0;
7
+ const flatMap_1 = __importDefault(require("lodash/flatMap"));
8
+ const uniq_1 = __importDefault(require("lodash/uniq"));
9
+ const ProvidedExternalDependencyModule_1 = __importDefault(require("./webpack-modules/ProvidedExternalDependencyModule"));
10
+ const WrmDependencyModule_1 = __importDefault(require("./webpack-modules/WrmDependencyModule"));
11
+ const WrmResourceModule_1 = __importDefault(require("./webpack-modules/WrmResourceModule"));
12
+ function isWrmResourceModule(m) {
13
+ return m instanceof WrmResourceModule_1.default;
14
+ }
15
+ function isProvidedDependencyOrWrmDependency(m) {
16
+ return m instanceof ProvidedExternalDependencyModule_1.default || m instanceof WrmDependencyModule_1.default;
17
+ }
18
+ const _getExternalResourceModules = (compilation, chunk) => {
19
+ return (0, exports.getChunkModules)(compilation, chunk)
20
+ .filter(isWrmResourceModule)
21
+ .map((m) => m.getResource());
22
+ };
23
+ const _getExternalDependencyModules = (compilation, chunk) => {
24
+ return (0, exports.getChunkModules)(compilation, chunk)
25
+ .filter(isProvidedDependencyOrWrmDependency)
26
+ .sort((a, b) => {
27
+ return (
28
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
29
+ require('webpack/lib/util/comparators.js').compareModulesByPreOrderIndexOrIdentifier(compilation.moduleGraph)(a, b));
30
+ })
31
+ .map((m) => m.getDependency());
32
+ };
33
+ const getAllAsyncChunks = (entryPoints) => {
34
+ const seenChunkGroups = new Set();
35
+ const recursivelyGetAllAsyncChunks = (chunkGroups) => {
36
+ const unseen = chunkGroups.filter((cg) => {
37
+ // circuit breaker
38
+ // dont use a chunk group more than once
39
+ const alreadySeen = seenChunkGroups.has(cg);
40
+ seenChunkGroups.add(cg);
41
+ return !alreadySeen;
42
+ });
43
+ return (0, flatMap_1.default)(unseen, (cg) => [...cg.chunks, ...recursivelyGetAllAsyncChunks(cg.getChildren())]);
44
+ };
45
+ // get all async chunks "deep"
46
+ const allAsyncChunks = (0, flatMap_1.default)(entryPoints, (e) => recursivelyGetAllAsyncChunks(e.getChildren()));
47
+ // dedupe
48
+ return (0, uniq_1.default)(allAsyncChunks);
49
+ };
50
+ exports.getAllAsyncChunks = getAllAsyncChunks;
51
+ const getChunkModules = (compilation, chunk) => {
52
+ return compilation.chunkGraph.getChunkModules(chunk);
53
+ };
54
+ exports.getChunkModules = getChunkModules;
55
+ const getExternalResourcesForChunk = (compilation, chunk) => {
56
+ const externalResources = new Set();
57
+ for (const dep of _getExternalResourceModules(compilation, chunk)) {
58
+ externalResources.add(dep);
59
+ }
60
+ return Array.from(externalResources);
61
+ };
62
+ exports.getExternalResourcesForChunk = getExternalResourcesForChunk;
63
+ const getDependenciesForChunks = (compilation, val) => {
64
+ const chunks = Array.isArray(val) ? val : [val];
65
+ const externalDeps = new Set();
66
+ for (const chunk of chunks) {
67
+ for (const dep of _getExternalDependencyModules(compilation, chunk)) {
68
+ externalDeps.add(dep);
69
+ }
70
+ // TODO: figure out how to pass this "properly" as a module
71
+ // @ts-expect-error See WrmPlugin.ts where this is set.
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
+ exports.getDependenciesForChunks = getDependenciesForChunks;
79
+ const isRunningInProductionMode = (compiler) => {
80
+ const { mode } = compiler.options;
81
+ return mode === 'production' || (mode === 'none' && process.env.NODE_ENV === 'production');
82
+ };
83
+ exports.isRunningInProductionMode = isRunningInProductionMode;
84
+ const isSingleRuntime = (compiler) => {
85
+ const { options } = compiler;
86
+ const runtimeChunkCfg = options.optimization && options.optimization.runtimeChunk;
87
+ if (runtimeChunkCfg) {
88
+ if (runtimeChunkCfg === 'single') {
89
+ return true;
90
+ }
91
+ const { name } = runtimeChunkCfg;
92
+ if (typeof name === 'string') {
93
+ return true;
94
+ }
95
+ if (typeof name === 'function') {
96
+ const resultA = name({ name: 'foo' });
97
+ const resultB = name({ name: 'bar' });
98
+ return resultA === resultB;
99
+ }
100
+ }
101
+ return false;
102
+ };
103
+ exports.isSingleRuntime = isSingleRuntime;
104
+ const extractLibraryDetailsFromWebpackConfig = (compiler) => {
105
+ const { library } = compiler.options.output;
106
+ if (!library) {
107
+ return { target: compiler.options.externalsType, name: undefined };
108
+ }
109
+ return {
110
+ target: library.type,
111
+ name: library.name,
112
+ };
113
+ };
114
+ exports.extractLibraryDetailsFromWebpackConfig = extractLibraryDetailsFromWebpackConfig;
115
+ //# sourceMappingURL=WebpackHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebpackHelpers.js","sourceRoot":"","sources":["../src/WebpackHelpers.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAqC;AACrC,uDAA+B;AAK/B,0HAAkG;AAClG,gGAAwE;AACxE,4FAAoE;AAEpE,SAAS,mBAAmB,CAAC,CAAS;IACpC,OAAO,CAAC,YAAY,2BAAiB,CAAC;AACxC,CAAC;AAED,SAAS,mCAAmC,CAAC,CAAS;IACpD,OAAO,CAAC,YAAY,0CAAgC,IAAI,CAAC,YAAY,6BAAmB,CAAC;AAC3F,CAAC;AAED,MAAM,2BAA2B,GAAG,CAAC,WAAwB,EAAE,KAAY,EAAiB,EAAE;IAC5F,OAAO,IAAA,uBAAe,EAAC,WAAW,EAAE,KAAK,CAA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,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACpE;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,4 @@
1
+ import type { Compilation, Compiler } from 'webpack';
2
+ import type { FactoryHandler } from './types/extracted-webpack-types';
3
+ export declare const hookIntoNormalModuleFactory: (stageName: string, compiler: Compiler, cb: FactoryHandler) => void;
4
+ export declare const hookIntoCompileDoneToGenerateReports: (stageName: string, compiler: Compiler, cb: (compilation: Compilation, callback: () => void) => void) => void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hookIntoCompileDoneToGenerateReports = exports.hookIntoNormalModuleFactory = void 0;
4
+ const hookIntoNormalModuleFactory = (stageName, compiler, cb) => {
5
+ compiler.hooks.compile.tap(stageName, (params) => {
6
+ const hooks = params.normalModuleFactory.hooks;
7
+ const passThruFactory = (data, callback) => callback();
8
+ hooks.factorize.tapAsync({
9
+ name: stageName,
10
+ stage: 99,
11
+ }, cb(passThruFactory));
12
+ });
13
+ };
14
+ exports.hookIntoNormalModuleFactory = hookIntoNormalModuleFactory;
15
+ const hookIntoCompileDoneToGenerateReports = (stageName, compiler, cb) => {
16
+ compiler.hooks.done.tapAsync(stageName, (stats, callback) => {
17
+ cb(stats.compilation, callback);
18
+ });
19
+ };
20
+ exports.hookIntoCompileDoneToGenerateReports = hookIntoCompileDoneToGenerateReports;
21
+ //# sourceMappingURL=WebpackRuntimeHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebpackRuntimeHelpers.js","sourceRoot":"","sources":["../src/WebpackRuntimeHelpers.ts"],"names":[],"mappings":";;;AAIO,MAAM,2BAA2B,GAAG,CAAC,SAAiB,EAAE,QAAkB,EAAE,EAAkB,EAAE,EAAE;IACvG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAC/C,MAAM,eAAe,GAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC3E,KAAK,CAAC,SAAS,CAAC,QAAQ,CACtB;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,EAAE;SACV,EACD,EAAE,CAAC,eAAe,CAAC,CACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAZW,QAAA,2BAA2B,+BAYtC;AAEK,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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rF,MAAM,WAAW,GAAG,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,45 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { DataProvidersMap, Options, ProvidedDependenciesMap, ResourceParamMap, TransformationMap } from './types/types';
3
+ declare 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
+ hookUpProvidedDependencies(compiler: Compiler): void;
36
+ injectWRMSpecificRequestTypes(compiler: Compiler): void;
37
+ /**
38
+ * Ensure the WRM.require function is available at runtime and is used to load any code-split chunks.
39
+ */
40
+ enableAsyncLoadingWithWRM(compiler: Compiler): void;
41
+ shouldOverwritePublicPath(): boolean;
42
+ shouldEnableAsyncLoadingWithWRM(): boolean;
43
+ apply(compiler: Compiler): void;
44
+ }
45
+ export = WrmPlugin;