1.0.0 • Published 2 years ago

jsonpscriptsrc-webpack-plugin v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

jsonpscriptsrc-webpack-plugin


Note: only support webpack 4.x

Override webpack runtime jsonpscriptsrc function.

install

yarn add -dev jsonpscriptsrc-webpack-plugin

usage

webpack.config.js

const {JsonpScriptSrcPlugin} = require('jsonpscriptsrc-webpack-plugin')

module.exports = {
  ...
  plugins:[
    new JsonpScriptSrcPlugin({
      customJsonpSrc(chunkId, chunkMaps, original) {
        // code
        // return your runtime src here
      }
    })
  ]
}

options

nametypeDefault
customJsonpSrc{Function}-
compilerOptions{Object}{jsc:{target:'es5'}}

customJsonpSrc

nametypedescription
chunkId{String}The parameters of the original jsonpScriptsrc function .
chunkMaps{Object}An object contains all the async chunks generated by webpack.
original{String}The return value of the original jsonpScriptsrc function.

Only supports the first way of writing options.customJsonpSrc

// #1
{
	customJsonpSrc(chunkId, chunkMaps, original) {}
}
// #2
{
	customJsonpSrc: (chunkId, chunkMaps, original) => {}
}
// #3
{
	customJsonpSrc: function(chunkId, chunkMaps, original) {}
}

compilerOptions

This plugin use swc transform customJsonpSrc function body content to es5. compilerOptions is the args of transform function.