Skip to content

Commit

Permalink
refactor: remove import of admin-bundler and accept it as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 10, 2025
1 parent bb1b463 commit 99ab2fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions packages/core/framework/src/build-tools/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path"
import type tsStatic from "typescript"
import { getConfigFile } from "@medusajs/utils"
import type { ConfigModule, Logger } from "@medusajs/types"
import { access, constants, copyFile, rm } from "fs/promises"
import type { AdminOptions, ConfigModule, Logger } from "@medusajs/types"

/**
* The compiler exposes the opinionated APIs for compiling Medusa
Expand Down Expand Up @@ -299,7 +299,14 @@ export class Compiler {
*/
async buildAppFrontend(
adminOnly: boolean,
tsConfig: tsStatic.ParsedCommandLine
adminBundler: {
build: (
options: AdminOptions & {
sources: string[]
outDir: string
}
) => Promise<void>
}
): Promise<boolean> {
const tracker = this.#trackDuration()

Expand Down Expand Up @@ -335,10 +342,7 @@ export class Compiler {

try {
this.#logger.info("Compiling frontend source...")
const { build: buildProductionBuild } = await import(
"@medusajs/admin-bundler"
)
await buildProductionBuild({
await adminBundler.build({
disable: false,
sources: [this.#adminSourceFolder],
...configFile.configModule.admin,
Expand Down
3 changes: 2 additions & 1 deletion packages/medusa/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default async function build({
promises.push(compiler.buildAppBackend(tsConfig))
}

promises.push(compiler.buildAppFrontend(adminOnly, tsConfig))
const bundler = await import("@medusajs/admin-bundler")
promises.push(compiler.buildAppFrontend(adminOnly, bundler))
await Promise.all(promises)
return true
}

0 comments on commit 99ab2fa

Please sign in to comment.