12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- "use strict";
- const { ConcatSource } = require("webpack-sources");
- const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
- class JsonpLibraryPlugin extends AbstractLibraryPlugin {
-
- constructor(options) {
- super({
- pluginName: "JsonpLibraryPlugin",
- type: options.type
- });
- }
-
- parseOptions(library) {
- const { name } = library;
- if (typeof name !== "string") {
- throw new Error(
- `Jsonp library name must be a simple string. ${AbstractLibraryPlugin.COMMON_LIBRARY_NAME_MESSAGE}`
- );
- }
- return {
- name: (name)
- };
- }
-
- render(source, { chunk }, { options, compilation }) {
- const name = compilation.getPath(options.name, {
- chunk
- });
- return new ConcatSource(`${name}(`, source, ")");
- }
-
- chunkHash(chunk, hash, chunkHashContext, { options, compilation }) {
- hash.update("JsonpLibraryPlugin");
- hash.update(compilation.getPath(options.name, { chunk }));
- }
- }
- module.exports = JsonpLibraryPlugin;
|