JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 271 forks source link

Webpack 5 with svg-sprite-loader@6.0.0 compilation error #444

Closed shorielov closed 3 years ago

shorielov commented 3 years ago

When I try to build a project I got an error: "TypeError: Cannot read property 'tap' of undefined" Webpack version is 5.26.0

TypeError: Cannot read property 'tap' of undefined at /node_modules/svg-sprite-loader/lib/plugin.js:82:14 at Hook.eval [as call] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:13:1) at Hook.CALL_DELEGATE [as _call] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14) at Compiler.newCompilation (/node_modules/webpack/lib/Compiler.js:1014:30) at /node_modules/webpack/lib/Compiler.js:1057:29 at Hook.eval [as callAsync] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14) at Compiler.compile (/node_modules/webpack/lib/Compiler.js:1052:28) at /node_modules/webpack/lib/Compiler.js:494:12 at Compiler.readRecords (/node_modules/webpack/lib/Compiler.js:892:11) at /node_modules/webpack/lib/Compiler.js:491:11 at Hook.eval [as callAsync] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14) at /node_modules/webpack/lib/Compiler.js:488:20 at Hook.eval [as callAsync] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14) at run (/node_modules/webpack/lib/Compiler.js:485:25)

joseareland commented 3 years ago

This one happens when using extract: true and the SpriteLoaderPlugin. .tap is an utility method in the bluebird JS library.

dmnsgn commented 3 years ago

Seems to be actually due to a missing compilation hook here: https://github.com/JetBrains/svg-sprite-loader/blob/89cfdd518c4665e85b0e6c1ababd3c9809dcfd75/lib/plugin.js#L80-L82

Removed in webpack 5: https://github.com/webpack/changelog-v5#other-minor-changes

shorielov commented 3 years ago

@dmnsgn Yes. And I can't create a build with svg-sprite-loader@5.2.1 and webpack@5.26.0

Module.issuerThere was no ModuleGraph assigned to the Module for backward-compat (Use the new API) at /node_modules/webpack/lib/ModuleGraph.js:720:12 at deprecated (internal/util.js:89:15) at Function.getModuleGraphForModule (/node_modules/webpack/lib/ModuleGraph.js:711:18) at NormalModule.get issuer [as issuer] (/node_modules/webpack/lib/Module.js:278:22) at isModuleShouldBeExtracted (/node_modules/svg-sprite-loader/lib/utils/is-module-should-be-extracted.js:11:20) at Array.filter () at new MappedList (/node_modules/svg-sprite-loader/lib/utils/mapped-list.js:42:42) at SVGSpritePlugin.afterOptimizeChunks (/node_modules/svg-sprite-loader/lib/plugin.js:179:16) at /node_modules/svg-sprite-loader/lib/plugin.js:79:40 at Hook.eval [as call] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1) at Hook.CALL_DELEGATE [as _call] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14) at Compilation.seal (/node_modules/webpack/lib/Compilation.js:2295:34) at /node_modules/webpack/lib/Compiler.js:1078:20 at /node_modules/webpack/lib/Compilation.js:2116:4 at _next2 (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :25:1) at eval (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :52:1) at /node_modules/webpack/lib/FlagDependencyExportsPlugin.js:343:11 at /node_modules/neo-async/async.js:2830:7 at Object.each (/node_modules/neo-async/async.js:2850:39) at /node_modules/webpack/lib/FlagDependencyExportsPlugin.js:322:18 at /node_modules/neo-async/async.js:2830:7 at Object.each (/node_modules/neo-async/async.js:2850:39)

d3x42 commented 3 years ago

Please try svg-sprite-loader@6.0.2

dmnsgn commented 3 years ago

@d3x42 works fine for me 👍

shorielov commented 3 years ago

@d3x42 thank you so much for fix, but I still reproduce the error

webpack: 5.26.0

/node_modules/webpack/lib/ModuleGraph.js:720 throw new Error( ^

Error: Module.issuerThere was no ModuleGraph assigned to the Module for backward-compat (Use the new API) at /node_modules/webpack/lib/ModuleGraph.js:720:12 at deprecated (internal/util.js:89:15) at Function.getModuleGraphForModule (/node_modules/webpack/lib/ModuleGraph.js:711:18) at NormalModule.get issuer [as issuer] (/node_modules/webpack/lib/Module.js:278:22) at isModuleShouldBeExtracted (/node_modules/svg-sprite-loader/lib/utils/is-module-should-be-extracted.js:11:20) at Array.filter () at new MappedList (/node_modules/svg-sprite-loader/lib/utils/mapped-list.js:42:42) at SVGSpritePlugin.afterOptimizeChunks (/node_modules/svg-sprite-loader/lib/plugin.js:181:16) at /node_modules/svg-sprite-loader/lib/plugin.js:78:40 at Hook.eval [as call] (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1) at Hook.CALL_DELEGATE [as _call] (/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14) at Compilation.seal (/node_modules/webpack/lib/Compilation.js:2295:34) at /node_modules/webpack/lib/Compiler.js:1078:20 at /node_modules/webpack/lib/Compilation.js:2116:4 at _next2 (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :25:1) at eval (eval at create (/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), :52:1) at /node_modules/webpack/lib/FlagDependencyExportsPlugin.js:343:11 at /node_modules/neo-async/async.js:2830:7 at Object.each (/node_modules/neo-async/async.js:2850:39) at /node_modules/webpack/lib/FlagDependencyExportsPlugin.js:322:18 at /node_modules/neo-async/async.js:2830:7 at Object.each (/node_modules/neo-async/async.js:2850:39)

d3x42 commented 3 years ago

@shorielov Could you please share GitHub project with a reproduced issue or your config? It seems to be another issue.

shorielov commented 3 years ago

@d3x42 I think it's the same issue https://github.com/JeffreyWay/laravel-mix/issues/2767

You should use the new Module API for getting the issuer.

dmnsgn commented 3 years ago

Related to this issue, I am still getting "Use new ChunkGraph API" though: https://github.com/JetBrains/svg-sprite-loader/issues/432 (a deprecation warning)

iuscare commented 3 years ago

Getting the same error as shorielov on 6.0.2. Webpack verison is ^5.13.0

Error: Module.issuerThere was no ModuleGraph assigned to the Module for backward-compat (Use the new API)
    at /var/www/project/buildchain/node_modules/webpack/lib/ModuleGraph.js:720:12
    at deprecated (internal/util.js:89:15)
    at Function.getModuleGraphForModule (/var/www/project/buildchain/node_modules/webpack/lib/ModuleGraph.js:711:18)
    at NormalModule.get issuer [as issuer] (/var/www/project/buildchain/node_modules/webpack/lib/Module.js:278:22)
    at isModuleShouldBeExtracted (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/utils/is-module-should-be-extracted.js:11:20)
    at Array.filter (<anonymous>)
    at new MappedList (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/utils/mapped-list.js:42:42)
    at SVGSpritePlugin.afterOptimizeChunks (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/plugin.js:181:16)
    at /var/www/project/buildchain/node_modules/svg-sprite-loader/lib/plugin.js:78:40
    at Hook.eval [as call] (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:12:1)
    at Hook.CALL_DELEGATE [as _call] (/var/www/project/buildchain/node_modules/tapable/lib/Hook.js:14:14)
    at Compilation.seal (/var/www/project/buildchain/node_modules/webpack/lib/Compilation.js:2295:34)
    at /var/www/project/buildchain/node_modules/webpack/lib/Compiler.js:1078:20
    at /var/www/project/buildchain/node_modules/webpack/lib/Compilation.js:2116:4
    at _next2 (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:35:1)
    at eval (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:71:1)
npm ERR! code ELIFECYCLE
npm ERR! errno 7

EDIT: This only happens when setting extract to true. Right before the stacktrace begins, I get:

69% building finish(node:3609) DeprecationWarning: Hook.context is deprecated and will be removed
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3609) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader
95% emitting emit(node:3609) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
64% building 58/59 entries 175/175 dependencies 62/118 modules(node:3609) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
76% sealing after chunk optimization /var/www/project/buildchain/node_modules/svg-sprite-loader/lib/var/www/project/buildchain/node_modules/@gfx/zopfli/dist/libzopfli.js:1
(function (exports, require, module, __filename, __dirname) { "use strict";var Module=typeof Module!=="undefined"?Module:{};const base64=require("base64-js");const base64EncodedBinary=require("./libzopfli-wasm");var Module={};Module.noInitialRun=true;Module.wasmBinary=base64.toByteArray(base64EncodedBinary);var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=function shell_read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){return read(f)}}readBinary=function readBinary(f){var data;if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=Number(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(typeof WebAssembly!=="object"){err("no native wasm support detected")}function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":8,"maximum":8+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var ALLOC_NORMAL=0;var ALLOC_NONE=3;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[_malloc,stackAlloc,dynamicAlloc][allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr<stop;ptr+=4){HEAP32[ptr>>2]=0}stop=ret+size;while(ptr<stop){HEAP8[ptr++>>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i<size){var curr=slab[i];type=singleType||types[i];if(type===0){i++;continue}if(type=="i64")type="i32";setValue(ret+i,curr,type);if(previousType!==type){typeSize=getNativeTypeSize(type);previousType=type}i+=typeSize}return ret}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx<endPtr){var u0=heap[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heap[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heap[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heap[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var DYNAMIC_BASE=5253664,DYNAMICTOP_PTR=10624;var INITIAL_INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_INITIAL_MEMORY/WASM_PAGE_SIZE,"maximum":2147483648/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_INITIAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";out(what);err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";throw new WebAssembly.RuntimeError(what)}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var wasmBinaryFile="libzopfli.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function _emscripten_get_heap_size(){return HEAPU8.length}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=_emscripten_get_heap_size();var PAGE_MULTIPLE=65536;var maxHeapSize=2147483648;if(requestedSize>maxHeapSize){return false}var minHeapSize=16777216;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(minHeapSize,requestedSize,overGrownHeapSize),PAGE_MULTIPLE));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _exit(status){exit(status)}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function _fd_close(fd){return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAP32[iov+i*8>>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j<len;j++){SYSCALLS.printChar(fd,HEAPU8[ptr+j])}num+=len}HEAP32[pnum>>2]=num;return 0}function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"d":_emscripten_memcpy_big,"e":_emscripten_resize_heap,"a":_exit,"f":_fd_close,"c":_fd_seek,"b":_fd_write,"memory":wasmMemory,"table":wasmTable};var asm=createWasm();Module["asm"]=asm;var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["g"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["h"]).apply(null,arguments)};var _deallocate=Module["_deallocate"]=function(){return(_deallocate=Module["_deallocate"]=Module["asm"]["i"]).apply(null,arguments)};var _createZopfliJsOutput=Module["_createZopfliJsOutput"]=function(){return(_createZopfliJsOutput=Module["_createZopfliJsOutput"]=Module["asm"]["j"]).apply(null,arguments)};var _getBuffer=Module["_getBuffer"]=function(){return(_getBuffer=Module["_getBuffer"]=Module["asm"]["k"]).apply(null,arguments)};var _getBufferSize=Module["_getBufferSize"]=function(){return(_getBufferSize=Module["_getBufferSize"]=Module["asm"]["l"]).apply(null,arguments)};var _compress=Module["_compress"]=function(){return(_compress=Module["_compress"]=Module["asm"]["m"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["n"]).apply(null,arguments)};Module["asm"]=asm;Module["intArrayFromString"]=intArrayFromString;Module["allocate"]=allocate;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{ABORT=true;EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status)}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}noExitRuntime=true;run();

Below is my sprite-loader-config:

// svg-loader.config.js
// returns a webpack config object for handling svg loading

// node modules
const path = require('path');

// webpack plugins
const SpritePlugin = require('svg-sprite-loader/plugin');

// return a webpack config
// eslint-disable-next-line @typescript-eslint/no-unused-vars
module.exports = (type = 'modern', settings) => {
  // common config
  const common = () => ({
    module: {
      rules: [
        {
          test: /\.(svg)$/,
          use: [
            {
              loader: 'svg-sprite-loader',
              options: {
                publicPath: '/',
                spriteFilename: 'svg/spritemap.svg',
              },
            },
            'svg-transform-loader',
            'svgo-loader',
          ],
        },
      ],
    },
    plugins: [
      new SpritePlugin()
    ],
  });
  // configs
  const configs = {
    // development configs
    development: {
      // legacy development config
      legacy: {},
      // modern development config
      modern: {
        ...common(),
      },
    },
    // production configs
    production: {
      // legacy production config
      legacy: {
        ...common(),
      },
      // modern production config
      modern: {
        ...common(),
      },
    },
  };

  return configs[process.env.NODE_ENV][type];
}
d3x42 commented 3 years ago

Please try svg-sprite-loader@6.0.3

iuscare commented 3 years ago

Thanks for the update. I am afraid, but still no success with the ModuleGraph. Same setup, just updated version generates the following stack trace:

Error: Module.issuerThere was no ModuleGraph assigned to the Module for backward-compat (Use the new API)
    at /var/www/project/buildchain/node_modules/webpack/lib/ModuleGraph.js:720:12
    at deprecated (internal/util.js:89:15)
    at Function.getModuleGraphForModule (/var/www/project/buildchain/node_modules/webpack/lib/ModuleGraph.js:711:18)
    at NormalModule.get issuer [as issuer] (/var/www/project/buildchain/node_modules/webpack/lib/Module.js:278:22)
    at isModuleShouldBeExtracted (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/utils/is-module-should-be-extracted.js:11:20)
    at Array.filter (<anonymous>)
    at new MappedList (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/utils/mapped-list.js:44:42)
    at SVGSpritePlugin.afterOptimizeChunks (/var/www/project/buildchain/node_modules/svg-sprite-loader/lib/plugin.js:188:16)
    at /var/www/project/buildchain/node_modules/svg-sprite-loader/lib/plugin.js:85:40
    at Hook.eval [as call] (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:12:1)
    at Hook.CALL_DELEGATE [as _call] (/var/www/project/buildchain/node_modules/tapable/lib/Hook.js:14:14)
    at Compilation.seal (/var/www/project/buildchain/node_modules/webpack/lib/Compilation.js:2299:34)
    at /var/www/project/buildchain/node_modules/webpack/lib/Compiler.js:1080:20
    at /var/www/project/buildchain/node_modules/webpack/lib/Compilation.js:2120:4
    at _next2 (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:35:1)
    at eval (eval at create (/var/www/project/buildchain/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:71:1)
npm ERR! code ELIFECYCLE
d3x42 commented 3 years ago

@iuscare svg-sprite-loader@6.0.5. It works on test project, I hope it'll solve your issue

iuscare commented 3 years ago

@d3x42 yay! This seems to work. Great! I am going to test it the following days, but at first look it seems that the issue can be closed for me. Thank you so much, I really appreciate your effort.