Build system work
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thilawyn/schemable-classes",
|
"name": "@thilawyn/schemable-class",
|
||||||
"version": "20231230.0.0",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://git.jvalver.de/api/packages/thilawyn/npm/"
|
"registry": "https://git.jvalver.de/api/packages/thilawyn/npm/"
|
||||||
@@ -31,14 +31,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "rollup -c rollup.config.ts",
|
||||||
"lint:tsc": "tsc --noEmit",
|
"lint:tsc": "tsc --noEmit",
|
||||||
"clean:cache": "rm -f tsconfig.tsbuildinfo",
|
"clean:cache": "rm -f tsconfig.tsbuildinfo",
|
||||||
"clean:dist": "rm -rf dist",
|
"clean:dist": "rm -rf dist",
|
||||||
"clean:node": "rm -rf node_modules"
|
"clean:node": "rm -rf node_modules"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thilawyn/thilatrait": "^20231230.0.0",
|
|
||||||
"decimal.js": "^10.4.3",
|
"decimal.js": "^10.4.3",
|
||||||
"effect": "^2.0.0-next.62",
|
"effect": "^2.0.0-next.62",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
@@ -46,6 +45,7 @@
|
|||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"bun-types": "latest",
|
"bun-types": "latest",
|
||||||
"npm-check-updates": "^16.14.12",
|
"npm-check-updates": "^16.14.12",
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { defineConfig } from "rollup"
|
|
||||||
import cleanup from "rollup-plugin-cleanup"
|
|
||||||
import ts from "rollup-plugin-ts"
|
|
||||||
import pkg from "./package.json" assert { type: "json" }
|
|
||||||
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
input: "src/index.ts",
|
|
||||||
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: pkg.exports["."].import.default,
|
|
||||||
format: "esm",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: pkg.exports["."].require.default,
|
|
||||||
format: "cjs",
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
file: pkg.exports["./jsonifiable"].import.default,
|
|
||||||
format: "esm",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: pkg.exports["./jsonifiable"].require.default,
|
|
||||||
format: "cjs",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
ts(),
|
|
||||||
|
|
||||||
cleanup({
|
|
||||||
comments: "jsdoc",
|
|
||||||
extensions: ["ts"],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
})
|
|
||||||
43
rollup.config.ts
Normal file
43
rollup.config.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
||||||
|
import { defineConfig } from "rollup"
|
||||||
|
import cleanup from "rollup-plugin-cleanup"
|
||||||
|
import ts from "rollup-plugin-ts"
|
||||||
|
import pkg from "./package.json" assert { type: "json" }
|
||||||
|
|
||||||
|
|
||||||
|
export const createBundleConfig = (
|
||||||
|
input: string,
|
||||||
|
name: keyof typeof pkg.exports,
|
||||||
|
) =>
|
||||||
|
defineConfig({
|
||||||
|
input,
|
||||||
|
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: pkg.exports[name].import.default,
|
||||||
|
format: "esm",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: pkg.exports[name].require.default,
|
||||||
|
format: "cjs",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
external: id => !/^[./]/.test(id),
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
nodeResolve(),
|
||||||
|
ts(),
|
||||||
|
|
||||||
|
cleanup({
|
||||||
|
comments: "jsdoc",
|
||||||
|
extensions: ["ts"],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
export default [
|
||||||
|
createBundleConfig("src/index.ts", "."),
|
||||||
|
createBundleConfig("src/jsonifiable/index.ts", "./jsonifiable"),
|
||||||
|
]
|
||||||
@@ -13,6 +13,14 @@ type NewSchemableArgs<Input extends object> =
|
|||||||
: [] | [Input, ...ParamsArgs]
|
: [] | [Input, ...ParamsArgs]
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of a SchemableClass with default values.
|
||||||
|
*
|
||||||
|
* @param class_ - The SchemableClass.
|
||||||
|
* @param values - The values to be parsed and used to create the instance.
|
||||||
|
* @param params - Optional parameters for parsing.
|
||||||
|
* @returns A new instance of the specified SchemableClass.
|
||||||
|
*/
|
||||||
export const newSchemable = <
|
export const newSchemable = <
|
||||||
C extends SchemableClass<$Config>,
|
C extends SchemableClass<$Config>,
|
||||||
$Config extends SchemableConfig,
|
$Config extends SchemableConfig,
|
||||||
@@ -22,6 +30,15 @@ export const newSchemable = <
|
|||||||
) =>
|
) =>
|
||||||
new class_(class_.schemaWithDefaultValues.parse(values || {}, params)) as InstanceType<C>
|
new class_(class_.schemaWithDefaultValues.parse(values || {}, params)) as InstanceType<C>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of a SchemableClass with default values asynchronously.
|
||||||
|
*
|
||||||
|
* @param class_ - The SchemableClass.
|
||||||
|
* @param values - The values to be parsed and used to create the instance.
|
||||||
|
* @param params - Optional parameters for parsing.
|
||||||
|
* @returns A Promise resolving to a new instance of the specified SchemableClass.
|
||||||
|
*/
|
||||||
export const newSchemablePromise = async <
|
export const newSchemablePromise = async <
|
||||||
C extends SchemableClass<$Config>,
|
C extends SchemableClass<$Config>,
|
||||||
$Config extends SchemableConfig,
|
$Config extends SchemableConfig,
|
||||||
@@ -31,6 +48,15 @@ export const newSchemablePromise = async <
|
|||||||
) =>
|
) =>
|
||||||
new class_(await class_.schemaWithDefaultValues.parseAsync(values || {}, params)) as InstanceType<C>
|
new class_(await class_.schemaWithDefaultValues.parseAsync(values || {}, params)) as InstanceType<C>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of a SchemableClass with default values as an Effect.
|
||||||
|
*
|
||||||
|
* @param class_ - The SchemableClass.
|
||||||
|
* @param values - The values to be parsed and used to create the instance.
|
||||||
|
* @param params - Optional parameters for parsing.
|
||||||
|
* @returns An Effect producing a new instance of the specified SchemableClass.
|
||||||
|
*/
|
||||||
export const newSchemableEffect = <
|
export const newSchemableEffect = <
|
||||||
C extends SchemableClass<$Config>,
|
C extends SchemableClass<$Config>,
|
||||||
$Config extends SchemableConfig,
|
$Config extends SchemableConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user