统计数据:从webpack导入的模块告诉项目导入的模块

时间:2019-05-30 12:53:37

标签: webpack webpack-4

Webpack的stats data提供了一个module属性,其中列出了在捆绑阶段处理的所有模块。

其中还列出了运行捆绑应用程序所需的webpack自动包含的运行时程序包(请参见下面的JSON)。就我而言,我可以看到:

  • node_modules/path-browserify/index.js
  • node_modules/process/browser.js

是否可以通过Webpack自动包含的告诉源代码导入的模块(包括依赖项的依赖项)?

我的统计数据:

[
  {
    "id": 0,
    "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
    "name": "./node_modules/minimatch/minimatch.js",
    "index": 4,
    "index2": 8,
    "size": 25347,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
    "issuerId": null,
    "issuerName": "./__fixtures__/entry.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 6,
        "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js 3954829b1d93e7eb46392fa7a3f56e0c",
        "module": "./__fixtures__/entry.js + 3 modules",
        "moduleName": "./__fixtures__/entry.js + 3 modules",
        "type": "harmony side effect evaluation",
        "userRequest": "minimatch",
        "loc": "3:0-34"
      }
    ],
    "usedExports": false,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 1,
    "source": "..."
  },
  {
    "id": 1,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/path-browserify/index.js",
    "name": "./node_modules/path-browserify/index.js",
    "index": 5,
    "index2": 4,
    "size": 6162,
    "cacheable": true,
    "built": true,
    "optional": true,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
    "issuerId": 0,
    "issuerName": "./node_modules/minimatch/minimatch.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      },
      {
        "id": 0,
        "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "name": "./node_modules/minimatch/minimatch.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 0,
        "moduleIdentifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "module": "./node_modules/minimatch/minimatch.js",
        "moduleName": "./node_modules/minimatch/minimatch.js",
        "type": "cjs require",
        "userRequest": "path",
        "loc": "6:9-24"
      }
    ],
    "usedExports": true,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 2,
    "source": "..."
  },
  {
    "id": 2,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/process/browser.js",
    "name": "./node_modules/process/browser.js",
    "index": 6,
    "index2": 3,
    "size": 5081,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/path-browserify/index.js",
    "issuerId": 1,
    "issuerName": "./node_modules/path-browserify/index.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      },
      {
        "id": 0,
        "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "name": "./node_modules/minimatch/minimatch.js"
      },
      {
        "id": 1,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/path-browserify/index.js",
        "name": "./node_modules/path-browserify/index.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 1,
        "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/path-browserify/index.js",
        "module": "./node_modules/path-browserify/index.js",
        "moduleName": "./node_modules/path-browserify/index.js",
        "type": "cjs require",
        "userRequest": "process",
        "loc": "1:0-34"
      }
    ],
    "usedExports": true,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 3,
    "source": "..."
  },
  {
    "id": 3,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
    "name": "./node_modules/brace-expansion/index.js",
    "index": 7,
    "index2": 7,
    "size": 4606,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
    "issuerId": 0,
    "issuerName": "./node_modules/minimatch/minimatch.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      },
      {
        "id": 0,
        "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "name": "./node_modules/minimatch/minimatch.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 0,
        "moduleIdentifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "module": "./node_modules/minimatch/minimatch.js",
        "moduleName": "./node_modules/minimatch/minimatch.js",
        "type": "cjs require",
        "userRequest": "brace-expansion",
        "loc": "10:13-39"
      }
    ],
    "usedExports": true,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 2,
    "source": "..."
  },
  {
    "id": 4,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/concat-map/index.js",
    "name": "./node_modules/concat-map/index.js",
    "index": 8,
    "index2": 5,
    "size": 319,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
    "issuerId": 3,
    "issuerName": "./node_modules/brace-expansion/index.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      },
      {
        "id": 0,
        "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "name": "./node_modules/minimatch/minimatch.js"
      },
      {
        "id": 3,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
        "name": "./node_modules/brace-expansion/index.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 3,
        "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
        "module": "./node_modules/brace-expansion/index.js",
        "moduleName": "./node_modules/brace-expansion/index.js",
        "type": "cjs require",
        "userRequest": "concat-map",
        "loc": "1:16-37"
      }
    ],
    "usedExports": true,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 3,
    "source": "..."
  },
  {
    "id": 5,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/balanced-match/index.js",
    "name": "./node_modules/balanced-match/index.js",
    "index": 9,
    "index2": 6,
    "size": 1171,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
    "issuerId": 3,
    "issuerName": "./node_modules/brace-expansion/index.js",
    "issuerPath": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js"
      },
      {
        "id": 0,
        "identifier": "<path-to-your-directory>node_modules/minimatch/minimatch.js",
        "name": "./node_modules/minimatch/minimatch.js"
      },
      {
        "id": 3,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
        "name": "./node_modules/brace-expansion/index.js"
      }
    ],
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": 3,
        "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>node_modules/brace-expansion/index.js",
        "module": "./node_modules/brace-expansion/index.js",
        "moduleName": "./node_modules/brace-expansion/index.js",
        "type": "cjs require",
        "userRequest": "balanced-match",
        "loc": "3:15-40"
      }
    ],
    "usedExports": true,
    "providedExports": null,
    "optimizationBailout": [
      "ModuleConcatenation bailout: Module is not an ECMAScript module"
    ],
    "depth": 3,
    "source": "..."
  },
  {
    "id": 6,
    "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js 3954829b1d93e7eb46392fa7a3f56e0c",
    "name": "./__fixtures__/entry.js + 3 modules",
    "index": 0,
    "index2": 9,
    "size": 2132,
    "cacheable": true,
    "built": true,
    "optional": false,
    "prefetched": false,
    "chunks": [0],
    "issuer": null,
    "issuerId": null,
    "issuerName": null,
    "issuerPath": null,
    "failed": false,
    "errors": 0,
    "warnings": 0,
    "assets": [],
    "reasons": [
      {
        "moduleId": null,
        "moduleIdentifier": null,
        "module": null,
        "moduleName": null,
        "type": "single entry",
        "userRequest": "<path-to-your-directory>__fixtures__/entry.js",
        "loc": "main"
      }
    ],
    "usedExports": true,
    "providedExports": [],
    "optimizationBailout": [],
    "depth": 0,
    "modules": [
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "name": "./__fixtures__/entry.js",
        "index": 0,
        "index2": 9,
        "size": 94,
        "cacheable": true,
        "built": true,
        "optional": false,
        "prefetched": false,
        "chunks": [],
        "issuer": null,
        "issuerId": null,
        "issuerName": null,
        "issuerPath": null,
        "failed": false,
        "errors": 0,
        "warnings": 0,
        "assets": [],
        "reasons": [
          {
            "moduleId": null,
            "moduleIdentifier": null,
            "module": null,
            "moduleName": null,
            "type": "single entry",
            "userRequest": "<path-to-your-directory>__fixtures__/entry.js",
            "loc": "main"
          }
        ],
        "usedExports": true,
        "providedExports": [],
        "optimizationBailout": [
          "ModuleConcatenation bailout: Module is an entry point"
        ],
        "depth": 0,
    "source": "..."
      },
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-1.js",
        "name": "./__fixtures__/file-1.js",
        "index": 1,
        "index2": 0,
        "size": 978,
        "cacheable": true,
        "built": true,
        "optional": false,
        "prefetched": false,
        "chunks": [],
        "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "issuerId": null,
        "issuerName": "./__fixtures__/entry.js",
        "issuerPath": [
          {
            "id": null,
            "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
            "name": "./__fixtures__/entry.js"
          }
        ],
        "failed": false,
        "errors": 0,
        "warnings": 0,
        "assets": [],
        "reasons": [
          {
            "moduleId": null,
            "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
            "module": "./__fixtures__/entry.js",
            "moduleName": "./__fixtures__/entry.js",
            "type": "harmony side effect evaluation",
            "userRequest": "./file-1",
            "loc": "1:0-29"
          }
        ],
        "usedExports": false,
        "providedExports": ["default"],
        "optimizationBailout": [],
        "depth": 1,
    "source": "..."
      },
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-2.js",
        "name": "./__fixtures__/file-2.js",
        "index": 2,
        "index2": 2,
        "size": 1009,
        "cacheable": true,
        "built": true,
        "optional": false,
        "prefetched": false,
        "chunks": [],
        "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
        "issuerId": null,
        "issuerName": "./__fixtures__/entry.js",
        "issuerPath": [
          {
            "id": null,
            "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
            "name": "./__fixtures__/entry.js"
          }
        ],
        "failed": false,
        "errors": 0,
        "warnings": 0,
        "assets": [],
        "reasons": [
          {
            "moduleId": null,
            "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
            "module": "./__fixtures__/entry.js",
            "moduleName": "./__fixtures__/entry.js",
            "type": "harmony side effect evaluation",
            "userRequest": "./file-2",
            "loc": "2:0-29"
          }
        ],
        "usedExports": false,
        "providedExports": ["default"],
        "optimizationBailout": [],
        "depth": 1,
    "source": "..."
      },
      {
        "id": null,
        "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-3.jsx",
        "name": "./__fixtures__/file-3.jsx",
        "index": 3,
        "index2": 1,
        "size": 46,
        "cacheable": true,
        "built": true,
        "optional": false,
        "prefetched": false,
        "chunks": [],
        "issuer": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-2.js",
        "issuerId": null,
        "issuerName": "./__fixtures__/file-2.js",
        "issuerPath": [
          {
            "id": null,
            "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/entry.js",
            "name": "./__fixtures__/entry.js"
          },
          {
            "id": null,
            "identifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-2.js",
            "name": "./__fixtures__/file-2.js"
          }
        ],
        "failed": false,
        "errors": 0,
        "warnings": 0,
        "assets": [],
        "reasons": [
          {
            "moduleId": null,
            "moduleIdentifier": "<path-to-your-directory>node_modules/babel-loader/lib/index.js??ref--5!<path-to-your-directory>__fixtures__/file-2.js",
            "module": "./__fixtures__/file-2.js",
            "moduleName": "./__fixtures__/file-2.js",
            "type": "harmony side effect evaluation",
            "userRequest": "./file-3",
            "loc": "7:0-29"
          }
        ],
        "usedExports": false,
        "providedExports": ["default"],
        "optimizationBailout": [],
        "depth": 2,
    "source": "..."
      }
    ],
    "filteredModules": 0
  }
]

0 个答案:

没有答案