Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Dependencies
# Dependencies
.medusa
node_modules/
package-lock.json
.yarn/
yarn.lock
.yalc
yalc.lock

Expand Down
13 changes: 7 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ Project skills are in `.ai/skills/` (symlinked to `.cursor/skills/` and `.codex/

## Rules for Agents

1. Always run `yarn format` before committing.
2. Follow the branch model: feature work from `develop`, PRs to `develop`.
3. Add a changeset (`yarn changeset`) for any user-facing change.
4. Use consistent terminology: `system`, `db`, `external`, `blocks`, `mpn-builder`, `workflow`.
5. When changing docs, follow the `docs` skill.
6. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts.
1. Never run `yarn install`, `yarn dev`, `medusa develop`, or other long-running/dependency-install commands on the user's behalf, in this repo or in sibling repos (`vending-plugin`, `app/apps/venloop`, `storefront`) — the user runs these themselves to save tokens. Tell them what to run and what to check instead.
2. Always run `yarn format` before committing.
3. Follow the branch model: feature work from `develop`, PRs to `develop`.
4. Add a changeset (`yarn changeset`) for any user-facing change.
5. Use consistent terminology: `system`, `db`, `external`, `blocks`, `mpn-builder`, `workflow`.
6. When changing docs, follow the `docs` skill.
7. Do not commit `.env`, `node_modules`, `.medusa/`, or build artifacts.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @codee-sh/medusa-plugin-notification-emails

## 1.0.4

### Patch Changes

- Support registering external templates via a directly-imported module object (`template.module`), not just a resolvable file path (`template.path`). Lets host apps register a template that lives locally (not published as its own package) by statically importing it and passing the module in `extend.services[].templates[].module`.

## 1.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codee-sh/medusa-plugin-notification-emails",
"version": "1.0.2",
"version": "1.0.4",
"description": "Medusa plugin for notifications emails.",
"author": "Codee Team (https://codee.dev)",
"license": "MIT",
Expand Down
20 changes: 13 additions & 7 deletions src/modules/mpn-builder/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,25 @@ class MpnBuilderService extends MedusaService({
async (template: any) => {
const templateName = template.name
const templateValue = template.path
const templateModule_ = template.module

let renderer = templateValue

try {
const templateModule = await import(
templateValue
)
renderer =
templateModule?.default || templateModule
let rawModule: any

if (templateModule_) {
rawModule = templateModule_
} else {
const imported = await import(templateValue)
rawModule = imported?.default || imported
}

renderer = rawModule

if (!renderer) {
this.logger_.warn(
`Template module from "${templateValue}" does not export a default function or expected named export`
`Template module from "${templateValue ?? "module"}" does not export a default function or expected named export`
)
return
}
Expand All @@ -136,7 +142,7 @@ class MpnBuilderService extends MedusaService({
)
} catch (error: any) {
this.logger_.warn(
`Failed to load template from "${templateValue}": ${error?.message || "Unknown error"}`
`Failed to load template from "${templateValue ?? "module"}": ${error?.message || "Unknown error"}`
)
return
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/mpn-builder/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export type ModuleOptions = {
id: string
templates?: Array<{
name: string
path: string
path?: string
module?: Record<string, any>
}>
}>
}
Expand Down
Loading