arkos 1.2.26-test → 1.2.28-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js +7 -0
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/esm/app.js +1 -1
- package/dist/esm/server.js +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/helpers/global.helpers.js +7 -0
- package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
- package/package.json +2 -2
|
@@ -42,6 +42,8 @@ exports.importModule = importModule;
|
|
|
42
42
|
exports.detectPackageManagerFromUserAgent = detectPackageManagerFromUserAgent;
|
|
43
43
|
const fs_1 = __importDefault(require("fs"));
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const module_1 = require("module");
|
|
46
|
+
const url_1 = require("url");
|
|
45
47
|
function getPackageJson() {
|
|
46
48
|
try {
|
|
47
49
|
const pkgPath = path_1.default.join(process.cwd(), "package.json");
|
|
@@ -72,6 +74,11 @@ async function importModule(modulePath, options = { fixExtension: true }) {
|
|
|
72
74
|
correctedPath = modulePath + ".js";
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
if (!options.fixExtension)
|
|
78
|
+
return await Promise.resolve(`${modulePath}`).then(s => __importStar(require(s)));
|
|
79
|
+
const userRequire = (0, module_1.createRequire)((0, url_1.pathToFileURL)(process.cwd() + "/package.json"));
|
|
80
|
+
const resolved = userRequire.resolve(modulePath);
|
|
81
|
+
return await Promise.resolve(`${(0, url_1.pathToFileURL)(resolved)}`).then(s => __importStar(require(s)));
|
|
75
82
|
return await Promise.resolve(`${correctedPath}`).then(s => __importStar(require(s)));
|
|
76
83
|
}
|
|
77
84
|
function detectPackageManagerFromUserAgent() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wCASC;AAED,sBAGC;AAED,oCAkCC;AAQD,8EAaC;AA5ED,4CAAoB;AACpB,gDAAwB;AACxB,mCAAuC;AACvC,6BAAoC;AAEpC,SAAgB,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,SAAgB,KAAK;IACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,UAAqC,EAAE,YAAY,EAAE,IAAI,EAAE;IAG3D,IAAI,aAAa,GAAG,UAAU,CAAC;IAE/B,IACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE;QACP,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;QAC1B,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC3B,CAAC;QACD,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAA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AU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n if (!options.fixExtension) return await import(modulePath);\n\n // When importing user modules:\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n\n return await import(correctedPath);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|
package/dist/esm/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router";import h from"./modules/error-handler/error-handler.controller";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router";import{queryParser as g}from"./utils/helpers/query-parser.helpers";import d from"./utils/helpers/deepmerge.helper";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
|
|
1
|
+
"use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router.js";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router.js";import h from"./modules/error-handler/error-handler.controller.js";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares.js";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers.js";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router.js";import{queryParser as g}from"./utils/helpers/query-parser.helpers.js";import d from"./utils/helpers/deepmerge.helper.js";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router.js";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
|
package/dist/esm/server.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{bootstrap as a}from"./app";import p from"./utils/helpers/deepmerge.helper";import c from"http";import s from"./utils/sheu";import{initializePrismaModels as l}from"./utils/helpers/models.helpers";process.on("uncaughtException",o=>{o.message.includes("EPIPE")||(console.error(`
|
|
1
|
+
"use strict";import{bootstrap as a}from"./app.js";import p from"./utils/helpers/deepmerge.helper.js";import c from"http";import s from"./utils/sheu.js";import{initializePrismaModels as l}from"./utils/helpers/models.helpers.js";process.on("uncaughtException",o=>{o.message.includes("EPIPE")||(console.error(`
|
|
2
2
|
UNCAUGHT EXCEPTION! SHUTTING DOWN...
|
|
3
3
|
`),console.error(o.name,o.message),console.error(o),process.exit(1))});let r,t,e={welcomeMessage:"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com",port:Number(process.env.CLI_PORT)||Number(process.env.PORT)||8e3,host:process.env.CLI_HOST||process.env.HOST||"localhost",fileUpload:{baseUploadDir:"uploads",baseRoute:"/api/uploads"},available:!1};async function u(o={}){l(),e.available=!0,e=p(e,o);const n=process.env.CLI_PORT||e.port||process.env.PORT||"port"in e?e.port:8e3;t=await a(e);const i=new Date().toTimeString().split(" ")[0];return n?(r=c.createServer(t),e?.configureServer&&await e.configureServer(r),r.listen(Number(n),e.host,()=>{s.ready(`${s.gray(i)} server waiting on http://${e.host||"localhost"}:${n}`)})):s.warn(`${s.gray(i)} port set to undefined, hence no internal http server was setup.`),t}process.on("unhandledRejection",o=>{console.error("UNHANDLED REJECTION! SHUTTING DOWN..."),console.error(o.name,o.message),console.error(o),r?.close(()=>{process.exit(1)})});export function terminateApplicationRunningProcessAndServer(){r?.close(()=>{process.exit(1)})}export function getArkosConfig(){return e}export function getExpressApp(){return t}export{r as server,u as initApp};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
3
5
|
export function getPackageJson() {
|
|
4
6
|
try {
|
|
5
7
|
const pkgPath = path.join(process.cwd(), "package.json");
|
|
@@ -30,6 +32,11 @@ export async function importModule(modulePath, options = { fixExtension: true })
|
|
|
30
32
|
correctedPath = modulePath + ".js";
|
|
31
33
|
}
|
|
32
34
|
}
|
|
35
|
+
if (!options.fixExtension)
|
|
36
|
+
return await import(modulePath);
|
|
37
|
+
const userRequire = createRequire(pathToFileURL(process.cwd() + "/package.json"));
|
|
38
|
+
const resolved = userRequire.resolve(modulePath);
|
|
39
|
+
return await import(pathToFileURL(resolved));
|
|
33
40
|
return await import(correctedPath);
|
|
34
41
|
}
|
|
35
42
|
export function detectPackageManagerFromUserAgent() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,EAA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,CAAC,QAAQ,CAAQ,CAAC,CAAC;IAEpD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAQD,MAAM,UAAU,iCAAiC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n if (!options.fixExtension) return await import(modulePath);\n\n // When importing user modules:\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n\n return await import(correctedPath);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkos",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.28-test",
|
|
4
4
|
"description": "The Express & Prisma Framework For RESTful API",
|
|
5
5
|
"main": "dist/cjs/exports/index.js",
|
|
6
6
|
"module": "dist/esm/exports/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
80
|
+
"build:esm": "tsc -p tsconfig.esm.json && ts-node scripts/fix-esm-imports.ts",
|
|
81
81
|
"build:types": "tsc -p tsconfig.types.json",
|
|
82
82
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
83
83
|
"build": "npx rimraf dist && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types && pnpm run minify && ts-node scripts/post-build-scripts.ts",
|