This repository was archived by the owner on Sep 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -20,27 +20,19 @@ import {
20
20
let FetchCompileWasmPlugin ;
21
21
let FetchCompileAsyncWasmPlugin ;
22
22
23
- try {
24
- // Webpack 5, sync WASM
23
+ // determine the version of webpack peer dependency
24
+ // eslint-disable-next-line global-require, import/no-unresolved
25
+ const useWebpack5 = require ( 'webpack/package.json' ) . version . startsWith ( '5.' ) ;
26
+
27
+ if ( useWebpack5 ) {
25
28
// eslint-disable-next-line global-require, import/no-unresolved
26
29
FetchCompileWasmPlugin = require ( 'webpack/lib/web/FetchCompileWasmPlugin' ) ;
27
- } catch ( ignoreError ) {
28
- // Nothing
29
- }
30
-
31
- try {
32
- // Webpack 5, async WASM
33
30
// eslint-disable-next-line global-require, import/no-unresolved
34
31
FetchCompileAsyncWasmPlugin = require ( 'webpack/lib/web/FetchCompileAsyncWasmPlugin' ) ;
35
- } catch ( ignoreError ) {
36
- // Nothing
37
- }
38
-
39
- // Webpack 4
40
- FetchCompileWasmPlugin =
41
- FetchCompileWasmPlugin ||
32
+ } else {
42
33
// eslint-disable-next-line global-require, import/no-unresolved
43
- require ( 'webpack/lib/web/FetchCompileWasmTemplatePlugin' ) ;
34
+ FetchCompileWasmPlugin = require ( 'webpack/lib/web/FetchCompileWasmTemplatePlugin' ) ;
35
+ }
44
36
45
37
export default function loader ( ) { }
46
38
You can’t perform that action at this time.
0 commit comments