@medusajs/admin-bundler 2.23.1 → 2.23.2-snapshot-20261127103409

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/AGENTS.md CHANGED
@@ -7,7 +7,7 @@ Builds and serves the Medusa Admin for an application, and builds the admin exte
7
7
  Not imported by app code. The Medusa CLI calls it:
8
8
 
9
9
  - `develop(options)`: Vite dev server in middleware mode, returned as an Express router. Used by `packages/medusa/src/loaders/admin.ts` in development.
10
- - `serve({ outDir })`: serves a prebuilt admin with long-lived cache headers and an SPA fallback. Throws if `index.html` is missing ("run 'medusa build'").
10
+ - `serve({ outDir, htmlHeaders })`: serves a prebuilt admin with long-lived cache headers and an SPA fallback. Throws if `index.html` is missing ("run 'medusa build'"). `admin.htmlHeaders` sets any headers on the HTML only, not on the static files, replacing only the ones it names (e.g. `http.securityHeaders`' CSP; the framework's other headers stay); `develop` ignores it.
11
11
  - `build(options)`: production build. Called from `packages/core/framework/src/build-tools/compiler.ts` (`medusa build`).
12
12
  - `plugin({ root, outDir })`: library build of a plugin's `src/admin` into `<outDir>/src/admin` (`medusa plugin:build`).
13
13
 
package/dist/index.d.ts CHANGED
@@ -8,6 +8,15 @@ type BundlerOptions = Required<Pick<AdminOptions, "path">> & Pick<AdminOptions,
8
8
  };
9
9
 
10
10
  declare function build(options: BundlerOptions): Promise<void>;
11
+ /**
12
+ * Builds the application as one Vite app: the admin dashboard is the client
13
+ * environment, and `buildServer` builds the backend after it. Not in
14
+ * parallel: bundling the backend can take several GB of memory on its own,
15
+ * more than build machines have to spare for both at once.
16
+ */
17
+ declare function buildApp(options: BundlerOptions, { buildServer }: {
18
+ buildServer: () => Promise<void>;
19
+ }): Promise<void>;
11
20
 
12
21
  declare function develop(options: BundlerOptions): Promise<IRouter>;
13
22
 
@@ -19,8 +28,9 @@ declare function plugin(options: PluginOptions): Promise<void>;
19
28
 
20
29
  type ServeOptions = {
21
30
  outDir: string;
31
+ htmlHeaders?: Record<string, string>;
22
32
  };
23
33
  declare function serve(options: ServeOptions): Promise<IRouter>;
24
34
 
25
- export { build, develop, plugin, serve };
35
+ export { build, buildApp, develop, plugin, serve };
26
36
  export type { BundlerOptions };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  build: () => build,
34
+ buildApp: () => buildApp,
34
35
  develop: () => develop,
35
36
  plugin: () => plugin,
36
37
  serve: () => serve
@@ -334,6 +335,24 @@ async function build(options) {
334
335
  };
335
336
  await vite.build(vite.mergeConfig(viteConfig, buildConfig));
336
337
  }
338
+ async function buildApp(options, { buildServer }) {
339
+ const vite = await import("vite");
340
+ const viteConfig = await getViteConfig(options);
341
+ const buildConfig = {
342
+ mode: "production",
343
+ logLevel: "error",
344
+ builder: {
345
+ async buildApp(builder2) {
346
+ await builder2.build(builder2.environments.client);
347
+ await buildServer();
348
+ }
349
+ }
350
+ };
351
+ const builder = await vite.createBuilder(
352
+ vite.mergeConfig(viteConfig, buildConfig)
353
+ );
354
+ await builder.buildApp();
355
+ }
337
356
 
338
357
  // src/commands/develop.ts
339
358
  var import_express = __toESM(require("express"));
@@ -358,8 +377,8 @@ function findTemplateFilePath(reqPath, root) {
358
377
  }
359
378
  return void 0;
360
379
  }
361
- async function injectViteMiddleware(router3, middleware) {
362
- router3.use((req, res, next) => {
380
+ async function injectViteMiddleware(router2, middleware) {
381
+ router2.use((req, res, next) => {
363
382
  if (req.path.toLowerCase().startsWith("/__open-in-editor")) {
364
383
  res.status(403).end();
365
384
  return;
@@ -367,8 +386,8 @@ async function injectViteMiddleware(router3, middleware) {
367
386
  req.path.endsWith(".html") ? next() : middleware(req, res, next);
368
387
  });
369
388
  }
370
- async function injectHtmlMiddleware(router3, server) {
371
- router3.use(async (req, res, next) => {
389
+ async function injectHtmlMiddleware(router2, server) {
390
+ router2.use(async (req, res, next) => {
372
391
  if (req.method !== "GET") {
373
392
  return next();
374
393
  }
@@ -511,8 +530,8 @@ var import_compression = __toESM(require("compression"));
511
530
  var import_express2 = require("express");
512
531
  var import_fs3 = __toESM(require("fs"));
513
532
  var import_path4 = __toESM(require("path"));
514
- var router2 = (0, import_express2.Router)();
515
533
  async function serve(options) {
534
+ const router2 = (0, import_express2.Router)();
516
535
  const htmlPath = import_path4.default.resolve(options.outDir, "index.html");
517
536
  const indexExists = import_fs3.default.existsSync(htmlPath);
518
537
  if (!indexExists) {
@@ -524,6 +543,9 @@ async function serve(options) {
524
543
  const sendHtml = (_req, res) => {
525
544
  res.setHeader("Cache-Control", "no-cache");
526
545
  res.setHeader("Vary", "Origin, Cache-Control");
546
+ for (const [name, value] of Object.entries(options.htmlHeaders ?? {})) {
547
+ res.setHeader(name, value);
548
+ }
527
549
  res.send(html);
528
550
  };
529
551
  const setStaticHeaders = (res) => {
@@ -543,6 +565,7 @@ async function serve(options) {
543
565
  // Annotate the CommonJS export names for ESM import in node:
544
566
  0 && (module.exports = {
545
567
  build,
568
+ buildApp,
546
569
  develop,
547
570
  plugin,
548
571
  serve
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/admin-bundler",
3
- "version": "2.23.1",
3
+ "version": "2.23.2-snapshot-20261127103409",
4
4
  "description": "Bundler for the Medusa admin dashboard.",
5
5
  "author": "Kasper Kristensen <kasper@medusajs.com>",
6
6
  "scripts": {
@@ -26,13 +26,13 @@
26
26
  "llmsFull": "https://docs.medusajs.com/llms-full.txt",
27
27
  "mcpServer": "https://docs.medusajs.com/mcp",
28
28
  "devDependencies": {
29
- "@medusajs/types": "2.23.1"
29
+ "@medusajs/types": "2.23.2-snapshot-20261127103409"
30
30
  },
31
31
  "dependencies": {
32
- "@medusajs/admin-shared": "2.23.1",
33
- "@medusajs/admin-vite-plugin": "2.23.1",
34
- "@medusajs/dashboard": "2.23.1",
35
- "@medusajs/ui-preset": "2.23.1",
32
+ "@medusajs/admin-shared": "2.23.2-snapshot-20261127103409",
33
+ "@medusajs/admin-vite-plugin": "2.23.2-snapshot-20261127103409",
34
+ "@medusajs/dashboard": "2.23.2-snapshot-20261127103409",
35
+ "@medusajs/ui-preset": "2.23.2-snapshot-20261127103409",
36
36
  "@tailwindcss/vite": "^4.3.5",
37
37
  "@vitejs/plugin-react": "^6.3.0",
38
38
  "compression": "^1.8.2",