<p dir="auto">We need to be able to create a reusable memory module so that memory can be shared across all <code class="notranslate">WASMModule</code>.</p>
<p dir="auto">An example code that would be valid for this use case may look like:</p>
<p dir="auto"><strong>entry.js</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import(“./abc.js”).then(abc =&gt; abc.doIt());"><pre class="notranslate"><span class="pl-k">import</span><span class="pl-kos">(</span><span class="pl-s1">“</span><span class="pl-kos">.</span><span class="pl-c1">/</span><span class="pl-c1">abc</span><span class="pl-kos">.</span><span class="pl-c1">js”</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">abc</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">abc</span><span class="pl-kos">.</span><span class="pl-en">doIt</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>abc.js</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { duplicateText } from “./string.cpp”;
 
export function doIt() {
  console.log(duplicateText(“Hello World”));
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">duplicateText</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s1">“</span><span class="pl-kos">.</span><span class="pl-c1">/</span><span class="pl-s1">string</span><span class="pl-kos">.</span><span class="pl-c1">cpp”</span><span class="pl-kos">;</span>
 
<span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">doIt</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">duplicateText</span><span class="pl-kos">(</span><span class="pl-s1">“Hello</span> <span class="pl-v">World”</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><em>string.cpp</em></p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="extern “C” const char* duplicateText(const char* text) {
  int len = strlen(text);
  char* newstr = new char[len*2 + 1];
  strcpy(newstr, text);
  strcat(newstr, text);
  return newstr;
}"><pre class="notranslate"><span class="pl-k">extern</span> “C” <span class="pl-k">const</span> <span class="pl-k">char</span>* <span class="pl-en">duplicateText</span>(<span class="pl-k">const</span> <span class="pl-k">char</span>* text) {
  <span class="pl-k">int</span> len = <span class="pl-c1">strlen</span>(text);
  <span class="pl-k">char</span>* newstr = <span class="pl-k">new</span> <span class="pl-k">char</span>[len*<span class="pl-c1">2</span> + <span class="pl-c1">1</span>];
  <span class="pl-c1">strcpy</span>(newstr, text);
  <span class="pl-c1">strcat</span>(newstr, text);
  <span class="pl-k">return</span> newstr;
}</pre></div>
<h2 dir="auto">Feature request</h2>





<p dir="auto"><strong>What is the expected behavior?</strong><br>
Webpack use JsonP to load other chunks. wondering whether we can load chunks by requireJs?</p>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong><br>
in my case, i want to share common chunks among different compilations, and assets from different compilations maybe used in the same page. since we use JsonP to load chunks, the output.chunkLoadingGlobal  from certain compilation will be set in common chunk files. so between different compilations , we wont get common chunks  exactly the same, and common share is failed.</p>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong><br>
maybe supply a option that splitChunks can be loaded by AMD, so the splitChunks  dont have to set some logic related to the main chunk. so we can share among compilations</p>
<p dir="auto"><strong>Are you willing to work on this yourself?</strong><br>
sorry，i would like to but maybe not qualified.</p>