* Returns source with library export. * @param {Source} source source * @param {RenderContext} renderContext render context * @param {LibraryContext<T>} libraryContext context * @returns {Source} source with library export
(source, { chunk }, { options, compilation })
| 238 | * @returns {Source} source with library export |
| 239 | */ |
| 240 | render(source, { chunk }, { options, compilation }) { |
| 241 | const fullNameResolved = this._getResolvedFullName( |
| 242 | options, |
| 243 | chunk, |
| 244 | compilation |
| 245 | ); |
| 246 | if (this.declare) { |
| 247 | const base = fullNameResolved[0]; |
| 248 | if (!isNameValid(base)) { |
| 249 | throw new Error( |
| 250 | `Library name base (${base}) must be a valid identifier when using a var declaring library type. Either use a valid identifier (e. g. ${Template.toIdentifier( |
| 251 | base |
| 252 | )}) or use a different library type (e. g. 'type: "global"', which assign a property on the global scope instead of declaring a variable). ${ |
| 253 | AbstractLibraryPlugin.COMMON_LIBRARY_NAME_MESSAGE |
| 254 | }` |
| 255 | ); |
| 256 | } |
| 257 | source = new ConcatSource(`${this.declare} ${base};\n`, source); |
| 258 | } |
| 259 | return source; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Embed in runtime bailout. |
nothing calls this directly
no test coverage detected