@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.
- package/dist/AppResources.d.ts +59 -0
- package/dist/AppResources.js +171 -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 +115 -0
- package/dist/WebpackHelpers.js.map +1 -0
- package/dist/WebpackRuntimeHelpers.d.ts +4 -0
- package/dist/WebpackRuntimeHelpers.js +21 -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 +45 -0
- package/dist/WrmPlugin.js +488 -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 +23 -0
- package/dist/helpers/file-system.js.map +1 -0
- package/dist/helpers/options-parser.d.ts +3 -0
- package/dist/helpers/options-parser.js +28 -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/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
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.extractPathPrefixForXml = exports.toMap = void 0;
|
|
7
|
+
const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const escapedSeparator = (0, escapeRegExp_1.default)(path_1.default.sep);
|
|
10
|
+
const pathSeparatorRegex = new RegExp(`^\\${escapedSeparator}|\\${escapedSeparator}$`, 'g');
|
|
11
|
+
const toMap = (original) => {
|
|
12
|
+
if (original instanceof Map) {
|
|
13
|
+
return original;
|
|
14
|
+
}
|
|
15
|
+
return original && typeof original === 'object' ? new Map(Object.entries(original)) : new Map();
|
|
16
|
+
};
|
|
17
|
+
exports.toMap = toMap;
|
|
18
|
+
const extractPathPrefixForXml = (pathPrefix) => {
|
|
19
|
+
if (!pathPrefix || pathPrefix === '' || pathPrefix === '/') {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
// remove leading/trailing path separator
|
|
23
|
+
const withoutLeadingTrailingSeparators = pathPrefix.replace(pathSeparatorRegex, '');
|
|
24
|
+
// readd trailing slash - this time OS independent always a "/"
|
|
25
|
+
return withoutLeadingTrailingSeparators + '/';
|
|
26
|
+
};
|
|
27
|
+
exports.extractPathPrefixForXml = extractPathPrefixForXml;
|
|
28
|
+
//# sourceMappingURL=options-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-parser.js","sourceRoot":"","sources":["../../src/helpers/options-parser.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA+C;AAC/C,gDAAwB;AAIxB,MAAM,gBAAgB,GAAG,IAAA,sBAAY,EAAC,cAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,MAAM,gBAAgB,MAAM,gBAAgB,GAAG,EAAE,GAAG,CAAC,CAAC;AAErF,MAAM,KAAK,GAAG,CAAI,QAAqB,EAAkB,EAAE;IAChE,IAAI,QAAQ,YAAY,GAAG,EAAE;QAC3B,OAAO,QAA0B,CAAC;KACnC;IACD,OAAO,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;AAClG,CAAC,CAAC;AALW,QAAA,KAAK,SAKhB;AAEK,MAAM,uBAAuB,GAAG,CAAC,UAA8B,EAAE,EAAE;IACxE,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,GAAG,EAAE;QAC1D,OAAO,EAAE,CAAC;KACX;IAED,yCAAyC;IACzC,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACpF,+DAA+D;IAC/D,OAAO,gCAAgC,GAAG,GAAG,CAAC;AAChD,CAAC,CAAC;AATW,QAAA,uBAAuB,2BASlC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const xml_1 = require("./xml");
|
|
4
|
+
const renderParams = (params) => {
|
|
5
|
+
if (!params) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return params.map((param) => (0, xml_1.renderElement)('param', param.attributes, param.value)).join('');
|
|
9
|
+
};
|
|
10
|
+
function isConditions(arg) {
|
|
11
|
+
if (Array.isArray(arg)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return 'type' in arg;
|
|
15
|
+
}
|
|
16
|
+
const renderCondition = (condition) => {
|
|
17
|
+
if (!condition) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
// we have an array of conditions or condition
|
|
21
|
+
if (Array.isArray(condition)) {
|
|
22
|
+
return condition.map(renderCondition).join('');
|
|
23
|
+
}
|
|
24
|
+
// we have a "conditions"-joiner for multiple sub conditions
|
|
25
|
+
if (isConditions(condition)) {
|
|
26
|
+
return (0, xml_1.renderElement)('conditions', { type: condition.type }, renderCondition(condition.conditions));
|
|
27
|
+
}
|
|
28
|
+
// we have a "condition"
|
|
29
|
+
return (0, xml_1.renderElement)('condition', ` class="${condition.class}" ${condition.invert ? 'invert="true"' : ''}`, renderParams(condition.params));
|
|
30
|
+
};
|
|
31
|
+
exports.default = renderCondition;
|
|
32
|
+
//# sourceMappingURL=renderCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderCondition.js","sourceRoot":"","sources":["../../src/helpers/renderCondition.ts"],"names":[],"mappings":";;AACA,+BAAsC;AAEtC,MAAM,YAAY,GAAG,CAAC,MAAoC,EAAE,EAAE;IAC5D,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mBAAa,EAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,GAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IAED,OAAO,MAAM,IAAI,GAAG,CAAC;AACvB,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,SAAgC,EAAU,EAAE;IACnE,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,CAAC;KACX;IAED,8CAA8C;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5B,OAAO,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KAChD;IAED,4DAA4D;IAC5D,IAAI,YAAY,CAAC,SAAS,CAAC,EAAE;QAC3B,OAAO,IAAA,mBAAa,EAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;KACrG;IAED,wBAAwB;IACxB,OAAO,IAAA,mBAAa,EAClB,WAAW,EACX,WAAW,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,EACxE,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAC/B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TransformationMap } from '../types/types';
|
|
2
|
+
declare type Resource = {
|
|
3
|
+
location: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Converts a map of filetype-to-transformer entries in to the set of XML transform elements
|
|
7
|
+
* required for a given set of resources. Renders every transform if no resources are provided.
|
|
8
|
+
*/
|
|
9
|
+
declare const renderTransformations: (transformations: TransformationMap, resources?: Resource[]) => string[];
|
|
10
|
+
export default renderTransformations;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const xml_1 = require("./xml");
|
|
8
|
+
const renderTransformer = (transformers) => {
|
|
9
|
+
if (transformers && transformers.length) {
|
|
10
|
+
return transformers.map((transformer) => (0, xml_1.renderElement)('transformer', { key: transformer })).join('');
|
|
11
|
+
}
|
|
12
|
+
return '';
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generates the appropriate function to be used when filtering a transform map down to only those required.
|
|
16
|
+
*/
|
|
17
|
+
const transformFilterFactory = (resources) => {
|
|
18
|
+
if (resources && resources.length) {
|
|
19
|
+
const resourceFiletypes = resources.map((resource) => path_1.default.extname(resource.location).substr(1));
|
|
20
|
+
return (ext) => resourceFiletypes.includes(ext);
|
|
21
|
+
}
|
|
22
|
+
return () => true;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Converts a map of filetype-to-transformer entries in to the set of XML transform elements
|
|
26
|
+
* required for a given set of resources. Renders every transform if no resources are provided.
|
|
27
|
+
*/
|
|
28
|
+
const renderTransformations = (transformations, resources = []) => {
|
|
29
|
+
return Array.from(transformations.keys())
|
|
30
|
+
.filter(transformFilterFactory(resources))
|
|
31
|
+
.map((extension) => (0, xml_1.renderElement)('transformation', { extension }, renderTransformer(transformations.get(extension))));
|
|
32
|
+
};
|
|
33
|
+
exports.default = renderTransformations;
|
|
34
|
+
//# sourceMappingURL=renderTransformations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTransformations.js","sourceRoot":"","sources":["../../src/helpers/renderTransformations.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAGxB,+BAAsC;AAEtC,MAAM,iBAAiB,GAAG,CAAC,YAAsB,EAAE,EAAE;IACnD,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,EAAE;QACvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,mBAAa,EAAC,aAAa,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACvG;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAAC,SAAqB,EAAE,EAAE;IACvD,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,EAAE;QACjC,MAAM,iBAAiB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACjG,OAAO,CAAC,GAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KACzD;IACD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;AACpB,CAAC,CAAC;AAMF;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,eAAkC,EAAE,YAAwB,EAAE,EAAY,EAAE;IACzG,OAAO,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;SACtC,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;SACzC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACjB,IAAA,mBAAa,EAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,EAAE,iBAAiB,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,CAAC,CACnG,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toTrimmedString: (val: string | unknown) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toTrimmedString = void 0;
|
|
4
|
+
const toTrimmedString = (val) => {
|
|
5
|
+
const maybeStr = typeof val === 'string' ? val : '';
|
|
6
|
+
return maybeStr.trim();
|
|
7
|
+
};
|
|
8
|
+
exports.toTrimmedString = toTrimmedString;
|
|
9
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/helpers/string.ts"],"names":[],"mappings":";;;AAAO,MAAM,eAAe,GAAG,CAAC,GAAqB,EAAE,EAAE;IACvD,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConditionsMap, ContextMap, DataProvidersMap, DeprecationMap, WebresourceMap } from '../types/types';
|
|
2
|
+
export declare const getContextForEntry: (entry: string, contextMap: ContextMap, addEntrypointNameAsContext: boolean) => string[];
|
|
3
|
+
export declare const getWebresourceAttributesForEntry: (entry: string, webresourceKeyMap: WebresourceMap) => {
|
|
4
|
+
key: string;
|
|
5
|
+
moduleId: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getConditionForEntry: (entry: string, conditionMap: ConditionsMap) => import("../types/types").Condition | undefined;
|
|
8
|
+
export declare const getDataProvidersForEntry: (entrypoint: string, dataProvidersMap: DataProvidersMap) => import("../types/types").DataProvider[];
|
|
9
|
+
export declare const getDeprecationInfoForEntry: (entrypoint: string, deprecationMap: DeprecationMap) => import("../types/types").DeprecationInfo | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeprecationInfoForEntry = exports.getDataProvidersForEntry = exports.getConditionForEntry = exports.getWebresourceAttributesForEntry = exports.getContextForEntry = void 0;
|
|
4
|
+
const web_resource_parser_1 = require("./web-resource-parser");
|
|
5
|
+
const getContextForEntry = (entry, contextMap, addEntrypointNameAsContext) => {
|
|
6
|
+
const initialArray = addEntrypointNameAsContext ? [entry] : [];
|
|
7
|
+
if (!contextMap.has(entry)) {
|
|
8
|
+
return initialArray;
|
|
9
|
+
}
|
|
10
|
+
// TODO: verify if we need the typecheck here, as Intellij is rightfully complaining about the typecheck here as `contextMap` should only return "strings"
|
|
11
|
+
// noinspection SuspiciousTypeOfGuard
|
|
12
|
+
return initialArray
|
|
13
|
+
.concat(contextMap.get(entry))
|
|
14
|
+
.filter((context) => typeof context === 'string' && context.trim() !== '');
|
|
15
|
+
};
|
|
16
|
+
exports.getContextForEntry = getContextForEntry;
|
|
17
|
+
const getWebresourceAttributesForEntry = (entry, webresourceKeyMap) => {
|
|
18
|
+
const wrKey = webresourceKeyMap.get(entry);
|
|
19
|
+
// Create the default attribute values
|
|
20
|
+
let attrs = { key: `entrypoint-${entry}`, moduleId: entry };
|
|
21
|
+
// Extend the attributes with parsed, valid values
|
|
22
|
+
if (typeof wrKey === 'object') {
|
|
23
|
+
attrs = Object.assign(attrs, (0, web_resource_parser_1.parseWebResourceAttributes)(wrKey));
|
|
24
|
+
}
|
|
25
|
+
// Override the key if a non-empty string is provided
|
|
26
|
+
if (typeof wrKey === 'string') {
|
|
27
|
+
attrs = Object.assign(attrs, (0, web_resource_parser_1.parseWebResourceAttributes)({ key: wrKey }));
|
|
28
|
+
}
|
|
29
|
+
return attrs;
|
|
30
|
+
};
|
|
31
|
+
exports.getWebresourceAttributesForEntry = getWebresourceAttributesForEntry;
|
|
32
|
+
const getConditionForEntry = (entry, conditionMap) => {
|
|
33
|
+
return conditionMap.get(entry);
|
|
34
|
+
};
|
|
35
|
+
exports.getConditionForEntry = getConditionForEntry;
|
|
36
|
+
const getDataProvidersForEntry = (entrypoint, dataProvidersMap) => {
|
|
37
|
+
return dataProvidersMap.get(entrypoint) || [];
|
|
38
|
+
};
|
|
39
|
+
exports.getDataProvidersForEntry = getDataProvidersForEntry;
|
|
40
|
+
const getDeprecationInfoForEntry = (entrypoint, deprecationMap) => {
|
|
41
|
+
return deprecationMap.get(entrypoint);
|
|
42
|
+
};
|
|
43
|
+
exports.getDeprecationInfoForEntry = getDeprecationInfoForEntry;
|
|
44
|
+
//# sourceMappingURL=web-resource-entrypoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-resource-entrypoints.js","sourceRoot":"","sources":["../../src/helpers/web-resource-entrypoints.ts"],"names":[],"mappings":";;;AACA,+DAAmE;AAE5D,MAAM,kBAAkB,GAAG,CAChC,KAAa,EACb,UAAsB,EACtB,0BAAmC,EACzB,EAAE;IACZ,MAAM,YAAY,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAC1B,OAAO,YAAY,CAAC;KACrB;IAED,0JAA0J;IAC1J,qCAAqC;IACrC,OAAO,YAAY;SAChB,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;SAC9B,MAAM,CAAC,CAAC,OAAO,EAAqB,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAClG,CAAC,CAAC;AAfW,QAAA,kBAAkB,sBAe7B;AAEK,MAAM,gCAAgC,GAAG,CAAC,KAAa,EAAE,iBAAiC,EAAE,EAAE;IACnG,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE3C,sCAAsC;IACtC,IAAI,KAAK,GAAG,EAAE,GAAG,EAAE,cAAc,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAE5D,kDAAkD;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,gDAA0B,EAAC,KAAK,CAAC,CAAC,CAAC;KACjE;IAED,qDAAqD;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,gDAA0B,EAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;KAC1E;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAjBW,QAAA,gCAAgC,oCAiB3C;AAEK,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAE,YAA2B,EAAE,EAAE;IACjF,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAEK,MAAM,wBAAwB,GAAG,CAAC,UAAkB,EAAE,gBAAkC,EAAE,EAAE;IACjG,OAAO,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC;AAEK,MAAM,0BAA0B,GAAG,CAAC,UAAkB,EAAE,cAA8B,EAAE,EAAE;IAC/F,OAAO,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC,CAAC;AAFW,QAAA,0BAA0B,8BAErC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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.renderWebResource = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const renderCondition_1 = __importDefault(require("./renderCondition"));
|
|
9
|
+
const renderTransformations_1 = __importDefault(require("./renderTransformations"));
|
|
10
|
+
const web_resource_parser_1 = require("./web-resource-parser");
|
|
11
|
+
const xml_1 = require("./xml");
|
|
12
|
+
/**
|
|
13
|
+
* Renders list of data providers {@see DataProvider} as <data key="provider-key" class="data.provider.Class" /> elements
|
|
14
|
+
*/
|
|
15
|
+
const renderDataProviders = (dataProviders) => {
|
|
16
|
+
if (!Array.isArray(dataProviders) || dataProviders.length === 0) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return dataProviders.map((dataProvider) => (0, xml_1.renderElement)('data', {
|
|
20
|
+
key: dataProvider.key,
|
|
21
|
+
class: dataProvider.class,
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
function renderContexts(contexts) {
|
|
25
|
+
return contexts ? contexts.map((context) => `<context>${context}</context>`) : [];
|
|
26
|
+
}
|
|
27
|
+
function renderDependencies(dependencies) {
|
|
28
|
+
return dependencies ? dependencies.map((dependency) => `<dependency>${dependency}</dependency>`) : [];
|
|
29
|
+
}
|
|
30
|
+
function renderDeprecationInfo(deprecationInfo, pluginKey, webResourceDescriptors) {
|
|
31
|
+
if (deprecationInfo) {
|
|
32
|
+
if (deprecationInfo === true) {
|
|
33
|
+
return ['<deprecated />'];
|
|
34
|
+
}
|
|
35
|
+
const attributes = {};
|
|
36
|
+
if (deprecationInfo.sinceVersion) {
|
|
37
|
+
attributes.since = deprecationInfo.sinceVersion;
|
|
38
|
+
}
|
|
39
|
+
if (deprecationInfo.removeInVersion) {
|
|
40
|
+
attributes.remove = deprecationInfo.removeInVersion;
|
|
41
|
+
}
|
|
42
|
+
if (deprecationInfo.alternative) {
|
|
43
|
+
attributes.alternative = calculateAlternativeResourceKey(deprecationInfo.alternative, pluginKey, webResourceDescriptors);
|
|
44
|
+
}
|
|
45
|
+
return [(0, xml_1.renderElement)('deprecated', attributes, deprecationInfo.extraInfo)];
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Expand the alternative attribute value to a full resource key if it is a reference to another entrypoint.
|
|
51
|
+
* @param alternativeAttributeValue the value of the "alternative" attribute in the deprecatedEntrypoints map. Can be a simple string
|
|
52
|
+
* referencing another entrypoint or a full resource key.
|
|
53
|
+
* @param pluginKey the plugin key
|
|
54
|
+
* @param webResourceDescriptors list all entry-points specified in the current build
|
|
55
|
+
*/
|
|
56
|
+
function calculateAlternativeResourceKey(alternativeAttributeValue, pluginKey, webResourceDescriptors) {
|
|
57
|
+
// If a colon is present, the users have specified a full resource key, and we don't need to do any mapping.
|
|
58
|
+
if (alternativeAttributeValue.includes(':')) {
|
|
59
|
+
return alternativeAttributeValue;
|
|
60
|
+
}
|
|
61
|
+
// We need to check if the alternative entry-point's web resource key has been mapped to something else.
|
|
62
|
+
const entryPointDescriptor = webResourceDescriptors.find((descriptor) => descriptor.attributes.moduleId === alternativeAttributeValue);
|
|
63
|
+
if (entryPointDescriptor !== undefined) {
|
|
64
|
+
return `${pluginKey}:${entryPointDescriptor.attributes.key}`;
|
|
65
|
+
}
|
|
66
|
+
// If it's not an entry point just assume it's some other web resource in the same plugin defined outside of webpack.
|
|
67
|
+
return `${pluginKey}:${alternativeAttributeValue}`;
|
|
68
|
+
}
|
|
69
|
+
const generateResourceElement = (resource, parameterMap) => {
|
|
70
|
+
const { name, location } = resource;
|
|
71
|
+
const assetContentType = path_1.default.extname(location).substr(1);
|
|
72
|
+
const parameters = parameterMap.get(assetContentType) || [];
|
|
73
|
+
const children = [];
|
|
74
|
+
const renderParameters = (attributes) => children.push((0, xml_1.renderElement)('param', attributes));
|
|
75
|
+
parameters.forEach(renderParameters);
|
|
76
|
+
return (0, xml_1.renderElement)('resource', {
|
|
77
|
+
type: 'download',
|
|
78
|
+
name,
|
|
79
|
+
location,
|
|
80
|
+
}, children);
|
|
81
|
+
};
|
|
82
|
+
const renderResources = (parameterMap, resources) => {
|
|
83
|
+
return resources
|
|
84
|
+
? resources
|
|
85
|
+
.filter(Boolean)
|
|
86
|
+
// ignore all `.map` files, since the WRM finds them of its own accord.
|
|
87
|
+
.filter((resource) => !resource.location.endsWith('.map'))
|
|
88
|
+
.map((resource) => generateResourceElement(resource, parameterMap))
|
|
89
|
+
: [];
|
|
90
|
+
};
|
|
91
|
+
const renderWebResource = (webresource, descriptors, options) => {
|
|
92
|
+
const { resources = [], externalResources = [], contexts, dependencies, deprecationInfo, conditions, dataProviders, } = webresource;
|
|
93
|
+
const attributes = (0, web_resource_parser_1.parseWebResourceAttributes)(webresource.attributes);
|
|
94
|
+
const allResources = [];
|
|
95
|
+
const children = [];
|
|
96
|
+
const prependPathPrefix = (location) => options.locationPrefix + location;
|
|
97
|
+
// add resources for direct dependencies (e.g., JS and CSS files)
|
|
98
|
+
allResources.push(...resources.map((res) => ({ name: res, location: prependPathPrefix(res) })));
|
|
99
|
+
// add resources for indirect dependencies (e.g., images extracted from CSS)
|
|
100
|
+
allResources.push(...externalResources.map((wr) => ({ name: wr.name, location: prependPathPrefix(wr.location) })));
|
|
101
|
+
children.push(...(0, renderTransformations_1.default)(options.transformationMap, allResources), ...renderContexts(contexts), ...renderDependencies(dependencies), ...renderDeprecationInfo(deprecationInfo, options.pluginKey, descriptors), ...renderResources(options.resourceParamMap, allResources), ...renderDataProviders(dataProviders), (0, renderCondition_1.default)(conditions));
|
|
102
|
+
return (0, xml_1.renderElement)('web-resource', attributes, children);
|
|
103
|
+
};
|
|
104
|
+
exports.renderWebResource = renderWebResource;
|
|
105
|
+
//# sourceMappingURL=web-resource-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-resource-generator.js","sourceRoot":"","sources":["../../src/helpers/web-resource-generator.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAYxB,wEAAgD;AAChD,oFAAuD;AACvD,+DAAmE;AACnE,+BAAsC;AAEtC;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,aAAyC,EAAE,EAAE;IACxE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/D,OAAO,EAAE,CAAC;KACX;IAED,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CACxC,IAAA,mBAAa,E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AAC,CAAC,CAAC,CAAC;IAEnH,QAAQ,CAAC,IAAI,CACX,GAAG,IAAA,+BAAgB,EAAC,OAAO,CAAC,iBAAsC,EAAE,YAAY,CAAC,EACjF,GAAG,cAAc,CAAC,QAAQ,CAAC,EAC3B,GAAG,kBAAkB,CAAC,YAAY,CAAC,EACnC,GAAG,qBAAqB,CAAC,eAAe,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,EACzE,GAAG,eAAe,CAAC,OAAO,CAAC,gBAAoC,EAAE,YAAY,CAAC,EAC9E,GAAG,mBAAmB,CAAC,aAAa,CAAC,EACrC,IAAA,yBAAe,EAAC,UAAU,CAAC,CAC5B,CAAC;IAEF,OAAO,IAAA,mBAAa,EAAC,cAAc,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC,CAAC;AArCW,QAAA,iBAAiB,qBAqC5B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseWebResourceAttributes = void 0;
|
|
4
|
+
const string_1 = require("./string");
|
|
5
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
6
|
+
const parseWebResourceAttributes = (data) => {
|
|
7
|
+
const attributes = {};
|
|
8
|
+
// Only parse objects.
|
|
9
|
+
if (data && typeof data === 'object') {
|
|
10
|
+
// define the key if a non-empty string was provided
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(data, 'key')) {
|
|
12
|
+
const customKey = (0, string_1.toTrimmedString)(data.key);
|
|
13
|
+
if (customKey) {
|
|
14
|
+
attributes.key = customKey;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// define the state as either enabled or disabled
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(data, 'state')) {
|
|
19
|
+
let isEnabled = true;
|
|
20
|
+
if (typeof data.state === 'boolean') {
|
|
21
|
+
isEnabled = data.state;
|
|
22
|
+
}
|
|
23
|
+
else if (typeof data.state === 'string') {
|
|
24
|
+
isEnabled = data.state !== 'disabled';
|
|
25
|
+
}
|
|
26
|
+
attributes.state = isEnabled ? 'enabled' : 'disabled';
|
|
27
|
+
}
|
|
28
|
+
// define the name if a non-empty string was provided
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(data, 'name')) {
|
|
30
|
+
const customName = (0, string_1.toTrimmedString)(data.name);
|
|
31
|
+
if (customName) {
|
|
32
|
+
attributes.name = customName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return attributes;
|
|
37
|
+
};
|
|
38
|
+
exports.parseWebResourceAttributes = parseWebResourceAttributes;
|
|
39
|
+
//# sourceMappingURL=web-resource-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-resource-parser.js","sourceRoot":"","sources":["../../src/helpers/web-resource-parser.ts"],"names":[],"mappings":";;;AACA,qCAA2C;AAE3C,wDAAwD;AACjD,MAAM,0BAA0B,GAAG,CAAC,IAAuB,EAAE,EAAE;IACpE,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,sBAAsB;IACtB,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACpC,oDAAoD;QACpD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;YACrD,MAAM,SAAS,GAAG,IAAA,wBAAe,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC;aAC5B;SACF;QAED,iDAAiD;QACjD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;YACvD,IAAI,SAAS,GAAG,IAAI,CAAC;YACrB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;gBACnC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;aACxB;iBAAM,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;gBACzC,SAAS,GAAG,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC;aACvC;YACD,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;SACvD;QAED,qDAAqD;QACrD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;YACtD,MAAM,UAAU,GAAG,IAAA,wBAAe,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9C,IAAI,UAAU,EAAE;gBACd,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC;aAC9B;SACF;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAjCW,QAAA,0BAA0B,8BAiCrC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare type AttributesObject = {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
};
|
|
4
|
+
export declare const stringifyAttributes: (attributes: AttributesObject) => string;
|
|
5
|
+
export declare const renderElement: (name: string, attributes: AttributesObject | string | undefined, children?: string | string[] | undefined) => string;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderElement = exports.stringifyAttributes = void 0;
|
|
4
|
+
const stringifyAttributes = (attributes) => {
|
|
5
|
+
if (!attributes) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return (' ' +
|
|
9
|
+
Object.keys(attributes)
|
|
10
|
+
.map((key) => {
|
|
11
|
+
const val = typeof attributes[key] === 'undefined' ? '' : String(attributes[key]);
|
|
12
|
+
return `${key}="${val}"`;
|
|
13
|
+
})
|
|
14
|
+
.join(' '));
|
|
15
|
+
};
|
|
16
|
+
exports.stringifyAttributes = stringifyAttributes;
|
|
17
|
+
const renderElement = (name, attributes, children) => {
|
|
18
|
+
if (typeof attributes === 'object') {
|
|
19
|
+
attributes = (0, exports.stringifyAttributes)(attributes);
|
|
20
|
+
}
|
|
21
|
+
// avoid outputting 'undefined' when attributes aren't present.
|
|
22
|
+
if (!attributes) {
|
|
23
|
+
attributes = '';
|
|
24
|
+
}
|
|
25
|
+
// convert children array in to a string.
|
|
26
|
+
// assume they are string values already. (todo: refactor for nested rendering?)
|
|
27
|
+
if (Array.isArray(children)) {
|
|
28
|
+
children = children.join('\n');
|
|
29
|
+
}
|
|
30
|
+
// render self-closing tags based on whether there is no child input.
|
|
31
|
+
if (!children) {
|
|
32
|
+
return `<${name}${attributes}/>`;
|
|
33
|
+
}
|
|
34
|
+
return `<${name}${attributes}>${children}</${name}>`;
|
|
35
|
+
};
|
|
36
|
+
exports.renderElement = renderElement;
|
|
37
|
+
//# sourceMappingURL=xml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../../src/helpers/xml.ts"],"names":[],"mappings":";;;AAEO,MAAM,mBAAmB,GAAG,CAAC,UAA4B,EAAE,EAAE;IAClE,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,EAAE,CAAC;KACX;IAED,OAAO,CACL,GAAG;QACH,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aACpB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,GAAG,GAAG,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YAClF,OAAO,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC;QAC3B,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B;AAEK,MAAM,aAAa,GAAG,CAC3B,IAAY,EACZ,UAAiD,EACjD,QAA4B,EAC5B,EAAE;IACF,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,UAAU,GAAG,IAAA,2BAAmB,EAAC,UAAU,CAAC,CAAC;KAC9C;IACD,+DAA+D;IAC/D,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,EAAE,CAAC;KACjB;IAED,yCAAyC;IACzC,gFAAgF;IAChF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAChC;IACD,qEAAqE;IACrE,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,IAAI,GAAG,UAAU,IAAI,CAAC;KAClC;IAED,OAAO,IAAI,IAAI,GAAG,UAAU,IAAI,QAAQ,KAAK,IAAI,GAAG,CAAC;AACvD,CAAC,CAAC;AAxBW,QAAA,aAAa,iBAwBxB"}
|
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.error = exports.warn = exports.log = exports.setVerbose = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
let verbose = false;
|
|
6
|
+
const setVerbose = (arg) => (verbose = arg);
|
|
7
|
+
exports.setVerbose = setVerbose;
|
|
8
|
+
const log = (...args) => {
|
|
9
|
+
if (verbose) {
|
|
10
|
+
console.log(...args);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.log = log;
|
|
14
|
+
const warn = (...args) => {
|
|
15
|
+
if (verbose) {
|
|
16
|
+
console.warn(...args);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.warn = warn;
|
|
20
|
+
const error = (...args) => {
|
|
21
|
+
if (verbose) {
|
|
22
|
+
console.error(...args);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.error = error;
|
|
26
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,IAAI,OAAO,GAAG,KAAK,CAAC;AACb,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;AAA/C,QAAA,UAAU,cAAqC;AAErD,MAAM,GAAG,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;IACxC,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KACtB;AACH,CAAC,CAAC;AAJW,QAAA,GAAG,OAId;AAEK,MAAM,IAAI,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;IACzC,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;KACvB;AACH,CAAC,CAAC;AAJW,QAAA,IAAI,QAIf;AAEK,MAAM,KAAK,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;IAC1C,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;KACxB;AACH,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const requireEnsureShim = (pluginKey) => `
|
|
4
|
+
if(installedChunks[chunkId] === 0) { // 0 means "already installed".
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
}
|
|
7
|
+
if (installedChunks[chunkId]) {
|
|
8
|
+
return installedChunks[chunkId][2];
|
|
9
|
+
}
|
|
10
|
+
promises.push(
|
|
11
|
+
new Promise(function(resolve, reject) {
|
|
12
|
+
installedChunks[chunkId] = [resolve, reject];
|
|
13
|
+
}),
|
|
14
|
+
new Promise(function(resolve, reject) {
|
|
15
|
+
WRM.require('wrc!${pluginKey}:' + chunkId).then(resolve, reject);
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
return installedChunks[chunkId][2] = Promise.all(promises);
|
|
19
|
+
`;
|
|
20
|
+
exports.default = requireEnsureShim;
|
|
21
|
+
//# sourceMappingURL=require-ensure-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-ensure-shim.js","sourceRoot":"","sources":["../../src/shims/require-ensure-shim.ts"],"names":[],"mappings":";;AAAA,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC;;;;;;;;;;;;2BAYtB,SAAS;;;;CAInC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Method signature is:
|
|
3
|
+
```
|
|
4
|
+
var inProgress[url] = [done];
|
|
5
|
+
var dataWebpackPrefix = "...";
|
|
6
|
+
// loadScript function to load a script via script tag
|
|
7
|
+
__webpack_require__.l = (url, done, key) => {
|
|
8
|
+
```
|
|
9
|
+
The variables are:
|
|
10
|
+
'done' - callback function
|
|
11
|
+
'key' - should be in the form "chunk-" + chunkId
|
|
12
|
+
*/
|
|
13
|
+
declare const runtimeLoadShim: (pluginKey: string, watchMode: boolean, publicPath: string) => string;
|
|
14
|
+
export default runtimeLoadShim;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
Method signature is:
|
|
4
|
+
```
|
|
5
|
+
var inProgress[url] = [done];
|
|
6
|
+
var dataWebpackPrefix = "...";
|
|
7
|
+
// loadScript function to load a script via script tag
|
|
8
|
+
__webpack_require__.l = (url, done, key) => {
|
|
9
|
+
```
|
|
10
|
+
The variables are:
|
|
11
|
+
'done' - callback function
|
|
12
|
+
'key' - should be in the form "chunk-" + chunkId
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const runtimeLoadShim = (pluginKey, watchMode, publicPath) => {
|
|
16
|
+
const watchModeShim = watchMode
|
|
17
|
+
? `
|
|
18
|
+
function waitForScriptsLoaded(done) {
|
|
19
|
+
// scripts that are showing up in the performance stats are already loaded, not including scripts in the dom that still load
|
|
20
|
+
const loadedScriptsSrc = performance.getEntriesByType('resource')
|
|
21
|
+
.filter(r => r.initiatorType === 'script' && r.name.startsWith('${publicPath}'))
|
|
22
|
+
.map(r => r.name);
|
|
23
|
+
const domScripts = Array.from(document.querySelectorAll('script')).filter(s => s.src.startsWith('${publicPath}'));
|
|
24
|
+
const deltaScripts = domScripts.filter(s => !loadedScriptsSrc.includes(s.src));
|
|
25
|
+
const promises = deltaScripts.map(deltaScript => {
|
|
26
|
+
return new Promise(res => {
|
|
27
|
+
deltaScript.addEventListener('load', res);
|
|
28
|
+
deltaScript.addEventListener('error', res);
|
|
29
|
+
deltaScript.addEventListener('abort', res);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
Promise.all(promises).then(done);
|
|
33
|
+
}
|
|
34
|
+
`
|
|
35
|
+
: '';
|
|
36
|
+
return `
|
|
37
|
+
// the raw chunkId is used as a web-resource key.
|
|
38
|
+
// webpack5's jsonp loader will call the load function with a prefixed chunkId.
|
|
39
|
+
// see https://github.com/webpack/webpack/blob/master/lib/web/JsonpChunkLoadingRuntimeModule.js#L181
|
|
40
|
+
const chunkId = (key || '').replace(/^chunk-/,'');
|
|
41
|
+
// use WRM.require instead of webpack's url-based lookup.
|
|
42
|
+
// since WRM.require can handle in-progress loads itself, we don't need to worry about
|
|
43
|
+
// registering the 'done' callback in the inProgress array; we just call it after WRM does its thing.
|
|
44
|
+
// ------
|
|
45
|
+
// WATCHMODE - In watch mode a batch file is loaded that contains a script that loads the actual contents from a webpack dev server.
|
|
46
|
+
// This means we cant execute the "done" callback for webpack before the second script is loaded.
|
|
47
|
+
// The solution is to check for all scripts to the dev-server in "performance" as this will only contain already fully loaded scripts and
|
|
48
|
+
// calculate the diff to all scripts in the body. Any script that is not showing up in "performance" will be listened to for a load event.
|
|
49
|
+
// Only once all those load events are successfully returned do we call the "done" callback to webpack and prevent a range of errors that
|
|
50
|
+
// would be triggered otherwise.
|
|
51
|
+
${watchModeShim}
|
|
52
|
+
WRM.require('wrc!${pluginKey}:' + chunkId).then(() => ${watchMode ? 'waitForScriptsLoaded(done)' : 'done()'}, (data) => {
|
|
53
|
+
var e = new Event('missing');
|
|
54
|
+
e.data = data;
|
|
55
|
+
done(e);
|
|
56
|
+
});
|
|
57
|
+
// we don't want the rest of the normal load function to run.
|
|
58
|
+
return;
|
|
59
|
+
`;
|
|
60
|
+
};
|
|
61
|
+
exports.default = runtimeLoadShim;
|
|
62
|
+
//# sourceMappingURL=runtime-load-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-load-shim.js","sourceRoot":"","sources":["../../src/shims/runtime-load-shim.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAE,SAAkB,EAAE,UAAkB,EAAE,EAAE;IACpF,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC;;;;wEAIkE,UAAU;;sGAEoB,UAAU;;;;;;;;;;;CAW/G;QACG,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;;;;;;;;;;;;;;;EAeP,aAAa;mBACI,SAAS,4BACxB,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,QAC7C;;;;;;;CAOD,CAAC;AACF,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Compilation, Compiler } from 'webpack';
|
|
2
|
+
import type { ArrayBaseType } from './types';
|
|
3
|
+
export declare type Entrypoint = Compilation['entrypoints'] extends Map<string, infer U> ? U : never;
|
|
4
|
+
export declare type PathData = Parameters<Compilation['getAssetPath']>[1];
|
|
5
|
+
declare type NormalModuleFactory = Parameters<Parameters<InstanceType<typeof Compiler>['hooks']['normalModuleFactory']['tap']>[1]>[0];
|
|
6
|
+
declare type FactorizeHandlerParameters = Parameters<Parameters<NormalModuleFactory['hooks']['factorize']['tapAsync']>[1]>;
|
|
7
|
+
declare type FactorizeHandlerCallback = FactorizeHandlerParameters[1];
|
|
8
|
+
declare type ResolveData = FactorizeHandlerParameters[0];
|
|
9
|
+
export declare type ResolveDataHandler = (data: ResolveData, cb: FactorizeHandlerCallback) => void;
|
|
10
|
+
export declare type FactoryHandler = (fn: ResolveDataHandler) => ResolveDataHandler;
|
|
11
|
+
export declare type ChunkGroup = ArrayBaseType<Compilation['chunkGroups']>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extracted-webpack-types.js","sourceRoot":"","sources":["../../src/types/extracted-webpack-types.ts"],"names":[],"mappings":""}
|