mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-12 23:51:21 +00:00
fix(js-client): Fix CDN flow and move it in modules [fixes DXJ-527] (#376)
* Use type module in html * Fix autocommit * Try fix template * Try fix template * Try fix template * Try fix template * Try fix template * Fix test * Update packages/@tests/smoke/web/public/index.html Co-authored-by: shamsartem <shamsartem@gmail.com> * Minify es bundle * Remove autocommit * Fix lint * Remove minimal * Change nox version * Change nox version * Fix CDN --------- Co-authored-by: shamsartem <shamsartem@gmail.com>
This commit is contained in:
@ -68,6 +68,7 @@
|
||||
"@types/debug": "4.1.7",
|
||||
"@types/node": "20.7.0",
|
||||
"@types/uuid": "8.3.2",
|
||||
"esbuild": "0.19.5",
|
||||
"hotscript": "1.0.13",
|
||||
"vite": "4.4.11",
|
||||
"vite-tsconfig-paths": "4.0.3",
|
||||
|
@ -176,16 +176,6 @@ export type {
|
||||
|
||||
export { v5_callFunction, v5_registerService } from "./api.js";
|
||||
|
||||
// @ts-expect-error Writing to global object like this prohibited by ts
|
||||
globalThis.new_fluence = Fluence;
|
||||
|
||||
// @ts-expect-error Writing to global object like this prohibited by ts
|
||||
globalThis.fluence = {
|
||||
clientFactory: createClient,
|
||||
callAquaFunction,
|
||||
registerService,
|
||||
};
|
||||
|
||||
export { createClient, callAquaFunction, registerService };
|
||||
|
||||
// Deprecated exports. Later they will be exposed only under js-client/keypair path
|
||||
|
@ -17,11 +17,30 @@
|
||||
import inject from "@rollup/plugin-inject";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import { createRequire } from "module";
|
||||
import { UserConfig } from "vite";
|
||||
import { PluginOption, UserConfig } from "vite";
|
||||
import { transform } from "esbuild";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const esbuildShim = require.resolve("node-stdlib-browser/helpers/esbuild/shim");
|
||||
|
||||
function minifyEs(): PluginOption {
|
||||
return {
|
||||
name: "minifyEs",
|
||||
renderChunk: {
|
||||
order: "post",
|
||||
async handler(code, chunk, outputOptions) {
|
||||
if (
|
||||
outputOptions.format === "es" &&
|
||||
chunk.fileName.endsWith(".min.js")
|
||||
) {
|
||||
return await transform(code, { minify: true });
|
||||
}
|
||||
return code;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const config: UserConfig = {
|
||||
build: {
|
||||
target: "modules",
|
||||
@ -30,7 +49,7 @@ const config: UserConfig = {
|
||||
entry: "./src/index.ts",
|
||||
name: "js-client",
|
||||
fileName: () => "index.min.js",
|
||||
formats: ["umd"],
|
||||
formats: ["es"],
|
||||
},
|
||||
outDir: "./dist/browser",
|
||||
rollupOptions: {
|
||||
@ -47,7 +66,7 @@ const config: UserConfig = {
|
||||
],
|
||||
},
|
||||
},
|
||||
plugins: [tsconfigPaths()],
|
||||
plugins: [tsconfigPaths(), minifyEs()],
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
define: {
|
||||
|
Reference in New Issue
Block a user