Skip to content

Commit

Permalink
fix: determine webpack peer dependency version (webpack-contrib#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Knagis committed Oct 16, 2020
1 parent a4792a5 commit 678a695
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/index.js
Expand Up @@ -20,27 +20,19 @@ import {
let FetchCompileWasmPlugin;
let FetchCompileAsyncWasmPlugin;

try {
// Webpack 5, sync WASM
// determine the version of webpack peer dependency
// eslint-disable-next-line global-require, import/no-unresolved
const useWebpack5 = require('webpack/package.json').version.startsWith('5.');

if (useWebpack5) {
// eslint-disable-next-line global-require, import/no-unresolved
FetchCompileWasmPlugin = require('webpack/lib/web/FetchCompileWasmPlugin');
} catch (ignoreError) {
// Nothing
}

try {
// Webpack 5, async WASM
// eslint-disable-next-line global-require, import/no-unresolved
FetchCompileAsyncWasmPlugin = require('webpack/lib/web/FetchCompileAsyncWasmPlugin');
} catch (ignoreError) {
// Nothing
}

// Webpack 4
FetchCompileWasmPlugin =
FetchCompileWasmPlugin ||
} else {
// eslint-disable-next-line global-require, import/no-unresolved
require('webpack/lib/web/FetchCompileWasmTemplatePlugin');
FetchCompileWasmPlugin = require('webpack/lib/web/FetchCompileWasmTemplatePlugin');
}

export default function loader() {}

Expand Down

0 comments on commit 678a695

Please sign in to comment.