diff --git a/package-lock.json b/package-lock.json index 97167c00..68bfafd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7280,11 +7280,6 @@ } } }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" - }, "mobx": { "version": "5.15.7", "resolved": "https://registry.npmjs.org/mobx/-/mobx-5.15.7.tgz", diff --git a/package.json b/package.json index 7877d05a..e9ba8f9c 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "filesize": "^6.1.0", "gzip-size": "^5.1.1", "lodash": "^4.17.20", - "mkdirp": "^1.0.4", "opener": "^1.5.2", "ws": "^7.3.1" }, diff --git a/src/BundleAnalyzerPlugin.js b/src/BundleAnalyzerPlugin.js index e2bc2d34..bc37f1de 100644 --- a/src/BundleAnalyzerPlugin.js +++ b/src/BundleAnalyzerPlugin.js @@ -1,5 +1,5 @@ +const fs = require('fs'); const path = require('path'); -const mkdir = require('mkdirp'); const {bold} = require('chalk'); const Logger = require('./Logger'); @@ -80,7 +80,7 @@ class BundleAnalyzerPlugin { async generateStatsFile(stats) { const statsFilepath = path.resolve(this.compiler.outputPath, this.opts.statsFilename); - mkdir.sync(path.dirname(statsFilepath)); + await fs.promises.mkdir(path.dirname(statsFilepath), {recursive: true}); try { await writeStats(stats, statsFilepath); diff --git a/src/viewer.js b/src/viewer.js index 6cb6d0b3..c259eede 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -6,7 +6,6 @@ const WebSocket = require('ws'); const _ = require('lodash'); const express = require('express'); const ejs = require('ejs'); -const mkdir = require('mkdirp'); const {bold} = require('chalk'); const Logger = require('./Logger'); @@ -163,7 +162,7 @@ async function generateReport(bundleStats, opts) { const reportFilepath = path.resolve(bundleDir || process.cwd(), reportFilename); - mkdir.sync(path.dirname(reportFilepath)); + fs.mkdirSync(path.dirname(reportFilepath), {recursive: true}); fs.writeFileSync(reportFilepath, reportHtml); logger.info(`${bold('Webpack Bundle Analyzer')} saved report to ${bold(reportFilepath)}`); @@ -187,8 +186,8 @@ async function generateJSONReport(bundleStats, opts) { if (!chartData) return; - mkdir.sync(path.dirname(reportFilename)); - fs.writeFileSync(reportFilename, JSON.stringify(chartData)); + await fs.promises.mkdir(path.dirname(reportFilename), {recursive: true}); + await fs.promises.writeFile(reportFilename, JSON.stringify(chartData)); logger.info(`${bold('Webpack Bundle Analyzer')} saved JSON report to ${bold(reportFilename)}`); }