diff --git a/packages/bundle-parser/README.md b/packages/bundle-parser/README.md new file mode 100644 index 00000000..05a1a484 --- /dev/null +++ b/packages/bundle-parser/README.md @@ -0,0 +1 @@ +Maps bundled output files to the modules based on the given webpack stats object. diff --git a/packages/bundle-parser/package.json b/packages/bundle-parser/package.json new file mode 100644 index 00000000..8c5bfdcc --- /dev/null +++ b/packages/bundle-parser/package.json @@ -0,0 +1,41 @@ +{ + "name": "@webpack-bundle-analyzer/bundle-parser", + "version": "3.0.0-alpha.1", + "description": "Maps webpack bundled output files to the modules based on the given webpack stats object", + "author": "Yury Grunin ", + "contributors": [ + "Yury Grunin ", + "Vesa Laakso (http://vesalaakso.com)" + ], + "license": "MIT", + "homepage": "https://github.com/webpack-contrib/webpack-bundle-analyzer", + "changelog": "https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md", + "bugs": { + "url": "https://github.com/webpack-contrib/webpack-bundle-analyzer/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/webpack-contrib/webpack-bundle-analyzer.git" + }, + "main": "src/index.js", + "engines": { + "node": ">= 4" + }, + "scripts": { + "test": "mocha --compilers js:babel-core/register", + "test-dev": "mocha --watch --compilers js:babel-core/register" + }, + "files": [ + "src" + ], + "dependencies": { + "acorn": "^5.3.0", + "lodash": "^4.17.4" + }, + "devDependencies": {}, + "keywords": [ + "webpack", + "bundle", + "analyzer" + ] +} diff --git a/packages/bundle-parser/src/index.js b/packages/bundle-parser/src/index.js new file mode 100644 index 00000000..aeafe201 --- /dev/null +++ b/packages/bundle-parser/src/index.js @@ -0,0 +1,4 @@ +// TODO: Figure out a proper API +module.exports = { + parseUtils: require('./parseUtils') +}; diff --git a/packages/plugin/src/parseUtils.js b/packages/bundle-parser/src/parseUtils.js similarity index 100% rename from packages/plugin/src/parseUtils.js rename to packages/bundle-parser/src/parseUtils.js diff --git a/packages/bundle-parser/test/.eslintrc.json b/packages/bundle-parser/test/.eslintrc.json new file mode 100644 index 00000000..9f67ce09 --- /dev/null +++ b/packages/bundle-parser/test/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../.eslintrc.json", + "env": { + "mocha": true, + "browser": true + }, + "globals": { + "sinon": true, + "expect": true, + "makeWebpackConfig": true, + "webpackCompile": true + } +} diff --git a/packages/plugin/test/bundles/validBundleWithArrowFunction.js b/packages/bundle-parser/test/bundles/validBundleWithArrowFunction.js similarity index 100% rename from packages/plugin/test/bundles/validBundleWithArrowFunction.js rename to packages/bundle-parser/test/bundles/validBundleWithArrowFunction.js diff --git a/packages/plugin/test/bundles/validBundleWithArrowFunction.modules.json b/packages/bundle-parser/test/bundles/validBundleWithArrowFunction.modules.json similarity index 100% rename from packages/plugin/test/bundles/validBundleWithArrowFunction.modules.json rename to packages/bundle-parser/test/bundles/validBundleWithArrowFunction.modules.json diff --git a/packages/plugin/test/bundles/validBundleWithEsNextFeatures.js b/packages/bundle-parser/test/bundles/validBundleWithEsNextFeatures.js similarity index 100% rename from packages/plugin/test/bundles/validBundleWithEsNextFeatures.js rename to packages/bundle-parser/test/bundles/validBundleWithEsNextFeatures.js diff --git a/packages/plugin/test/bundles/validBundleWithEsNextFeatures.modules.json b/packages/bundle-parser/test/bundles/validBundleWithEsNextFeatures.modules.json similarity index 100% rename from packages/plugin/test/bundles/validBundleWithEsNextFeatures.modules.json rename to packages/bundle-parser/test/bundles/validBundleWithEsNextFeatures.modules.json diff --git a/packages/plugin/test/bundles/validCommonBundleWithDedupePlugin.js b/packages/bundle-parser/test/bundles/validCommonBundleWithDedupePlugin.js similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithDedupePlugin.js rename to packages/bundle-parser/test/bundles/validCommonBundleWithDedupePlugin.js diff --git a/packages/plugin/test/bundles/validCommonBundleWithDedupePlugin.modules.json b/packages/bundle-parser/test/bundles/validCommonBundleWithDedupePlugin.modules.json similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithDedupePlugin.modules.json rename to packages/bundle-parser/test/bundles/validCommonBundleWithDedupePlugin.modules.json diff --git a/packages/plugin/test/bundles/validCommonBundleWithModulesAsArray.js b/packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsArray.js similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithModulesAsArray.js rename to packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsArray.js diff --git a/packages/plugin/test/bundles/validCommonBundleWithModulesAsArray.modules.json b/packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsArray.modules.json similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithModulesAsArray.modules.json rename to packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsArray.modules.json diff --git a/packages/plugin/test/bundles/validCommonBundleWithModulesAsObject.js b/packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsObject.js similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithModulesAsObject.js rename to packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsObject.js diff --git a/packages/plugin/test/bundles/validCommonBundleWithModulesAsObject.modules.json b/packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsObject.modules.json similarity index 100% rename from packages/plugin/test/bundles/validCommonBundleWithModulesAsObject.modules.json rename to packages/bundle-parser/test/bundles/validCommonBundleWithModulesAsObject.modules.json diff --git a/packages/plugin/test/bundles/validExtraBundleWithModulesAsArray.js b/packages/bundle-parser/test/bundles/validExtraBundleWithModulesAsArray.js similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithModulesAsArray.js rename to packages/bundle-parser/test/bundles/validExtraBundleWithModulesAsArray.js diff --git a/packages/plugin/test/bundles/validExtraBundleWithModulesAsArray.modules.json b/packages/bundle-parser/test/bundles/validExtraBundleWithModulesAsArray.modules.json similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithModulesAsArray.modules.json rename to packages/bundle-parser/test/bundles/validExtraBundleWithModulesAsArray.modules.json diff --git a/packages/plugin/test/bundles/validExtraBundleWithModulesInsideArrayConcat.js b/packages/bundle-parser/test/bundles/validExtraBundleWithModulesInsideArrayConcat.js similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithModulesInsideArrayConcat.js rename to packages/bundle-parser/test/bundles/validExtraBundleWithModulesInsideArrayConcat.js diff --git a/packages/plugin/test/bundles/validExtraBundleWithModulesInsideArrayConcat.modules.json b/packages/bundle-parser/test/bundles/validExtraBundleWithModulesInsideArrayConcat.modules.json similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithModulesInsideArrayConcat.modules.json rename to packages/bundle-parser/test/bundles/validExtraBundleWithModulesInsideArrayConcat.modules.json diff --git a/packages/plugin/test/bundles/validExtraBundleWithNamedChunk.js b/packages/bundle-parser/test/bundles/validExtraBundleWithNamedChunk.js similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithNamedChunk.js rename to packages/bundle-parser/test/bundles/validExtraBundleWithNamedChunk.js diff --git a/packages/plugin/test/bundles/validExtraBundleWithNamedChunk.modules.json b/packages/bundle-parser/test/bundles/validExtraBundleWithNamedChunk.modules.json similarity index 100% rename from packages/plugin/test/bundles/validExtraBundleWithNamedChunk.modules.json rename to packages/bundle-parser/test/bundles/validExtraBundleWithNamedChunk.modules.json diff --git a/packages/plugin/test/bundles/validJsonpWithArrayConcatAndEntryPoint.js b/packages/bundle-parser/test/bundles/validJsonpWithArrayConcatAndEntryPoint.js similarity index 100% rename from packages/plugin/test/bundles/validJsonpWithArrayConcatAndEntryPoint.js rename to packages/bundle-parser/test/bundles/validJsonpWithArrayConcatAndEntryPoint.js diff --git a/packages/plugin/test/bundles/validJsonpWithArrayConcatAndEntryPoint.modules.json b/packages/bundle-parser/test/bundles/validJsonpWithArrayConcatAndEntryPoint.modules.json similarity index 100% rename from packages/plugin/test/bundles/validJsonpWithArrayConcatAndEntryPoint.modules.json rename to packages/bundle-parser/test/bundles/validJsonpWithArrayConcatAndEntryPoint.modules.json diff --git a/packages/plugin/test/bundles/validUmdLibraryBundleWithModulesAsArray.js b/packages/bundle-parser/test/bundles/validUmdLibraryBundleWithModulesAsArray.js similarity index 100% rename from packages/plugin/test/bundles/validUmdLibraryBundleWithModulesAsArray.js rename to packages/bundle-parser/test/bundles/validUmdLibraryBundleWithModulesAsArray.js diff --git a/packages/plugin/test/bundles/validUmdLibraryBundleWithModulesAsArray.modules.json b/packages/bundle-parser/test/bundles/validUmdLibraryBundleWithModulesAsArray.modules.json similarity index 100% rename from packages/plugin/test/bundles/validUmdLibraryBundleWithModulesAsArray.modules.json rename to packages/bundle-parser/test/bundles/validUmdLibraryBundleWithModulesAsArray.modules.json diff --git a/packages/plugin/test/parseUtils.js b/packages/bundle-parser/test/parseUtils.js similarity index 89% rename from packages/plugin/test/parseUtils.js rename to packages/bundle-parser/test/parseUtils.js index f6288254..e3297016 100644 --- a/packages/plugin/test/parseUtils.js +++ b/packages/bundle-parser/test/parseUtils.js @@ -1,7 +1,8 @@ +const { expect } = require('chai'); const fs = require('fs'); const _ = require('lodash'); -const { parseBundle } = require('../lib/parseUtils'); +const { parseBundle } = require('../src/parseUtils'); const BUNDLES_DIR = `${__dirname}/bundles`; diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 345a95de..2bff3a33 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -29,8 +29,8 @@ "src" ], "dependencies": { + "@webpack-bundle-analyzer/bundle-parser": "^3.0.0-alpha.1", "@webpack-bundle-analyzer/reporter-treemap": "^3.0.0-alpha.1", - "acorn": "^5.3.0", "bfj-node4": "^5.2.0", "chalk": "^2.3.0", "commander": "^2.13.0", diff --git a/packages/plugin/src/analyzer.js b/packages/plugin/src/analyzer.js index 1872a258..48339cfb 100644 --- a/packages/plugin/src/analyzer.js +++ b/packages/plugin/src/analyzer.js @@ -5,7 +5,7 @@ const _ = require('lodash'); const gzipSize = require('gzip-size'); const { Folder } = require('../lib/tree'); -const { parseBundle } = require('../lib/parseUtils'); +const { parseBundle } = require('@webpack-bundle-analyzer/bundle-parser'); const FILENAME_QUERY_REGEXP = /\?.*$/; const MULTI_MODULE_REGEXP = /^multi /;