Skip to content

Commit c49bd78

Browse files
litlighilitCopilot
andcommitted
feat(build): --app:lib for js to gen esModule
Co-authored-by: Copilot <copilot@github.com>
1 parent dee5406 commit c49bd78

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎npython/Python/jspython.nim‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ when isMain(nodejs or deno):
1414
else:
1515
when isMain(dKarax):
1616
import ./karaxpython
17-
elif isMainModule:
17+
elif isMainModule and appType != "lib":
1818
import ./lifecycle
1919
Py_Initialize()
2020
mayWaitFor interactiveShell()

‎npython/Utils/nexportcImpl.nim‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ proc newLibPragmas(old_pragma: NimNode): NimNode =
1818
old_pragma.copyNimTree
1919
else: newNimNode nnkPragma
2020
pragmas.add ident"exportc"
21+
when defined(js) and defined(esModule) and appType != "lib":
22+
pragmas.add nnkExprColonExpr.newTree(
23+
ident"codeGenDecl", newLit"export function $# $#($#)"
24+
)
2125
pragmas.add ident"dynlib"
2226
pragmas.add ident"cdecl"
2327
pragmas

0 commit comments

Comments
 (0)