This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/scripts/web_api_esm.py

30 lines
780 B
Python

"""Enable ESM Modules for generated Web API"""
from json import loads, dumps
TSCONFIG_ESM = {
"compilerOptions": {
"declaration": True,
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"outDir": "./dist/esm",
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"dist",
"node_modules"
]
}
with open("web-api/package.json", encoding="utf-8") as _package:
package = loads(_package.read())
package["module"] = "./dist/esm/index.js"
package["sideEffects"] = False
package["scripts"]["build"] = "tsc && tsc --project tsconfig.esm.json"
open("web-api/package.json", "w+", encoding="utf-8").write(dumps(package))
open("web-api/tsconfig.esm.json", "w+", encoding="utf-8").write(dumps(TSCONFIG_ESM))