Skip to content

Commit

Permalink
fix: update alloy main patches
Browse files Browse the repository at this point in the history
  • Loading branch information
janvennemann committed Nov 26, 2023
1 parent 61f0ccf commit b6688c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/node/plugins/alloy/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,21 @@ export function corePlugin(ctx: AlloyContext, platform: Platform): Plugin {
}

/**
* Applies various patches in the given content to be compatible Vite.
* Applies various patches in the given content to be compatible with Vite.
*
* @param content File content to modify
*/
function patchForViteCompatibility(content: string) {
// requires for controllers need to use `.default`
content = requireDefaultExport(content, appControllerRequestPattern);
content = requireDefaultExport(content, widgetControllerRequestPattern);
// FIXME: Re-enable once we can control ESM mode per project
// content = requireDefaultExport(content, appControllerRequestPattern);
// content = requireDefaultExport(content, widgetControllerRequestPattern);

content = content
// remove ucfirst in model/collection requires
.replace(/models\/'\s\+\sucfirst\(name\)/g, "models/' + name")
// remove double slash in controller requires
.replace(/(controllers\/' \+ \(?)(name)/, "$1$2.replace(/^\\//, '')");
.replace(/(controllers\/' \+ \(?)(name)/g, "$1$2?.replace(/^\\//, '')");

return content;
}
Expand Down

0 comments on commit b6688c9

Please sign in to comment.