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 ( export const loadMarineDeps = async (
CDNUrl: string, CDNUrl: string,
): Promise<StrategyReturnType> => { ): Promise<StrategyReturnType> => {
const [marineJsWasm, avmWasm] = await Promise.all([ const timeout = new Promise((resolve) => {
fetchResource( setTimeout(resolve, 500);
"@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();
}),
]);
// TODO: load worker in parallel with avm and marine, test that it works const [marineJsWasm, avmWasm, worker] = await Promise.all([
const worker = await getWorker("@fluencelabs/marine-worker", CDNUrl); 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]; return [marineJsWasm, avmWasm, worker];
}; };

View File

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