bundle-internals
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -0,1 +1,11 @@ | ||
## 1.1.3 (03 March 2020) | ||
* fix crash | ||
## 1.1.2 (18 December 2019) | ||
* fix crash | ||
* internal refactoring | ||
* fixed d.ts | ||
## 1.1.1 (05 August 2019) | ||
@@ -2,0 +12,0 @@ |
{ | ||
"name": "bundle-internals", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "The webpack plugin that collects a debug information about your webpack bundle (e.g. bundled modules, input entry points, and output assets)", | ||
@@ -46,3 +46,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"tapable": "^1.1.3" | ||
"webpack-sources": "^1.4.3" | ||
}, | ||
@@ -52,2 +52,2 @@ "devDependencies": { | ||
} | ||
} | ||
} |
@@ -111,4 +111,10 @@ # Bundle Internals Plugin | ||
This plugin will be used in [Webpack Runtime Analyzer](https://github.com/smelukov/webpack-runtime-analyzer/) V2 But for now, you can load debug data from your bundle to [Jora Sandbox](https://discoveryjs.github.io/jora-sandbox/) and make some interesting queries to it. | ||
This plugin will be used in [Webpack Runtime Analyzer](https://github.com/smelukov/webpack-runtime-analyzer/) V2 | ||
But for now, you can get the raw bundle internal data and analyze it manually. | ||
> It's just a JSON and you may use any tools to analyze and visualize it | ||
For example, you may load it to [Jora Sandbox](https://discoveryjs.github.io/jora-sandbox/) and make some interesting queries to it. | ||
Jora Sandbox is a sandbox for the [Jora](https://github.com/discoveryjs/jora) query engine that allows you to query and aggregate any data from JSON. | ||
@@ -131,3 +137,3 @@ | ||
```json | ||
```js | ||
[ | ||
@@ -149,3 +155,3 @@ { name: "@babel/polyfill", version: ["7.4.4"] }, | ||
``` | ||
input.modules.sort(<reasons.size()>).reverse().id | ||
input.modules.sort(reasons.size() desc).id | ||
``` | ||
@@ -155,3 +161,3 @@ | ||
```json | ||
```js | ||
[ | ||
@@ -158,0 +164,0 @@ "./node_modules/react/index.js", |
const fs = require('fs'); | ||
const path = require('path'); | ||
const NodeOutputFileSystem = require.main.require('webpack/lib/node/NodeOutputFileSystem'); | ||
const RequestShortener = require.main.require('webpack/lib/RequestShortener'); | ||
const NodeOutputFileSystem = require('webpack/lib/node/NodeOutputFileSystem'); | ||
const RequestShortener = require('webpack/lib/RequestShortener'); | ||
const { Tapable, SyncHook } = require("tapable"); | ||
const { RawSource } = require("webpack-sources"); | ||
const { | ||
@@ -36,11 +37,11 @@ getFileHash, | ||
if (this.options.runMode === 'all' || this.options.runMode === 'watch') { | ||
compiler.hooks.watchRun.tapAsync(pluginName, run); | ||
compiler.hooks.watchRun.tap(pluginName, run); | ||
} | ||
if (this.options.runMode === 'all' || this.options.runMode === 'non-watch') { | ||
compiler.hooks.run.tapAsync(pluginName, run); | ||
compiler.hooks.run.tap(pluginName, run); | ||
} | ||
} | ||
run(compiler, done) { | ||
run(compiler) { | ||
const requestShortener = new RequestShortener(compiler.context); | ||
@@ -66,3 +67,3 @@ | ||
compiler.hooks.thisCompilation.tap(pluginName, compilation => { | ||
compilation.hooks.optimizeChunkAssets.tap(pluginName, () => { | ||
compilation.hooks.optimizeAssets.tapAsync(pluginName, async (assets, cb) => { | ||
stats.assets = compilation.chunkGroups.reduce((all, group) => { | ||
@@ -102,5 +103,3 @@ if (!group.isInitial()) { | ||
}, stats.assets); | ||
}); | ||
compiler.hooks.afterEmit.tapAsync(pluginName, async (compilation, done) => { | ||
let outputFileSystem = compilation.compiler.outputFileSystem; | ||
@@ -123,2 +122,3 @@ | ||
let absResourcePath = module.resource; | ||
let resource = module.resource ? path.relative(compiler.context, module.resource) : undefined; | ||
@@ -128,2 +128,3 @@ let extractedFrom; | ||
if (!resource && module.issuer && module.issuer.resource) { | ||
absResourcePath = module.issuer.resource; | ||
resource = path.relative(compiler.context, module.issuer.resource); | ||
@@ -135,3 +136,3 @@ } | ||
if (resource && !stats.input.files.find(({ path }) => path === resource)) { | ||
const fileStat = compiler.inputFileSystem.statSync(resource); | ||
const fileStat = compiler.inputFileSystem.statSync(absResourcePath); | ||
const fileInfo = { | ||
@@ -143,3 +144,3 @@ path: resource, | ||
const [pathToPackageJson] = resource.match(/.*node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\//) || []; | ||
const [pathToPackageJson] = absResourcePath.match(/.*node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\//) || []; | ||
@@ -244,3 +245,3 @@ if (pathToPackageJson) { | ||
if (!size) { | ||
size = compilation.assets[file].size(); | ||
size = assets[file].size(); | ||
} | ||
@@ -310,4 +311,6 @@ | ||
if (this.options.saveTo) { | ||
fs.writeFileSync(path.resolve(compiler.options.output.path, this.options.saveTo), JSON.stringify(data)); | ||
const { saveTo } = this.options; | ||
if (saveTo) { | ||
assets[saveTo] = new RawSource(JSON.stringify(data)); | ||
} | ||
@@ -317,7 +320,5 @@ | ||
done(); | ||
cb(); | ||
}); | ||
}); | ||
done(); | ||
} | ||
@@ -324,0 +325,0 @@ |
@@ -45,3 +45,3 @@ export type Info = { | ||
*/ | ||
initial: { [string]: string[] }, | ||
initial: { [key: string]: string[] }, | ||
/** | ||
@@ -51,3 +51,3 @@ * Dynamic imports chunks | ||
*/ | ||
dynamic: { [string]: string[] }, | ||
dynamic: { [key: string]: string[] }, | ||
} | ||
@@ -71,3 +71,3 @@ | ||
*/ | ||
nodeModules: { [string]: string[] } | ||
nodeModules: { [key: string]: string[] } | ||
} | ||
@@ -183,3 +183,3 @@ | ||
*/ | ||
extracted: string?, | ||
extracted?: string, | ||
/** | ||
@@ -228,3 +228,3 @@ * List of reasons that leads to webpack deoptimization | ||
*/ | ||
source: (string | number)?, | ||
source?: string | number, | ||
type: string, | ||
@@ -240,2 +240,2 @@ message: string | ||
unknown = "unknown" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33530
761
168
+ Addedwebpack-sources@^1.4.3
+ Addedsource-list-map@2.0.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedwebpack-sources@1.4.3(transitive)
- Removedtapable@^1.1.3
- Removedtapable@1.1.3(transitive)