Skip to content

Commit

Permalink
fix: #151 support Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyi committed Aug 17, 2023
1 parent ceede1d commit 7d9ab05
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/auto-polyfills-webpack-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ class AutoPolyfillsWebpackPlugin {

get coreJsVersion() {
try {
const coreJsPathList = require.resolve('core-js').split('/');
const coreJsPath = require.resolve('core-js');
// Windows’s path separator is \\, MacOS or Linux is /
const splitKey = coreJsPath.includes('/') ? '/' : '\\';
const coreJsPathList = coreJsPath.split(splitKey);
coreJsPathList.pop();
const coreJsPkg = join(coreJsPathList.join('/'), './package.json');
const coreJsPkg = join(coreJsPathList.join(splitKey), './package.json');
return require(coreJsPkg).version;
} catch (ex) {
throw ex;
Expand Down

0 comments on commit 7d9ab05

Please sign in to comment.