@medusajs/admin-bundler 3.0.0-preview-20250211091350 → 3.0.0-preview-20250406180144
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.ts +1 -0
- package/dist/index.js +263 -99
- package/package.json +8 -12
- package/dist/entry.tsx +0 -15
- package/dist/index.css +0 -5
- package/dist/index.html +0 -16
package/dist/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ import * as express_serve_static_core from 'express-serve-static-core';
|
|
4
4
|
type BundlerOptions = Required<Pick<AdminOptions, "path">> & Pick<AdminOptions, "vite" | "backendUrl" | "storefrontUrl"> & {
|
5
5
|
outDir: string;
|
6
6
|
sources?: string[];
|
7
|
+
plugins?: string[];
|
7
8
|
};
|
8
9
|
|
9
10
|
declare function build(options: BundlerOptions): Promise<void>;
|
package/dist/index.js
CHANGED
@@ -571,6 +571,14 @@ var require_dist = __commonJS({
|
|
571
571
|
"muted": {
|
572
572
|
"DEFAULT": "var(--fg-muted)"
|
573
573
|
}
|
574
|
+
},
|
575
|
+
"alpha": {
|
576
|
+
"250": {
|
577
|
+
"DEFAULT": "var(--alpha-250)"
|
578
|
+
},
|
579
|
+
"400": {
|
580
|
+
"DEFAULT": "var(--alpha-400)"
|
581
|
+
}
|
574
582
|
}
|
575
583
|
}
|
576
584
|
},
|
@@ -595,9 +603,9 @@ var require_dist = __commonJS({
|
|
595
603
|
"elevation-flyout": "var(--elevation-flyout)",
|
596
604
|
"elevation-tooltip": "var(--elevation-tooltip)",
|
597
605
|
"elevation-modal": "var(--elevation-modal)",
|
598
|
-
"elevation-commandbar": "var(--elevation-commandbar)",
|
599
606
|
"elevation-code-block": "var(--elevation-code-block)",
|
600
|
-
"buttons-inverted": "var(--buttons-inverted)"
|
607
|
+
"buttons-inverted": "var(--buttons-inverted)",
|
608
|
+
"elevation-commandbar": "var(--elevation-commandbar)"
|
601
609
|
}
|
602
610
|
}
|
603
611
|
};
|
@@ -690,7 +698,9 @@ var require_dist = __commonJS({
|
|
690
698
|
"--bg-field-component-hover": "rgba(39, 39, 42, 1)",
|
691
699
|
"--bg-subtle-pressed": "rgba(39, 39, 42, 1)",
|
692
700
|
"--button-transparent-pressed": "rgba(255, 255, 255, 0.12)",
|
693
|
-
"--fg-muted": "rgba(113, 113, 122, 1)"
|
701
|
+
"--fg-muted": "rgba(113, 113, 122, 1)",
|
702
|
+
"--alpha-400": "rgba(255, 255, 255, 0.24)",
|
703
|
+
"--alpha-250": "rgba(255, 255, 255, 0.1)"
|
694
704
|
},
|
695
705
|
"light": {
|
696
706
|
"--tag-neutral-border": "rgba(228, 228, 231, 1)",
|
@@ -780,7 +790,9 @@ var require_dist = __commonJS({
|
|
780
790
|
"--contrast-border-top": "rgba(24, 24, 27, 1)",
|
781
791
|
"--bg-overlay": "rgba(24, 24, 27, 0.4)",
|
782
792
|
"--fg-disabled": "rgba(161, 161, 170, 1)",
|
783
|
-
"--fg-muted": "rgba(113, 113, 122, 1)"
|
793
|
+
"--fg-muted": "rgba(113, 113, 122, 1)",
|
794
|
+
"--alpha-400": "rgba(24, 24, 27, 0.24)",
|
795
|
+
"--alpha-250": "rgba(24, 24, 27, 0.1)"
|
784
796
|
}
|
785
797
|
};
|
786
798
|
var components = {
|
@@ -800,7 +812,6 @@ var require_dist = __commonJS({
|
|
800
812
|
"--buttons-danger-focus": "0px -1px 0px 0px rgba(255, 255, 255, 0.16), 0px 0px 0px 1px rgba(255, 255, 255, 0.12), 0px 0px 0px 1px rgba(159, 18, 57, 1), 0px 0px 0px 2px rgba(24, 24, 27, 1), 0px 0px 0px 4px rgba(96, 165, 250, 0.8)",
|
801
813
|
"--details-switch-background": "0px 1px 1px 0px rgba(0, 0, 0, 0.1) inset, 0px 2px 4px 0px rgba(0, 0, 0, 0.1) inset, 0px 0px 0px 0.75px rgba(255, 255, 255, 0.12) inset, 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset",
|
802
814
|
"--buttons-inverted-focus": "0px -1px 0px 0px rgba(255, 255, 255, 0.12), 0px 0px 0px 1px rgba(255, 255, 255, 0.12), 0px 0px 0px 1px rgba(82, 82, 91, 1), 0px 0px 0px 2px rgba(24, 24, 27, 1), 0px 0px 0px 4px rgba(96, 165, 250, 0.8)",
|
803
|
-
"--elevation-tooltip": "0px -1px 0px 0px rgba(255, 255, 255, 0.04), 0px 0px 0px 1px rgba(255, 255, 255, 0.1), 0px 2px 4px 0px rgba(0, 0, 0, 0.32), 0px 4px 8px 0px rgba(0, 0, 0, 0.32)",
|
804
815
|
"--elevation-flyout": "0px -1px 0px 0px rgba(255, 255, 255, 0.04), 0px 0px 0px 1px rgba(255, 255, 255, 0.1), 0px 4px 8px 0px rgba(0, 0, 0, 0.32), 0px 8px 16px 0px rgba(0, 0, 0, 0.32)",
|
805
816
|
"--borders-error": "0px 0px 0px 1px rgba(244, 63, 94, 1), 0px 0px 0px 3px rgba(225, 29, 72, 0.25)",
|
806
817
|
"--buttons-inverted": "0px -1px 0px 0px rgba(255, 255, 255, 0.12), 0px 0px 0px 1px rgba(255, 255, 255, 0.1), 0px 0px 0px 1px rgba(82, 82, 91, 1), 0px 0px 1px 1.5px rgba(0, 0, 0, 0.24), 0px 2px 2px 0px rgba(0, 0, 0, 0.24)",
|
@@ -810,8 +821,9 @@ var require_dist = __commonJS({
|
|
810
821
|
"--buttons-neutral": "0px -1px 0px 0px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(39, 39, 42, 1), 0px 0px 1px 1.5px rgba(0, 0, 0, 0.24), 0px 2px 2px 0px rgba(0, 0, 0, 0.24)",
|
811
822
|
"--elevation-code-block": "0px -1px 0px 0px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(39, 39, 42, 1), 0px 1px 2px 0px rgba(0, 0, 0, 0.32), 0px 2px 4px 0px rgba(0, 0, 0, 0.32)",
|
812
823
|
"--buttons-neutral-focus": "0px -1px 0px 0px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(255, 255, 255, 0.06), 0px 0px 0px 1px rgba(39, 39, 42, 1), 0px 0px 0px 2px rgba(24, 24, 27, 1), 0px 0px 0px 4px rgba(96, 165, 250, 0.8)",
|
813
|
-
"--elevation-
|
814
|
-
"--elevation-
|
824
|
+
"--elevation-modal": "0px 0px 0px 1px rgba(24, 24, 27, 1) inset, 0px 0px 0px 1.5px rgba(255, 255, 255, 0.06) inset, 0px -1px 0px 0px rgba(255, 255, 255, 0.04), 0px 0px 0px 1px rgba(255, 255, 255, 0.1), 0px 4px 8px 0px rgba(0, 0, 0, 0.32), 0px 8px 16px 0px rgba(0, 0, 0, 0.32)",
|
825
|
+
"--elevation-commandbar": "0px 0px 0px 0.75px rgba(24, 24, 27, 1) inset, 0px 0px 0px 1.25px rgba(255, 255, 255, 0.1) inset, 0px 4px 8px 0px rgba(0, 0, 0, 0.32), 0px 8px 16px 0px rgba(0, 0, 0, 0.32)",
|
826
|
+
"--elevation-tooltip": "0px -1px 0px 0px rgba(255, 255, 255, 0.04), 0px 2px 4px 0px rgba(0, 0, 0, 0.32), 0px 0px 0px 1px rgba(255, 255, 255, 0.1), 0px 4px 8px 0px rgba(0, 0, 0, 0.32)"
|
815
827
|
},
|
816
828
|
"light": {
|
817
829
|
"--borders-interactive-with-active": "0px 0px 0px 1px rgba(59, 130, 246, 1), 0px 0px 0px 4px rgba(59, 130, 246, 0.2)",
|
@@ -834,9 +846,9 @@ var require_dist = __commonJS({
|
|
834
846
|
"--elevation-flyout": "0px 0px 0px 1px rgba(0, 0, 0, 0.08), 0px 4px 8px 0px rgba(0, 0, 0, 0.08), 0px 8px 16px 0px rgba(0, 0, 0, 0.08)",
|
835
847
|
"--elevation-tooltip": "0px 0px 0px 1px rgba(0, 0, 0, 0.08), 0px 2px 4px 0px rgba(0, 0, 0, 0.08), 0px 4px 8px 0px rgba(0, 0, 0, 0.08)",
|
836
848
|
"--elevation-modal": "0px 0px 0px 1px rgba(255, 255, 255, 1) inset, 0px 0px 0px 1.5px rgba(228, 228, 231, 0.6) inset, 0px 0px 0px 1px rgba(0, 0, 0, 0.08), 0px 8px 16px 0px rgba(0, 0, 0, 0.08), 0px 16px 32px 0px rgba(0, 0, 0, 0.08)",
|
837
|
-
"--elevation-commandbar": "0px 0px 0px 1px rgba(39, 39, 42, 1) inset, 0px 0px 0px 1.5px rgba(255, 255, 255, 0.3) inset, 0px 8px 16px 0px rgba(0, 0, 0, 0.08), 0px 16px 32px 0px rgba(0, 0, 0, 0.08)",
|
838
849
|
"--elevation-code-block": "0px 0px 0px 1px rgba(24, 24, 27, 1) inset, 0px 0px 0px 1.5px rgba(255, 255, 255, 0.2) inset",
|
839
|
-
"--buttons-inverted": "0px 0.75px 0px 0px rgba(255, 255, 255, 0.2) inset, 0px 1px 2px 0px rgba(0, 0, 0, 0.4), 0px 0px 0px 1px rgba(24, 24, 27, 1)"
|
850
|
+
"--buttons-inverted": "0px 0.75px 0px 0px rgba(255, 255, 255, 0.2) inset, 0px 1px 2px 0px rgba(0, 0, 0, 0.4), 0px 0px 0px 1px rgba(24, 24, 27, 1)",
|
851
|
+
"--elevation-commandbar": "0px 0px 0px 0.75px rgba(39, 39, 42, 1) inset, 0px 0px 0px 1.25px rgba(255, 255, 255, 0.3) inset, 0px 8px 16px 0px rgba(0, 0, 0, 0.08), 0px 16px 32px 0px rgba(0, 0, 0, 0.08)"
|
840
852
|
}
|
841
853
|
};
|
842
854
|
var typography = {
|
@@ -978,24 +990,12 @@ var require_dist = __commonJS({
|
|
978
990
|
"fontWeight": "500",
|
979
991
|
"fontFamily": "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji"
|
980
992
|
},
|
981
|
-
".code-label": {
|
982
|
-
"fontSize": "0.75rem",
|
983
|
-
"lineHeight": "1.25rem",
|
984
|
-
"fontWeight": "400",
|
985
|
-
"fontFamily": "Roboto Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace"
|
986
|
-
},
|
987
993
|
".h4-webs": {
|
988
994
|
"fontSize": "1.5rem",
|
989
995
|
"lineHeight": "1.875rem",
|
990
996
|
"fontWeight": "500",
|
991
997
|
"fontFamily": "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji"
|
992
998
|
},
|
993
|
-
".code-body": {
|
994
|
-
"fontSize": "0.75rem",
|
995
|
-
"lineHeight": "1.125rem",
|
996
|
-
"fontWeight": "400",
|
997
|
-
"fontFamily": "Roboto Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace"
|
998
|
-
},
|
999
999
|
".h2-core": {
|
1000
1000
|
"fontSize": "1rem",
|
1001
1001
|
"lineHeight": "1.5rem",
|
@@ -1031,6 +1031,18 @@ var require_dist = __commonJS({
|
|
1031
1031
|
"lineHeight": "1.5rem",
|
1032
1032
|
"fontWeight": "500",
|
1033
1033
|
"fontFamily": "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji"
|
1034
|
+
},
|
1035
|
+
".code-body": {
|
1036
|
+
"fontSize": "0.75rem",
|
1037
|
+
"lineHeight": "1.125rem",
|
1038
|
+
"fontWeight": "400",
|
1039
|
+
"fontFamily": "Roboto Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace"
|
1040
|
+
},
|
1041
|
+
".code-label": {
|
1042
|
+
"fontSize": "0.75rem",
|
1043
|
+
"lineHeight": "0.9375rem",
|
1044
|
+
"fontWeight": "500",
|
1045
|
+
"fontFamily": "Roboto Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace"
|
1034
1046
|
}
|
1035
1047
|
};
|
1036
1048
|
var plugin_default = (0, import_plugin2.default)(
|
@@ -1108,16 +1120,179 @@ __export(src_exports, {
|
|
1108
1120
|
});
|
1109
1121
|
module.exports = __toCommonJS(src_exports);
|
1110
1122
|
|
1111
|
-
// src/
|
1123
|
+
// src/utils/config.ts
|
1112
1124
|
var import_admin_shared = require("@medusajs/admin-shared");
|
1113
1125
|
var import_path = __toESM(require("path"));
|
1126
|
+
|
1127
|
+
// src/plugins/inject-tailwindcss.ts
|
1128
|
+
var import_node_path = __toESM(require("path"));
|
1129
|
+
var injectTailwindCSS = (options) => {
|
1130
|
+
return {
|
1131
|
+
name: "medusa:inject-tailwindcss",
|
1132
|
+
config: () => ({
|
1133
|
+
css: {
|
1134
|
+
postcss: {
|
1135
|
+
plugins: [
|
1136
|
+
require("tailwindcss")({
|
1137
|
+
config: createTailwindConfig(
|
1138
|
+
options.entry,
|
1139
|
+
options.sources,
|
1140
|
+
options.plugins
|
1141
|
+
)
|
1142
|
+
})
|
1143
|
+
]
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
})
|
1147
|
+
};
|
1148
|
+
};
|
1149
|
+
function createTailwindConfig(entry, sources = [], plugins = []) {
|
1150
|
+
const root = import_node_path.default.join(entry, "**/*.{js,ts,jsx,tsx}");
|
1151
|
+
const html = import_node_path.default.join(entry, "index.html");
|
1152
|
+
let dashboard = "";
|
1153
|
+
try {
|
1154
|
+
dashboard = import_node_path.default.join(
|
1155
|
+
import_node_path.default.dirname(require.resolve("@medusajs/dashboard")),
|
1156
|
+
"**/*.{js,ts,jsx,tsx}"
|
1157
|
+
);
|
1158
|
+
} catch (_e) {
|
1159
|
+
}
|
1160
|
+
let ui = "";
|
1161
|
+
try {
|
1162
|
+
ui = import_node_path.default.join(
|
1163
|
+
import_node_path.default.dirname(require.resolve("@medusajs/ui")),
|
1164
|
+
"**/*.{js,ts,jsx,tsx}"
|
1165
|
+
);
|
1166
|
+
} catch (_e) {
|
1167
|
+
}
|
1168
|
+
const sourceExtensions = sources.map(
|
1169
|
+
(s) => import_node_path.default.join(s, "**/*.{js,ts,jsx,tsx}")
|
1170
|
+
);
|
1171
|
+
const pluginExtensions = [];
|
1172
|
+
for (const plugin2 of plugins) {
|
1173
|
+
try {
|
1174
|
+
const pluginPath = import_node_path.default.join(
|
1175
|
+
import_node_path.default.dirname(require.resolve(plugin2)),
|
1176
|
+
"**/*.{js,ts,jsx,tsx}"
|
1177
|
+
);
|
1178
|
+
pluginExtensions.push(pluginPath);
|
1179
|
+
} catch (_e) {
|
1180
|
+
}
|
1181
|
+
}
|
1182
|
+
const config = {
|
1183
|
+
presets: [require_dist()],
|
1184
|
+
content: [
|
1185
|
+
html,
|
1186
|
+
root,
|
1187
|
+
dashboard,
|
1188
|
+
ui,
|
1189
|
+
...sourceExtensions,
|
1190
|
+
...pluginExtensions
|
1191
|
+
],
|
1192
|
+
darkMode: "class"
|
1193
|
+
};
|
1194
|
+
return config;
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
// src/utils/write-static-files.ts
|
1198
|
+
var import_promises = require("fs/promises");
|
1199
|
+
var import_node_path2 = require("path");
|
1200
|
+
var import_outdent = __toESM(require("outdent"));
|
1201
|
+
async function writeStaticFiles(plugins) {
|
1202
|
+
const outDir = (0, import_node_path2.join)(process.cwd(), ".medusa/client");
|
1203
|
+
await (0, import_promises.mkdir)(outDir, { recursive: true });
|
1204
|
+
const promises = [
|
1205
|
+
writeCSSFile(outDir),
|
1206
|
+
writeEntryFile(outDir, plugins),
|
1207
|
+
writeHTMLFile(outDir)
|
1208
|
+
];
|
1209
|
+
await Promise.all(promises);
|
1210
|
+
}
|
1211
|
+
async function writeCSSFile(outDir) {
|
1212
|
+
const css = import_outdent.default`
|
1213
|
+
@import "@medusajs/dashboard/css";
|
1214
|
+
|
1215
|
+
@tailwind base;
|
1216
|
+
@tailwind components;
|
1217
|
+
@tailwind utilities;
|
1218
|
+
`;
|
1219
|
+
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "index.css"), css);
|
1220
|
+
}
|
1221
|
+
function getPluginName(index) {
|
1222
|
+
return `plugin${index}`;
|
1223
|
+
}
|
1224
|
+
async function writeEntryFile(outDir, plugins) {
|
1225
|
+
const entry = import_outdent.default`
|
1226
|
+
import App from "@medusajs/dashboard";
|
1227
|
+
import React from "react";
|
1228
|
+
import ReactDOM from "react-dom/client";
|
1229
|
+
import "./index.css";
|
1230
|
+
|
1231
|
+
${plugins?.map((plugin2, idx) => `import ${getPluginName(idx)} from "${plugin2}"`).join("\n")}
|
1232
|
+
|
1233
|
+
let root = null
|
1234
|
+
|
1235
|
+
if (!root) {
|
1236
|
+
root = ReactDOM.createRoot(document.getElementById("medusa"))
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
|
1240
|
+
root.render(
|
1241
|
+
<React.StrictMode>
|
1242
|
+
<App plugins={[${plugins?.map((_, idx) => getPluginName(idx)).join(", ")}]} />
|
1243
|
+
</React.StrictMode>
|
1244
|
+
)
|
1245
|
+
|
1246
|
+
|
1247
|
+
if (import.meta.hot) {
|
1248
|
+
import.meta.hot.accept()
|
1249
|
+
}
|
1250
|
+
`;
|
1251
|
+
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "entry.jsx"), entry);
|
1252
|
+
}
|
1253
|
+
async function writeHTMLFile(outDir) {
|
1254
|
+
const html = import_outdent.default`
|
1255
|
+
<!DOCTYPE html>
|
1256
|
+
<html>
|
1257
|
+
<head>
|
1258
|
+
<meta
|
1259
|
+
http-equiv="Content-Type"
|
1260
|
+
content="text/html; charset=UTF-8"
|
1261
|
+
/>
|
1262
|
+
<meta
|
1263
|
+
name="viewport"
|
1264
|
+
content="width=device-width, initial-scale=1, user-scalable=no"
|
1265
|
+
/>
|
1266
|
+
<link rel="icon" href="data:," data-placeholder-favicon />
|
1267
|
+
</head>
|
1268
|
+
|
1269
|
+
<body>
|
1270
|
+
<div id="medusa"></div>
|
1271
|
+
<script type="module" src="./entry.jsx"></script>
|
1272
|
+
</body>
|
1273
|
+
</html>
|
1274
|
+
`;
|
1275
|
+
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "index.html"), html);
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
// src/plugins/write-static-files.ts
|
1279
|
+
var writeStaticFiles2 = (options) => {
|
1280
|
+
return {
|
1281
|
+
name: "medusa:write-static-files",
|
1282
|
+
buildStart: async (ctx) => {
|
1283
|
+
await writeStaticFiles(options.plugins);
|
1284
|
+
}
|
1285
|
+
};
|
1286
|
+
};
|
1287
|
+
|
1288
|
+
// src/utils/config.ts
|
1114
1289
|
async function getViteConfig(options) {
|
1115
1290
|
const { searchForWorkspaceRoot, mergeConfig } = await import("vite");
|
1116
1291
|
const { default: react } = await import("@vitejs/plugin-react");
|
1117
1292
|
const { default: medusa } = await import("@medusajs/admin-vite-plugin");
|
1118
1293
|
const getPort = await import("get-port");
|
1119
1294
|
const hmrPort = await getPort.default();
|
1120
|
-
const root = import_path.default.resolve(
|
1295
|
+
const root = import_path.default.resolve(process.cwd(), ".medusa/client");
|
1121
1296
|
const backendUrl = options.backendUrl ?? "";
|
1122
1297
|
const storefrontUrl = options.storefrontUrl ?? "";
|
1123
1298
|
const baseConfig = {
|
@@ -1153,16 +1328,15 @@ async function getViteConfig(options) {
|
|
1153
1328
|
port: hmrPort
|
1154
1329
|
}
|
1155
1330
|
},
|
1156
|
-
css: {
|
1157
|
-
postcss: {
|
1158
|
-
plugins: [
|
1159
|
-
require("tailwindcss")({
|
1160
|
-
config: createTailwindConfig(root, options.sources)
|
1161
|
-
})
|
1162
|
-
]
|
1163
|
-
}
|
1164
|
-
},
|
1165
1331
|
plugins: [
|
1332
|
+
writeStaticFiles2({
|
1333
|
+
plugins: options.plugins
|
1334
|
+
}),
|
1335
|
+
injectTailwindCSS({
|
1336
|
+
entry: root,
|
1337
|
+
sources: options.sources,
|
1338
|
+
plugins: options.plugins
|
1339
|
+
}),
|
1166
1340
|
react(),
|
1167
1341
|
medusa({
|
1168
1342
|
sources: options.sources
|
@@ -1175,35 +1349,8 @@ async function getViteConfig(options) {
|
|
1175
1349
|
}
|
1176
1350
|
return baseConfig;
|
1177
1351
|
}
|
1178
|
-
function createTailwindConfig(entry, sources = []) {
|
1179
|
-
const root = import_path.default.join(entry, "**/*.{js,ts,jsx,tsx}");
|
1180
|
-
const html = import_path.default.join(entry, "index.html");
|
1181
|
-
let dashboard = "";
|
1182
|
-
try {
|
1183
|
-
dashboard = import_path.default.join(
|
1184
|
-
import_path.default.dirname(require.resolve("@medusajs/dashboard")),
|
1185
|
-
"**/*.{js,ts,jsx,tsx}"
|
1186
|
-
);
|
1187
|
-
} catch (_e) {
|
1188
|
-
}
|
1189
|
-
let ui = "";
|
1190
|
-
try {
|
1191
|
-
ui = import_path.default.join(
|
1192
|
-
import_path.default.dirname(require.resolve("@medusajs/ui")),
|
1193
|
-
"**/*.{js,ts,jsx,tsx}"
|
1194
|
-
);
|
1195
|
-
} catch (_e) {
|
1196
|
-
}
|
1197
|
-
const extensions = sources.map((s) => import_path.default.join(s, "**/*.{js,ts,jsx,tsx}"));
|
1198
|
-
const config = {
|
1199
|
-
presets: [require_dist()],
|
1200
|
-
content: [html, root, dashboard, ui, ...extensions],
|
1201
|
-
darkMode: "class"
|
1202
|
-
};
|
1203
|
-
return config;
|
1204
|
-
}
|
1205
1352
|
|
1206
|
-
// src/
|
1353
|
+
// src/commands/build.ts
|
1207
1354
|
async function build(options) {
|
1208
1355
|
const vite = await import("vite");
|
1209
1356
|
const viteConfig = await getViteConfig(options);
|
@@ -1214,7 +1361,7 @@ async function build(options) {
|
|
1214
1361
|
await vite.build(vite.mergeConfig(viteConfig, buildConfig));
|
1215
1362
|
}
|
1216
1363
|
|
1217
|
-
// src/
|
1364
|
+
// src/commands/develop.ts
|
1218
1365
|
var import_express = __toESM(require("express"));
|
1219
1366
|
var import_fs = __toESM(require("fs"));
|
1220
1367
|
var import_path2 = __toESM(require("path"));
|
@@ -1285,24 +1432,30 @@ async function develop(options) {
|
|
1285
1432
|
return router;
|
1286
1433
|
}
|
1287
1434
|
|
1288
|
-
// src/
|
1435
|
+
// src/commands/plugin.ts
|
1289
1436
|
var import_fs2 = require("fs");
|
1290
|
-
var
|
1291
|
-
var import_glob = require("glob");
|
1437
|
+
var import_node_module = require("module");
|
1292
1438
|
var import_path3 = __toESM(require("path"));
|
1439
|
+
|
1440
|
+
// src/plugins/clear-plugin-build.ts
|
1441
|
+
var import_promises2 = require("fs/promises");
|
1442
|
+
var import_node_path3 = __toESM(require("path"));
|
1443
|
+
var clearPluginBuild = (options) => ({
|
1444
|
+
name: "medusa:clear-plugin-build",
|
1445
|
+
buildStart: async () => {
|
1446
|
+
const adminDir = import_node_path3.default.join(options.outDir, "admin");
|
1447
|
+
try {
|
1448
|
+
await (0, import_promises2.rm)(adminDir, { recursive: true, force: true });
|
1449
|
+
} catch (e) {
|
1450
|
+
}
|
1451
|
+
}
|
1452
|
+
});
|
1453
|
+
|
1454
|
+
// src/commands/plugin.ts
|
1293
1455
|
async function plugin(options) {
|
1294
1456
|
const vite = await import("vite");
|
1295
1457
|
const react = (await import("@vitejs/plugin-react")).default;
|
1296
|
-
const
|
1297
|
-
const entries = await (0, import_glob.glob)(`${options.root}/src/admin/**/*.{ts,tsx,js,jsx}`);
|
1298
|
-
if (entries.length === 0) {
|
1299
|
-
return;
|
1300
|
-
}
|
1301
|
-
const entryPoints = entries.reduce((acc, entry) => {
|
1302
|
-
const outPath = entry.replace(/^src\//, "").replace(/\.(ts|tsx|js|jsx)$/, "");
|
1303
|
-
acc[outPath] = import_path3.default.resolve(options.root, entry);
|
1304
|
-
return acc;
|
1305
|
-
}, {});
|
1458
|
+
const medusa = (await import("@medusajs/admin-vite-plugin")).default;
|
1306
1459
|
const pkg = JSON.parse(
|
1307
1460
|
(0, import_fs2.readFileSync)(import_path3.default.resolve(options.root, "package.json"), "utf-8")
|
1308
1461
|
);
|
@@ -1311,51 +1464,62 @@ async function plugin(options) {
|
|
1311
1464
|
...Object.keys(pkg.peerDependencies || {}),
|
1312
1465
|
...Object.keys(pkg.devDependencies || {}),
|
1313
1466
|
"react",
|
1314
|
-
"react-dom",
|
1315
1467
|
"react/jsx-runtime",
|
1316
1468
|
"react-router-dom",
|
1469
|
+
"@medusajs/js-sdk",
|
1317
1470
|
"@medusajs/admin-sdk",
|
1318
1471
|
"@tanstack/react-query"
|
1319
1472
|
]);
|
1473
|
+
const outDir = import_path3.default.resolve(options.root, options.outDir, "src/admin");
|
1474
|
+
const entryPoint = import_path3.default.resolve(
|
1475
|
+
options.root,
|
1476
|
+
"src/admin/__admin-extensions__.js"
|
1477
|
+
);
|
1320
1478
|
const originalNodeEnv = process.env.NODE_ENV;
|
1321
1479
|
process.env.NODE_ENV = "production";
|
1322
1480
|
const pluginConfig = {
|
1323
1481
|
build: {
|
1324
1482
|
lib: {
|
1325
|
-
entry:
|
1326
|
-
formats: ["es"]
|
1483
|
+
entry: entryPoint,
|
1484
|
+
formats: ["es", "cjs"],
|
1485
|
+
fileName: "index"
|
1327
1486
|
},
|
1328
1487
|
emptyOutDir: false,
|
1329
1488
|
minify: false,
|
1330
|
-
outDir
|
1489
|
+
outDir,
|
1331
1490
|
rollupOptions: {
|
1332
|
-
|
1333
|
-
|
1491
|
+
external: (id, importer) => {
|
1492
|
+
if (!importer) {
|
1493
|
+
const idParts2 = id.split("/");
|
1494
|
+
const name2 = idParts2[0]?.startsWith("@") ? `${idParts2[0]}/${idParts2[1]}` : idParts2[0];
|
1495
|
+
const builtinModulesWithNodePrefix = [
|
1496
|
+
...import_node_module.builtinModules,
|
1497
|
+
...import_node_module.builtinModules.map((modName) => `node:${modName}`)
|
1498
|
+
];
|
1499
|
+
return Boolean(
|
1500
|
+
name2 && external.has(name2) || name2 && builtinModulesWithNodePrefix.includes(name2)
|
1501
|
+
);
|
1502
|
+
}
|
1503
|
+
const idParts = id.split("/");
|
1504
|
+
const name = idParts[0]?.startsWith("@") ? `${idParts[0]}/${idParts[1]}` : idParts[0];
|
1505
|
+
return Boolean(name && external.has(name));
|
1506
|
+
},
|
1334
1507
|
output: {
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
},
|
1340
|
-
preserveModules: true,
|
1341
|
-
entryFileNames: (chunkInfo) => {
|
1342
|
-
return `${chunkInfo.name.replace(`${options.root}/`, "")}.js`;
|
1508
|
+
preserveModules: false,
|
1509
|
+
interop: "auto",
|
1510
|
+
chunkFileNames: () => {
|
1511
|
+
return `_chunks/[name]-[hash]`;
|
1343
1512
|
}
|
1344
1513
|
}
|
1345
1514
|
}
|
1346
1515
|
},
|
1347
1516
|
plugins: [
|
1348
1517
|
react(),
|
1349
|
-
{
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
await (0, import_promises.rm)(adminDir, { recursive: true, force: true });
|
1355
|
-
} catch (e) {
|
1356
|
-
}
|
1357
|
-
}
|
1358
|
-
}
|
1518
|
+
medusa({
|
1519
|
+
pluginMode: true,
|
1520
|
+
sources: [import_path3.default.resolve(options.root, "src/admin")]
|
1521
|
+
}),
|
1522
|
+
clearPluginBuild({ outDir })
|
1359
1523
|
],
|
1360
1524
|
logLevel: "silent",
|
1361
1525
|
clearScreen: false
|
@@ -1364,7 +1528,7 @@ async function plugin(options) {
|
|
1364
1528
|
process.env.NODE_ENV = originalNodeEnv;
|
1365
1529
|
}
|
1366
1530
|
|
1367
|
-
// src/
|
1531
|
+
// src/commands/serve.ts
|
1368
1532
|
var import_compression = __toESM(require("compression"));
|
1369
1533
|
var import_express2 = require("express");
|
1370
1534
|
var import_fs3 = __toESM(require("fs"));
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/admin-bundler",
|
3
|
-
"version": "3.0.0-preview-
|
3
|
+
"version": "3.0.0-preview-20250406180144",
|
4
4
|
"description": "Bundler for the Medusa admin dashboard.",
|
5
5
|
"author": "Kasper Kristensen <kasper@medusajs.com>",
|
6
6
|
"scripts": {
|
7
|
-
"build": "tsup
|
7
|
+
"build": "tsup"
|
8
8
|
},
|
9
9
|
"main": "./dist/index.js",
|
10
10
|
"types": "./dist/index.d.ts",
|
@@ -18,30 +18,26 @@
|
|
18
18
|
"package.json"
|
19
19
|
],
|
20
20
|
"devDependencies": {
|
21
|
-
"@medusajs/types": "3.0.0-preview-
|
21
|
+
"@medusajs/types": "3.0.0-preview-20250406180144",
|
22
22
|
"@types/compression": "^1.7.5",
|
23
|
-
"copyfiles": "^2.4.1",
|
24
23
|
"express": "^4.21.0",
|
25
24
|
"tsup": "^8.0.1",
|
26
25
|
"typescript": "^5.3.3"
|
27
26
|
},
|
28
27
|
"dependencies": {
|
29
|
-
"@medusajs/admin-shared": "3.0.0-preview-
|
30
|
-
"@medusajs/admin-vite-plugin": "3.0.0-preview-
|
31
|
-
"@medusajs/dashboard": "3.0.0-preview-
|
32
|
-
"@rollup/plugin-node-resolve": "^16.0.0",
|
28
|
+
"@medusajs/admin-shared": "3.0.0-preview-20250406180144",
|
29
|
+
"@medusajs/admin-vite-plugin": "3.0.0-preview-20250406180144",
|
30
|
+
"@medusajs/dashboard": "3.0.0-preview-20250406180144",
|
33
31
|
"@vitejs/plugin-react": "^4.2.1",
|
34
32
|
"autoprefixer": "^10.4.16",
|
35
33
|
"compression": "^1.7.4",
|
36
34
|
"express": "^4.21.0",
|
37
35
|
"get-port": "^5.1.1",
|
38
36
|
"glob": "^10.3.10",
|
37
|
+
"outdent": "^0.8.0",
|
39
38
|
"postcss": "^8.4.32",
|
40
39
|
"tailwindcss": "^3.3.6",
|
41
|
-
"vite": "^5.
|
42
|
-
},
|
43
|
-
"peerDependencies": {
|
44
|
-
"react-dom": "^18.0.0"
|
40
|
+
"vite": "^5.4.14"
|
45
41
|
},
|
46
42
|
"packageManager": "yarn@3.2.1"
|
47
43
|
}
|
package/dist/entry.tsx
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import App from "@medusajs/dashboard";
|
2
|
-
import React from "react";
|
3
|
-
import ReactDOM from "react-dom/client";
|
4
|
-
import "./index.css";
|
5
|
-
|
6
|
-
ReactDOM.createRoot(document.getElementById("medusa")!).render(
|
7
|
-
<React.StrictMode>
|
8
|
-
<App />
|
9
|
-
</React.StrictMode>
|
10
|
-
)
|
11
|
-
|
12
|
-
|
13
|
-
if (import.meta.hot) {
|
14
|
-
import.meta.hot.accept()
|
15
|
-
}
|
package/dist/index.css
DELETED
package/dist/index.html
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<meta
|
6
|
-
name="viewport"
|
7
|
-
content="width=device-width, initial-scale=1, user-scalable=no"
|
8
|
-
/>
|
9
|
-
<link rel="icon" href="data:," data-placeholder-favicon />
|
10
|
-
</head>
|
11
|
-
|
12
|
-
<body>
|
13
|
-
<div id="medusa"></div>
|
14
|
-
<script type="module" src="./entry.tsx"></script>
|
15
|
-
</body>
|
16
|
-
</html>
|