Reproduce bug

This commit is contained in:
Akim Mamedov 2023-12-16 01:24:54 +07:00
parent 9b629eef2e
commit bb4ae8e82d
2 changed files with 22 additions and 29 deletions

View File

@ -27,21 +27,29 @@ type StrategyReturnType = [
export const loadMarineDeps = async (
CDNUrl: string,
): Promise<StrategyReturnType> => {
const [marineJsWasm, avmWasm] = await Promise.all([
fetchResource(
"@fluencelabs/marine-js",
"/dist/marine-js.wasm",
CDNUrl,
).then((res) => {
return res.arrayBuffer();
}),
fetchResource("@fluencelabs/avm", "/dist/avm.wasm", CDNUrl).then((res) => {
return res.arrayBuffer();
}),
]);
const timeout = new Promise((resolve) => {
setTimeout(resolve, 500);
});
// TODO: load worker in parallel with avm and marine, test that it works
const worker = await getWorker("@fluencelabs/marine-worker", CDNUrl);
const [marineJsWasm, avmWasm, worker] = await Promise.all([
timeout.then(() => {
return fetchResource(
"@fluencelabs/marine-js",
"/dist/marine-js.wasm",
CDNUrl,
).then((res) => {
return res.arrayBuffer();
});
}),
timeout.then(() => {
return fetchResource("@fluencelabs/avm", "/dist/avm.wasm", CDNUrl).then(
(res) => {
return res.arrayBuffer();
},
);
}),
getWorker("@fluencelabs/marine-worker", CDNUrl),
]);
return [marineJsWasm, avmWasm, worker];
};

View File

@ -14,16 +14,10 @@
* limitations under the License.
*/
import { createRequire } from "module";
import inject from "@rollup/plugin-inject";
import { transform } from "esbuild";
import { PluginOption, UserConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
const require = createRequire(import.meta.url);
const esbuildShim = require.resolve("node-stdlib-browser/helpers/esbuild/shim");
function minifyEs(): PluginOption {
return {
name: "minifyEs",
@ -56,15 +50,6 @@ const config: UserConfig = {
formats: ["es"],
},
outDir: "./dist/browser",
rollupOptions: {
plugins: [
inject({
global: [esbuildShim, "global"],
process: [esbuildShim, "process"],
Buffer: [esbuildShim, "Buffer"],
}),
],
},
},
plugins: [tsconfigPaths(), minifyEs()],
optimizeDeps: {