@medusajs/admin-bundler 2.6.2-snapshot-20250310153842 → 2.6.2-snapshot-20250311083444
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/entry.tsx +15 -0
- package/dist/index.css +5 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.html +16 -0
- package/dist/index.js +78 -230
- package/package.json +11 -7
package/dist/entry.tsx
ADDED
@@ -0,0 +1,15 @@
|
|
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
ADDED
package/dist/index.d.ts
CHANGED
@@ -4,7 +4,6 @@ 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[];
|
8
7
|
};
|
9
8
|
|
10
9
|
declare function build(options: BundlerOptions): Promise<void>;
|
package/dist/index.html
ADDED
@@ -0,0 +1,16 @@
|
|
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>
|
package/dist/index.js
CHANGED
@@ -1108,179 +1108,16 @@ __export(src_exports, {
|
|
1108
1108
|
});
|
1109
1109
|
module.exports = __toCommonJS(src_exports);
|
1110
1110
|
|
1111
|
-
// src/
|
1111
|
+
// src/lib/config.ts
|
1112
1112
|
var import_admin_shared = require("@medusajs/admin-shared");
|
1113
1113
|
var import_path = __toESM(require("path"));
|
1114
|
-
|
1115
|
-
// src/plugins/inject-tailwindcss.ts
|
1116
|
-
var import_node_path = __toESM(require("path"));
|
1117
|
-
var injectTailwindCSS = (options) => {
|
1118
|
-
return {
|
1119
|
-
name: "medusa:inject-tailwindcss",
|
1120
|
-
config: () => ({
|
1121
|
-
css: {
|
1122
|
-
postcss: {
|
1123
|
-
plugins: [
|
1124
|
-
require("tailwindcss")({
|
1125
|
-
config: createTailwindConfig(
|
1126
|
-
options.entry,
|
1127
|
-
options.sources,
|
1128
|
-
options.plugins
|
1129
|
-
)
|
1130
|
-
})
|
1131
|
-
]
|
1132
|
-
}
|
1133
|
-
}
|
1134
|
-
})
|
1135
|
-
};
|
1136
|
-
};
|
1137
|
-
function createTailwindConfig(entry, sources = [], plugins = []) {
|
1138
|
-
const root = import_node_path.default.join(entry, "**/*.{js,ts,jsx,tsx}");
|
1139
|
-
const html = import_node_path.default.join(entry, "index.html");
|
1140
|
-
let dashboard = "";
|
1141
|
-
try {
|
1142
|
-
dashboard = import_node_path.default.join(
|
1143
|
-
import_node_path.default.dirname(require.resolve("@medusajs/dashboard")),
|
1144
|
-
"**/*.{js,ts,jsx,tsx}"
|
1145
|
-
);
|
1146
|
-
} catch (_e) {
|
1147
|
-
}
|
1148
|
-
let ui = "";
|
1149
|
-
try {
|
1150
|
-
ui = import_node_path.default.join(
|
1151
|
-
import_node_path.default.dirname(require.resolve("@medusajs/ui")),
|
1152
|
-
"**/*.{js,ts,jsx,tsx}"
|
1153
|
-
);
|
1154
|
-
} catch (_e) {
|
1155
|
-
}
|
1156
|
-
const sourceExtensions = sources.map(
|
1157
|
-
(s) => import_node_path.default.join(s, "**/*.{js,ts,jsx,tsx}")
|
1158
|
-
);
|
1159
|
-
const pluginExtensions = [];
|
1160
|
-
for (const plugin2 of plugins) {
|
1161
|
-
try {
|
1162
|
-
const pluginPath = import_node_path.default.join(
|
1163
|
-
import_node_path.default.dirname(require.resolve(plugin2)),
|
1164
|
-
"**/*.{js,ts,jsx,tsx}"
|
1165
|
-
);
|
1166
|
-
pluginExtensions.push(pluginPath);
|
1167
|
-
} catch (_e) {
|
1168
|
-
}
|
1169
|
-
}
|
1170
|
-
const config = {
|
1171
|
-
presets: [require_dist()],
|
1172
|
-
content: [
|
1173
|
-
html,
|
1174
|
-
root,
|
1175
|
-
dashboard,
|
1176
|
-
ui,
|
1177
|
-
...sourceExtensions,
|
1178
|
-
...pluginExtensions
|
1179
|
-
],
|
1180
|
-
darkMode: "class"
|
1181
|
-
};
|
1182
|
-
return config;
|
1183
|
-
}
|
1184
|
-
|
1185
|
-
// src/utils/write-static-files.ts
|
1186
|
-
var import_promises = require("fs/promises");
|
1187
|
-
var import_node_path2 = require("path");
|
1188
|
-
var import_outdent = __toESM(require("outdent"));
|
1189
|
-
async function writeStaticFiles(plugins) {
|
1190
|
-
const outDir = (0, import_node_path2.join)(process.cwd(), ".medusa/client");
|
1191
|
-
await (0, import_promises.mkdir)(outDir, { recursive: true });
|
1192
|
-
const promises = [
|
1193
|
-
writeCSSFile(outDir),
|
1194
|
-
writeEntryFile(outDir, plugins),
|
1195
|
-
writeHTMLFile(outDir)
|
1196
|
-
];
|
1197
|
-
await Promise.all(promises);
|
1198
|
-
}
|
1199
|
-
async function writeCSSFile(outDir) {
|
1200
|
-
const css = import_outdent.default`
|
1201
|
-
@import "@medusajs/dashboard/css";
|
1202
|
-
|
1203
|
-
@tailwind base;
|
1204
|
-
@tailwind components;
|
1205
|
-
@tailwind utilities;
|
1206
|
-
`;
|
1207
|
-
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "index.css"), css);
|
1208
|
-
}
|
1209
|
-
function getPluginName(index) {
|
1210
|
-
return `plugin${index}`;
|
1211
|
-
}
|
1212
|
-
async function writeEntryFile(outDir, plugins) {
|
1213
|
-
const entry = import_outdent.default`
|
1214
|
-
import App from "@medusajs/dashboard";
|
1215
|
-
import React from "react";
|
1216
|
-
import ReactDOM from "react-dom/client";
|
1217
|
-
import "./index.css";
|
1218
|
-
|
1219
|
-
${plugins?.map((plugin2, idx) => `import ${getPluginName(idx)} from "${plugin2}"`).join("\n")}
|
1220
|
-
|
1221
|
-
let root = null
|
1222
|
-
|
1223
|
-
if (!root) {
|
1224
|
-
root = ReactDOM.createRoot(document.getElementById("medusa"))
|
1225
|
-
}
|
1226
|
-
|
1227
|
-
|
1228
|
-
root.render(
|
1229
|
-
<React.StrictMode>
|
1230
|
-
<App plugins={[${plugins?.map((_, idx) => getPluginName(idx)).join(", ")}]} />
|
1231
|
-
</React.StrictMode>
|
1232
|
-
)
|
1233
|
-
|
1234
|
-
|
1235
|
-
if (import.meta.hot) {
|
1236
|
-
import.meta.hot.accept()
|
1237
|
-
}
|
1238
|
-
`;
|
1239
|
-
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "entry.jsx"), entry);
|
1240
|
-
}
|
1241
|
-
async function writeHTMLFile(outDir) {
|
1242
|
-
const html = import_outdent.default`
|
1243
|
-
<!DOCTYPE html>
|
1244
|
-
<html>
|
1245
|
-
<head>
|
1246
|
-
<meta
|
1247
|
-
http-equiv="Content-Type"
|
1248
|
-
content="text/html; charset=UTF-8"
|
1249
|
-
/>
|
1250
|
-
<meta
|
1251
|
-
name="viewport"
|
1252
|
-
content="width=device-width, initial-scale=1, user-scalable=no"
|
1253
|
-
/>
|
1254
|
-
<link rel="icon" href="data:," data-placeholder-favicon />
|
1255
|
-
</head>
|
1256
|
-
|
1257
|
-
<body>
|
1258
|
-
<div id="medusa"></div>
|
1259
|
-
<script type="module" src="./entry.jsx"></script>
|
1260
|
-
</body>
|
1261
|
-
</html>
|
1262
|
-
`;
|
1263
|
-
await (0, import_promises.writeFile)((0, import_node_path2.join)(outDir, "index.html"), html);
|
1264
|
-
}
|
1265
|
-
|
1266
|
-
// src/plugins/write-static-files.ts
|
1267
|
-
var writeStaticFiles2 = (options) => {
|
1268
|
-
return {
|
1269
|
-
name: "medusa:write-static-files",
|
1270
|
-
buildStart: async (ctx) => {
|
1271
|
-
await writeStaticFiles(options.plugins);
|
1272
|
-
}
|
1273
|
-
};
|
1274
|
-
};
|
1275
|
-
|
1276
|
-
// src/utils/config.ts
|
1277
1114
|
async function getViteConfig(options) {
|
1278
1115
|
const { searchForWorkspaceRoot, mergeConfig } = await import("vite");
|
1279
1116
|
const { default: react } = await import("@vitejs/plugin-react");
|
1280
1117
|
const { default: medusa } = await import("@medusajs/admin-vite-plugin");
|
1281
1118
|
const getPort = await import("get-port");
|
1282
1119
|
const hmrPort = await getPort.default();
|
1283
|
-
const root = import_path.default.resolve(
|
1120
|
+
const root = import_path.default.resolve(__dirname, "./");
|
1284
1121
|
const backendUrl = options.backendUrl ?? "";
|
1285
1122
|
const storefrontUrl = options.storefrontUrl ?? "";
|
1286
1123
|
const baseConfig = {
|
@@ -1316,15 +1153,16 @@ async function getViteConfig(options) {
|
|
1316
1153
|
port: hmrPort
|
1317
1154
|
}
|
1318
1155
|
},
|
1156
|
+
css: {
|
1157
|
+
postcss: {
|
1158
|
+
plugins: [
|
1159
|
+
require("tailwindcss")({
|
1160
|
+
config: createTailwindConfig(root, options.sources)
|
1161
|
+
})
|
1162
|
+
]
|
1163
|
+
}
|
1164
|
+
},
|
1319
1165
|
plugins: [
|
1320
|
-
writeStaticFiles2({
|
1321
|
-
plugins: options.plugins
|
1322
|
-
}),
|
1323
|
-
injectTailwindCSS({
|
1324
|
-
entry: root,
|
1325
|
-
sources: options.sources,
|
1326
|
-
plugins: options.plugins
|
1327
|
-
}),
|
1328
1166
|
react(),
|
1329
1167
|
medusa({
|
1330
1168
|
sources: options.sources
|
@@ -1337,8 +1175,35 @@ async function getViteConfig(options) {
|
|
1337
1175
|
}
|
1338
1176
|
return baseConfig;
|
1339
1177
|
}
|
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
|
+
}
|
1340
1205
|
|
1341
|
-
// src/
|
1206
|
+
// src/lib/build.ts
|
1342
1207
|
async function build(options) {
|
1343
1208
|
const vite = await import("vite");
|
1344
1209
|
const viteConfig = await getViteConfig(options);
|
@@ -1349,7 +1214,7 @@ async function build(options) {
|
|
1349
1214
|
await vite.build(vite.mergeConfig(viteConfig, buildConfig));
|
1350
1215
|
}
|
1351
1216
|
|
1352
|
-
// src/
|
1217
|
+
// src/lib/develop.ts
|
1353
1218
|
var import_express = __toESM(require("express"));
|
1354
1219
|
var import_fs = __toESM(require("fs"));
|
1355
1220
|
var import_path2 = __toESM(require("path"));
|
@@ -1420,30 +1285,24 @@ async function develop(options) {
|
|
1420
1285
|
return router;
|
1421
1286
|
}
|
1422
1287
|
|
1423
|
-
// src/
|
1288
|
+
// src/lib/plugin.ts
|
1424
1289
|
var import_fs2 = require("fs");
|
1425
|
-
var
|
1290
|
+
var import_promises = require("fs/promises");
|
1291
|
+
var import_glob = require("glob");
|
1426
1292
|
var import_path3 = __toESM(require("path"));
|
1427
|
-
|
1428
|
-
// src/plugins/clear-plugin-build.ts
|
1429
|
-
var import_promises2 = require("fs/promises");
|
1430
|
-
var import_node_path3 = __toESM(require("path"));
|
1431
|
-
var clearPluginBuild = (options) => ({
|
1432
|
-
name: "medusa:clear-plugin-build",
|
1433
|
-
buildStart: async () => {
|
1434
|
-
const adminDir = import_node_path3.default.join(options.outDir, "admin");
|
1435
|
-
try {
|
1436
|
-
await (0, import_promises2.rm)(adminDir, { recursive: true, force: true });
|
1437
|
-
} catch (e) {
|
1438
|
-
}
|
1439
|
-
}
|
1440
|
-
});
|
1441
|
-
|
1442
|
-
// src/commands/plugin.ts
|
1443
1293
|
async function plugin(options) {
|
1444
1294
|
const vite = await import("vite");
|
1445
1295
|
const react = (await import("@vitejs/plugin-react")).default;
|
1446
|
-
const
|
1296
|
+
const { nodeResolve } = await import("@rollup/plugin-node-resolve");
|
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
|
+
}, {});
|
1447
1306
|
const pkg = JSON.parse(
|
1448
1307
|
(0, import_fs2.readFileSync)(import_path3.default.resolve(options.root, "package.json"), "utf-8")
|
1449
1308
|
);
|
@@ -1452,62 +1311,51 @@ async function plugin(options) {
|
|
1452
1311
|
...Object.keys(pkg.peerDependencies || {}),
|
1453
1312
|
...Object.keys(pkg.devDependencies || {}),
|
1454
1313
|
"react",
|
1314
|
+
"react-dom",
|
1455
1315
|
"react/jsx-runtime",
|
1456
1316
|
"react-router-dom",
|
1457
|
-
"@medusajs/js-sdk",
|
1458
1317
|
"@medusajs/admin-sdk",
|
1459
1318
|
"@tanstack/react-query"
|
1460
1319
|
]);
|
1461
|
-
const outDir = import_path3.default.resolve(options.root, options.outDir, "src/admin");
|
1462
|
-
const entryPoint = import_path3.default.resolve(
|
1463
|
-
options.root,
|
1464
|
-
"src/admin/__admin-extensions__.js"
|
1465
|
-
);
|
1466
1320
|
const originalNodeEnv = process.env.NODE_ENV;
|
1467
1321
|
process.env.NODE_ENV = "production";
|
1468
1322
|
const pluginConfig = {
|
1469
1323
|
build: {
|
1470
1324
|
lib: {
|
1471
|
-
entry:
|
1472
|
-
formats: ["es"
|
1473
|
-
fileName: "index"
|
1325
|
+
entry: entryPoints,
|
1326
|
+
formats: ["es"]
|
1474
1327
|
},
|
1475
1328
|
emptyOutDir: false,
|
1476
1329
|
minify: false,
|
1477
|
-
outDir,
|
1330
|
+
outDir: import_path3.default.resolve(options.root, options.outDir),
|
1478
1331
|
rollupOptions: {
|
1479
|
-
|
1480
|
-
|
1481
|
-
const idParts2 = id.split("/");
|
1482
|
-
const name2 = idParts2[0]?.startsWith("@") ? `${idParts2[0]}/${idParts2[1]}` : idParts2[0];
|
1483
|
-
const builtinModulesWithNodePrefix = [
|
1484
|
-
...import_node_module.builtinModules,
|
1485
|
-
...import_node_module.builtinModules.map((modName) => `node:${modName}`)
|
1486
|
-
];
|
1487
|
-
return Boolean(
|
1488
|
-
name2 && external.has(name2) || name2 && builtinModulesWithNodePrefix.includes(name2)
|
1489
|
-
);
|
1490
|
-
}
|
1491
|
-
const idParts = id.split("/");
|
1492
|
-
const name = idParts[0]?.startsWith("@") ? `${idParts[0]}/${idParts[1]}` : idParts[0];
|
1493
|
-
return Boolean(name && external.has(name));
|
1494
|
-
},
|
1332
|
+
plugins: [nodeResolve()],
|
1333
|
+
external: [...external, /node_modules/],
|
1495
1334
|
output: {
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1335
|
+
globals: {
|
1336
|
+
react: "React",
|
1337
|
+
"react-dom": "React-dom",
|
1338
|
+
"react/jsx-runtime": "react/jsx-runtime"
|
1339
|
+
},
|
1340
|
+
preserveModules: true,
|
1341
|
+
entryFileNames: (chunkInfo) => {
|
1342
|
+
return `${chunkInfo.name.replace(`${options.root}/`, "")}.js`;
|
1500
1343
|
}
|
1501
1344
|
}
|
1502
1345
|
}
|
1503
1346
|
},
|
1504
1347
|
plugins: [
|
1505
1348
|
react(),
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1349
|
+
{
|
1350
|
+
name: "clear-admin-plugin",
|
1351
|
+
buildStart: async () => {
|
1352
|
+
const adminDir = import_path3.default.join(options.root, options.outDir, "admin");
|
1353
|
+
try {
|
1354
|
+
await (0, import_promises.rm)(adminDir, { recursive: true, force: true });
|
1355
|
+
} catch (e) {
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
}
|
1511
1359
|
],
|
1512
1360
|
logLevel: "silent",
|
1513
1361
|
clearScreen: false
|
@@ -1516,7 +1364,7 @@ async function plugin(options) {
|
|
1516
1364
|
process.env.NODE_ENV = originalNodeEnv;
|
1517
1365
|
}
|
1518
1366
|
|
1519
|
-
// src/
|
1367
|
+
// src/lib/serve.ts
|
1520
1368
|
var import_compression = __toESM(require("compression"));
|
1521
1369
|
var import_express2 = require("express");
|
1522
1370
|
var import_fs3 = __toESM(require("fs"));
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/admin-bundler",
|
3
|
-
"version": "2.6.2-snapshot-
|
3
|
+
"version": "2.6.2-snapshot-20250311083444",
|
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 && copyfiles -f ./src/index.html ./src/entry.tsx ./src/index.css ./dist"
|
8
8
|
},
|
9
9
|
"main": "./dist/index.js",
|
10
10
|
"types": "./dist/index.d.ts",
|
@@ -18,26 +18,30 @@
|
|
18
18
|
"package.json"
|
19
19
|
],
|
20
20
|
"devDependencies": {
|
21
|
-
"@medusajs/types": "2.6.2-snapshot-
|
21
|
+
"@medusajs/types": "2.6.2-snapshot-20250311083444",
|
22
22
|
"@types/compression": "^1.7.5",
|
23
|
+
"copyfiles": "^2.4.1",
|
23
24
|
"express": "^4.21.0",
|
24
25
|
"tsup": "^8.0.1",
|
25
26
|
"typescript": "^5.3.3"
|
26
27
|
},
|
27
28
|
"dependencies": {
|
28
|
-
"@medusajs/admin-shared": "2.6.2-snapshot-
|
29
|
-
"@medusajs/admin-vite-plugin": "2.6.2-snapshot-
|
30
|
-
"@medusajs/dashboard": "2.6.2-snapshot-
|
29
|
+
"@medusajs/admin-shared": "2.6.2-snapshot-20250311083444",
|
30
|
+
"@medusajs/admin-vite-plugin": "2.6.2-snapshot-20250311083444",
|
31
|
+
"@medusajs/dashboard": "2.6.2-snapshot-20250311083444",
|
32
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
31
33
|
"@vitejs/plugin-react": "^4.2.1",
|
32
34
|
"autoprefixer": "^10.4.16",
|
33
35
|
"compression": "^1.7.4",
|
34
36
|
"express": "^4.21.0",
|
35
37
|
"get-port": "^5.1.1",
|
36
38
|
"glob": "^10.3.10",
|
37
|
-
"outdent": "^0.8.0",
|
38
39
|
"postcss": "^8.4.32",
|
39
40
|
"tailwindcss": "^3.3.6",
|
40
41
|
"vite": "^5.4.14"
|
41
42
|
},
|
43
|
+
"peerDependencies": {
|
44
|
+
"react-dom": "^18.0.0"
|
45
|
+
},
|
42
46
|
"packageManager": "yarn@3.2.1"
|
43
47
|
}
|