| | |
| | | /** @typedef {import("../ExternalModule").RequestRecord} RequestRecord */ |
| | | |
| | | /** |
| | | * Defines the shared type used by this module. |
| | | * @template T |
| | | * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> |
| | | */ |
| | | |
| | | /** |
| | | * Accessor to object access. |
| | | * @param {string[]} accessor the accessor to convert to path |
| | | * @returns {string} the path |
| | | */ |
| | |
| | | /** @typedef {string | string[]} Accessor */ |
| | | |
| | | /** |
| | | * Returns the path. |
| | | * @param {string|undefined} base the path prefix |
| | | * @param {Accessor} accessor the accessor |
| | | * @param {string=} joinWith the element separator |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Defines the umd library plugin options type used by this module. |
| | | * @typedef {object} UmdLibraryPluginOptions |
| | | * @property {LibraryType} type |
| | | * @property {boolean=} optionalAmdExternalAsGlobal |
| | | */ |
| | | |
| | | /** |
| | | * Defines the umd library plugin parsed type used by this module. |
| | | * @typedef {object} UmdLibraryPluginParsed |
| | | * @property {string | string[] | undefined} name |
| | | * @property {LibraryCustomUmdObject} names |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Represents the umd library plugin runtime component. |
| | | * @typedef {UmdLibraryPluginParsed} T |
| | | * @extends {AbstractLibraryPlugin<UmdLibraryPluginParsed>} |
| | | */ |
| | | class UmdLibraryPlugin extends AbstractLibraryPlugin { |
| | | /** |
| | | * Creates an instance of UmdLibraryPlugin. |
| | | * @param {UmdLibraryPluginOptions} options the plugin option |
| | | */ |
| | | constructor(options) { |
| | |
| | | type: options.type |
| | | }); |
| | | |
| | | /** @type {UmdLibraryPluginOptions["optionalAmdExternalAsGlobal"]} */ |
| | | this.optionalAmdExternalAsGlobal = options.optionalAmdExternalAsGlobal; |
| | | } |
| | | |
| | | /** |
| | | * Returns preprocess as needed by overriding. |
| | | * @param {LibraryOptions} library normalized library option |
| | | * @returns {T | false} preprocess as needed by overriding |
| | | * @returns {T} preprocess as needed by overriding |
| | | */ |
| | | parseOptions(library) { |
| | | /** @type {LibraryName | undefined} */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns source with library export. |
| | | * @param {Source} source source |
| | | * @param {RenderContext} renderContext render context |
| | | * @param {LibraryContext<T>} libraryContext context |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the replaced keys. |
| | | * @param {string} str the string to replace |
| | | * @returns {string} the replaced keys |
| | | */ |
| | |
| | | }); |
| | | |
| | | /** |
| | | * Externals deps array. |
| | | * @param {ExternalModule[]} modules external modules |
| | | * @returns {string} result |
| | | */ |
| | |
| | | )}]`; |
| | | |
| | | /** |
| | | * Externals root array. |
| | | * @param {ExternalModule[]} modules external modules |
| | | * @returns {string} result |
| | | */ |
| | |
| | | ); |
| | | |
| | | /** |
| | | * Externals require array. |
| | | * @param {string} type the type |
| | | * @returns {string} external require array |
| | | */ |
| | |
| | | replaceKeys( |
| | | externals |
| | | .map((m) => { |
| | | let expr; |
| | | let request = m.request; |
| | | if (typeof request === "object") { |
| | | request = |
| | |
| | | `Missing external configuration for type:${type}` |
| | | ); |
| | | } |
| | | expr = Array.isArray(request) |
| | | let expr = Array.isArray(request) |
| | | ? `require(${JSON.stringify( |
| | | request[0] |
| | | )})${accessorToObjectAccess(request.slice(1))}` |
| | |
| | | ); |
| | | |
| | | /** |
| | | * Externals arguments. |
| | | * @param {ExternalModule[]} modules external modules |
| | | * @returns {string} arguments |
| | | */ |
| | |
| | | .join(", "); |
| | | |
| | | /** |
| | | * Returns stringified library name. |
| | | * @param {Accessor} library library name |
| | | * @returns {string} stringified library name |
| | | */ |
| | |
| | | ) |
| | | ); |
| | | |
| | | /** @type {string} */ |
| | | let amdFactory; |
| | | if (optionalExternals.length > 0) { |
| | | const wrapperArguments = externalsArguments(requiredExternals); |
| | |
| | | const { auxiliaryComment, namedDefine, names } = options; |
| | | |
| | | /** |
| | | * Gets auxiliary comment. |
| | | * @param {keyof LibraryCustomUmdCommentObject} type type |
| | | * @returns {string} comment |
| | | */ |