我正在尝试做一些包装用于浏览器的axios功能的功能。我正在使用汇总并尝试使axios成为捆绑包的一部分,但结果甚至与我的预期还不接近:axios是1600行,我的捆绑包是17000,其中包括根本不应该存在的东西,例如流程.stderr。这是我的汇总配置:
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import babel from "rollup-plugin-babel";
import builtins from 'rollup-plugin-node-builtins';
import json from "rollup-plugin-json";
import pkg from "./package.json";
export default {
input: "src/index.js",
output: [
{
name: "axoi",
file: pkg.main,
format: "iife"
}
],
plugins: [
babel(),
nodeResolve({
jsnext: true,
main: true,
module: true
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
browser: true,
preferBuiltins: false,
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false // Default: true
// explicitly specify unresolvable named exports
// (see below for more details)
// namedExports: { './module.js': ['foo', 'bar' ] } // Default: undefined
}),
globals(),
builtins(),
json()
],
experimentalCodeSplitting: true
};