Skip to content

Commit

Permalink
fix(utils): use webpack object version if package can't be required
Browse files Browse the repository at this point in the history
fix(utils): use webpack object version if package can't be required
  • Loading branch information
LuudJanssen authored Apr 23, 2021
1 parent 4a3d105 commit f4b82c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/utils/is-webpack-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const webpackPkg = require('webpack/package.json');
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved, global-require
const webpackPkg = require('webpack/package.json') || {};
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved, global-require
const webpackVersion = webpackPkg.version || require('webpack').version;

const webpackMajorVersion = parseInt(webpackPkg.version.split('.')[0], 10);
const webpackMajorVersion = parseInt(webpackVersion.split('.')[0], 10);

module.exports = webpackMajorVersion === 1;

0 comments on commit f4b82c2

Please sign in to comment.