@miden-sdk/vite-plugin 0.13.4 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +47 -2
- package/dist/index.mjs +47 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,11 @@ import { Plugin } from 'vite';
|
|
|
3
3
|
interface MidenVitePluginOptions {
|
|
4
4
|
/** Packages to deduplicate. Default: ["@miden-sdk/miden-sdk"] */
|
|
5
5
|
wasmPackages?: string[];
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Enable COOP/COEP headers on dev server for SharedArrayBuffer support.
|
|
8
|
+
* Default: false — enabling this breaks OAuth popup flows (e.g. Para)
|
|
9
|
+
* because `same-origin` COOP nullifies `window.opener` in popups.
|
|
10
|
+
*/
|
|
7
11
|
crossOriginIsolation?: boolean;
|
|
8
12
|
/** gRPC-web proxy target URL. Default: "https://rpc.testnet.miden.io". Set to false to disable. */
|
|
9
13
|
rpcProxyTarget?: string | false;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { Plugin } from 'vite';
|
|
|
3
3
|
interface MidenVitePluginOptions {
|
|
4
4
|
/** Packages to deduplicate. Default: ["@miden-sdk/miden-sdk"] */
|
|
5
5
|
wasmPackages?: string[];
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Enable COOP/COEP headers on dev server for SharedArrayBuffer support.
|
|
8
|
+
* Default: false — enabling this breaks OAuth popup flows (e.g. Para)
|
|
9
|
+
* because `same-origin` COOP nullifies `window.opener` in popups.
|
|
10
|
+
*/
|
|
7
11
|
crossOriginIsolation?: boolean;
|
|
8
12
|
/** gRPC-web proxy target URL. Default: "https://rpc.testnet.miden.io". Set to false to disable. */
|
|
9
13
|
rpcProxyTarget?: string | false;
|
package/dist/index.js
CHANGED
|
@@ -36,13 +36,28 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
38
|
var import_node_module = require("module");
|
|
39
|
+
var externalizeMidenReact = {
|
|
40
|
+
name: "externalize-miden-react",
|
|
41
|
+
setup(build) {
|
|
42
|
+
build.onResolve({ filter: /^@miden-sdk\/react$/ }, () => ({
|
|
43
|
+
path: "@miden-sdk/react",
|
|
44
|
+
external: true
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
39
48
|
function midenVitePlugin(options) {
|
|
40
49
|
const {
|
|
41
50
|
wasmPackages = ["@miden-sdk/miden-sdk"],
|
|
42
|
-
crossOriginIsolation =
|
|
51
|
+
crossOriginIsolation = false,
|
|
43
52
|
rpcProxyTarget = "https://rpc.testnet.miden.io",
|
|
44
53
|
rpcProxyPath = "/rpc.Api"
|
|
45
54
|
} = options ?? {};
|
|
55
|
+
const requiredDedupe = [
|
|
56
|
+
"react",
|
|
57
|
+
"react-dom",
|
|
58
|
+
"react/jsx-runtime",
|
|
59
|
+
"@miden-sdk/react"
|
|
60
|
+
];
|
|
46
61
|
return {
|
|
47
62
|
name: "@miden-sdk/vite-plugin",
|
|
48
63
|
enforce: "pre",
|
|
@@ -79,7 +94,7 @@ function midenVitePlugin(options) {
|
|
|
79
94
|
return {
|
|
80
95
|
resolve: {
|
|
81
96
|
alias,
|
|
82
|
-
dedupe: [...wasmPackages],
|
|
97
|
+
dedupe: [...wasmPackages, ...requiredDedupe],
|
|
83
98
|
preserveSymlinks: true
|
|
84
99
|
},
|
|
85
100
|
optimizeDeps: {
|
|
@@ -95,6 +110,36 @@ function midenVitePlugin(options) {
|
|
|
95
110
|
server: serverConfig,
|
|
96
111
|
preview: previewConfig
|
|
97
112
|
};
|
|
113
|
+
},
|
|
114
|
+
// Use configResolved to inject the esbuild externalization plugin and
|
|
115
|
+
// dedupe entries into the final resolved config. This runs AFTER all
|
|
116
|
+
// plugins' config() hooks have been merged, so other plugins (e.g.
|
|
117
|
+
// vite-plugin-node-polyfills) can't overwrite these entries.
|
|
118
|
+
configResolved(config) {
|
|
119
|
+
if (!config.optimizeDeps.esbuildOptions) {
|
|
120
|
+
config.optimizeDeps.esbuildOptions = {};
|
|
121
|
+
}
|
|
122
|
+
const esbuildOpts = config.optimizeDeps.esbuildOptions;
|
|
123
|
+
if (!esbuildOpts.plugins) {
|
|
124
|
+
esbuildOpts.plugins = [];
|
|
125
|
+
}
|
|
126
|
+
const hasPlugin = esbuildOpts.plugins.some(
|
|
127
|
+
(p) => p.name === "externalize-miden-react"
|
|
128
|
+
);
|
|
129
|
+
if (!hasPlugin) {
|
|
130
|
+
esbuildOpts.plugins.push(externalizeMidenReact);
|
|
131
|
+
}
|
|
132
|
+
if (!esbuildOpts.target) {
|
|
133
|
+
esbuildOpts.target = "esnext";
|
|
134
|
+
}
|
|
135
|
+
if (!config.resolve.dedupe) {
|
|
136
|
+
config.resolve.dedupe = [];
|
|
137
|
+
}
|
|
138
|
+
for (const dep of requiredDedupe) {
|
|
139
|
+
if (!config.resolve.dedupe.includes(dep)) {
|
|
140
|
+
config.resolve.dedupe.push(dep);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
98
143
|
}
|
|
99
144
|
};
|
|
100
145
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
|
+
var externalizeMidenReact = {
|
|
5
|
+
name: "externalize-miden-react",
|
|
6
|
+
setup(build) {
|
|
7
|
+
build.onResolve({ filter: /^@miden-sdk\/react$/ }, () => ({
|
|
8
|
+
path: "@miden-sdk/react",
|
|
9
|
+
external: true
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
4
13
|
function midenVitePlugin(options) {
|
|
5
14
|
const {
|
|
6
15
|
wasmPackages = ["@miden-sdk/miden-sdk"],
|
|
7
|
-
crossOriginIsolation =
|
|
16
|
+
crossOriginIsolation = false,
|
|
8
17
|
rpcProxyTarget = "https://rpc.testnet.miden.io",
|
|
9
18
|
rpcProxyPath = "/rpc.Api"
|
|
10
19
|
} = options ?? {};
|
|
20
|
+
const requiredDedupe = [
|
|
21
|
+
"react",
|
|
22
|
+
"react-dom",
|
|
23
|
+
"react/jsx-runtime",
|
|
24
|
+
"@miden-sdk/react"
|
|
25
|
+
];
|
|
11
26
|
return {
|
|
12
27
|
name: "@miden-sdk/vite-plugin",
|
|
13
28
|
enforce: "pre",
|
|
@@ -44,7 +59,7 @@ function midenVitePlugin(options) {
|
|
|
44
59
|
return {
|
|
45
60
|
resolve: {
|
|
46
61
|
alias,
|
|
47
|
-
dedupe: [...wasmPackages],
|
|
62
|
+
dedupe: [...wasmPackages, ...requiredDedupe],
|
|
48
63
|
preserveSymlinks: true
|
|
49
64
|
},
|
|
50
65
|
optimizeDeps: {
|
|
@@ -60,6 +75,36 @@ function midenVitePlugin(options) {
|
|
|
60
75
|
server: serverConfig,
|
|
61
76
|
preview: previewConfig
|
|
62
77
|
};
|
|
78
|
+
},
|
|
79
|
+
// Use configResolved to inject the esbuild externalization plugin and
|
|
80
|
+
// dedupe entries into the final resolved config. This runs AFTER all
|
|
81
|
+
// plugins' config() hooks have been merged, so other plugins (e.g.
|
|
82
|
+
// vite-plugin-node-polyfills) can't overwrite these entries.
|
|
83
|
+
configResolved(config) {
|
|
84
|
+
if (!config.optimizeDeps.esbuildOptions) {
|
|
85
|
+
config.optimizeDeps.esbuildOptions = {};
|
|
86
|
+
}
|
|
87
|
+
const esbuildOpts = config.optimizeDeps.esbuildOptions;
|
|
88
|
+
if (!esbuildOpts.plugins) {
|
|
89
|
+
esbuildOpts.plugins = [];
|
|
90
|
+
}
|
|
91
|
+
const hasPlugin = esbuildOpts.plugins.some(
|
|
92
|
+
(p) => p.name === "externalize-miden-react"
|
|
93
|
+
);
|
|
94
|
+
if (!hasPlugin) {
|
|
95
|
+
esbuildOpts.plugins.push(externalizeMidenReact);
|
|
96
|
+
}
|
|
97
|
+
if (!esbuildOpts.target) {
|
|
98
|
+
esbuildOpts.target = "esnext";
|
|
99
|
+
}
|
|
100
|
+
if (!config.resolve.dedupe) {
|
|
101
|
+
config.resolve.dedupe = [];
|
|
102
|
+
}
|
|
103
|
+
for (const dep of requiredDedupe) {
|
|
104
|
+
if (!config.resolve.dedupe.includes(dep)) {
|
|
105
|
+
config.resolve.dedupe.push(dep);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
63
108
|
}
|
|
64
109
|
};
|
|
65
110
|
}
|
package/package.json
CHANGED