jsonpscriptsrc-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

name type Default
customJsonpSrc {Function} -
compilerOptions {Object} {jsc:{target:'es5'}}

customJsonpSrc

name type description
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.

Package Sidebar

Install

npm i jsonpscriptsrc-webpack-plugin

Weekly Downloads

560

Version

1.0.0

License

MIT

Unpacked Size

5.89 kB

Total Files

4

Last publish

Collaborators

  • a_sleepwalker