From 3a2be716b62e0639b258cea292e487778cc196f6 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Sun, 9 Feb 2025 00:02:21 +0200 Subject: [PATCH] Fix commonjs build --- .gitignore | 1 - IDEAS.md | 6 - docs/js-usage.md | 10 +- package.json | 9 +- packages/prepack/package.json | 2 - packages/prepack/src/Prepack.res | 188 +++++---- packages/prepack/src/Prepack.res.mjs | 375 ++++++++++++++---- packages/tests/src/benchmark/comparison.js | 2 +- packages/tests/src/core/S_test.ts | 2 +- .../tests/src/genType/GenType_test_type.ts | 2 +- pnpm-lock.yaml | 98 ----- src/S.js | 148 ++++--- src/S.mjs | 70 ++++ wallaby.conf.js | 2 +- 14 files changed, 573 insertions(+), 342 deletions(-) create mode 100644 src/S.mjs diff --git a/.gitignore b/.gitignore index e5f0cf93..d3b44c79 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ node_modules packages/tests/src/core/**/*_test.res.mjs lib coverage -dist packages/artifacts .tsimp \ No newline at end of file diff --git a/IDEAS.md b/IDEAS.md index a026b08f..868c3373 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -18,12 +18,6 @@ let trimContract: S.contract string> = S.contract(s => { - Use internal transform for trim -## v9.1 - -- [x] Update object type validation -- [ ] Support standard schema -- [ ] Make rescript an optional peer dependency - ## v10 - Rename S.to to S.reshape diff --git a/docs/js-usage.md b/docs/js-usage.md index bc2e4045..01f42696 100644 --- a/docs/js-usage.md +++ b/docs/js-usage.md @@ -832,8 +832,14 @@ Reverses the schema. This gets especially magical for schemas with transformatio ### **`standard`** ```ts -S.standard(S.string); -// Returns StandardSchemaV1 +const docsSchema = S.schema({ + id: S.number, + content: S.string, +}); + +// ┌─── StandardSchemaV1<{ id: number; content: string; }> +// ▼ +const standardSchema = S.standard(docsSchema); ``` Converts ReScript Schema into [Standard Schema](https://standardschema.dev/). You can use it to integrate with 20+ other libraries. Checkout the [Standard Schema](https://standardschema.dev/) to learn more. 👀 diff --git a/package.json b/package.json index 165b7f49..e1ff1724 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rescript-schema", - "version": "9.2.0", + "version": "9.2.1", "private": true, "description": "🧬 The fastest parser in the entire JavaScript ecosystem with a focus on small bundle size and top-notch DX", "keywords": [ @@ -30,11 +30,10 @@ "license": "MIT", "author": "Dmitry Zakharov ", "type": "module", - "main": "./dist/S.js", - "module": "./dist/S.mjs", + "main": "./src/S.js", + "module": "./src/S.mjs", "types": "./src/S.d.ts", "files": [ - "dist", "src/S_Core.res", "src/S_Core.res.js", "src/S_Core.res.mjs", @@ -42,6 +41,8 @@ "src/S.resi", "src/S.res.js", "src/S.res.mjs", + "src/S.js", + "src/S.mjs", "src/S.d.ts", "RescriptSchema.gen.d.ts", "rescript.json" diff --git a/packages/prepack/package.json b/packages/prepack/package.json index b3089943..58ff25eb 100644 --- a/packages/prepack/package.json +++ b/packages/prepack/package.json @@ -10,9 +10,7 @@ }, "dependencies": { "@rescript/core": "1.3.0", - "@rollup/plugin-replace": "5.0.2", "@rollup/plugin-node-resolve": "16.0.0", - "@rollup/plugin-commonjs": "28.0.2", "execa": "7.1.1", "rescript": "11.1.0", "rescript-nodejs": "16.1.0", diff --git a/packages/prepack/src/Prepack.res b/packages/prepack/src/Prepack.res index 64eb2cc2..a7b25b9e 100644 --- a/packages/prepack/src/Prepack.res +++ b/packages/prepack/src/Prepack.res @@ -8,7 +8,6 @@ let sourePaths = [ "README.md", "RescriptSchema.gen.d.ts", ] -let jsInputPath = NodeJs.Path.join2(artifactsPath, "src/S.js") module Stdlib = { module Dict = { @@ -67,19 +66,10 @@ module Rollup = { type t } - module ReplacePlugin = { - type options = {values: dict} - @module("@rollup/plugin-replace") external make: options => Plugin.t = "default" - } - module NodeResolvePlugin = { @module("@rollup/plugin-node-resolve") external make: unit => Plugin.t = "nodeResolve" } - module CommonjsPluggin = { - @module("@rollup/plugin-commonjs") external make: unit => Plugin.t = "default" - } - module InputOptions = { type t = { input?: string, @@ -124,6 +114,102 @@ if NodeJs.Fs.existsSync(artifactsPath) { } NodeJs.Fs.mkdirSync(artifactsPath) +let filesMapping = [ + ("Error", "S.$$Error.$$class"), + ("string", "S.string"), + ("boolean", "S.bool"), + ("int32", "S.$$int"), + ("number", "S.$$float"), + ("bigint", "S.bigint"), + ("json", "S.json"), + ("never", "S.never"), + ("unknown", "S.unknown"), + ("undefined", "S.unit"), + ("optional", "S.js_optional"), + ("nullable", "S.$$null"), + ("nullish", "S.nullable"), + ("array", "S.array"), + ("unnest", "S.unnest"), + ("record", "S.dict"), + ("jsonString", "S.jsonString"), + ("union", "S.js_union"), + ("object", "S.object"), + ("schema", "S.js_schema"), + ("safe", "S.js_safe"), + ("safeAsync", "S.js_safeAsync"), + ("reverse", "S.reverse"), + ("convertOrThrow", "S.convertOrThrow"), + ("convertToJsonOrThrow", "S.convertToJsonOrThrow"), + ("convertToJsonStringOrThrow", "S.convertToJsonStringOrThrow"), + ("reverseConvertOrThrow", "S.reverseConvertOrThrow"), + ("reverseConvertToJsonOrThrow", "S.reverseConvertToJsonOrThrow"), + ("reverseConvertToJsonStringOrThrow", " S.reverseConvertToJsonStringOrThrow"), + ("parseOrThrow", "S.parseOrThrow"), + ("parseJsonOrThrow", "S.parseJsonOrThrow"), + ("parseJsonStringOrThrow", "S.parseJsonStringOrThrow"), + ("parseAsyncOrThrow", "S.parseAsyncOrThrow"), + ("assertOrThrow", "S.assertOrThrow"), + ("recursive", "S.recursive"), + ("merge", "S.js_merge"), + ("strict", "S.strict"), + ("deepStrict", "S.deepStrict"), + ("strip", "S.strip"), + ("deepStrip", "S.deepStrip"), + ("custom", "S.js_custom"), + ("standard", "S.standard"), + ("tuple", "S.tuple"), + ("asyncParserRefine", "S.js_asyncParserRefine"), + ("refine", "S.js_refine"), + ("transform", "S.js_transform"), + ("description", "S.description"), + ("describe", "S.describe"), + ("name", "S.js_name"), + ("setName", "S.setName"), + ("removeTypeValidation", "S.removeTypeValidation"), + ("compile", "S.compile"), + ("port", "S.port"), + ("numberMin", "S.floatMin"), + ("numberMax", "S.floatMax"), + ("arrayMinLength", "S.arrayMinLength"), + ("arrayMaxLength", "S.arrayMaxLength"), + ("arrayLength", "S.arrayLength"), + ("stringMinLength", "S.stringMinLength"), + ("stringMaxLength", "S.stringMaxLength"), + ("stringLength", "S.stringLength"), + ("email", "S.email"), + ("uuid", "S.uuid"), + ("cuid", "S.cuid"), + ("url", "S.url"), + ("pattern", "S.pattern"), + ("datetime", "S.datetime"), + ("trim", "S.trim"), + ("setGlobalConfig", "S.setGlobalConfig"), +] + +NodeJs.Fs.writeFileSyncWith( + "./src/S.mjs", + ["import * as S from \"./S_Core.res.mjs\";"] + ->Js.Array2.concat( + filesMapping->Js.Array2.map(((name, value)) => `export const ${name} = ${value}`), + ) + ->Js.Array2.joinWith("\n") + ->NodeJs.Buffer.fromString, + { + encoding: "utf8", + }, +) + +NodeJs.Fs.writeFileSyncWith( + "./src/S.js", + ["var S = require(\"./S_Core.res.mjs\");"] + ->Js.Array2.concat(filesMapping->Js.Array2.map(((name, value)) => `exports.${name} = ${value}`)) + ->Js.Array2.joinWith("\n") + ->NodeJs.Buffer.fromString, + { + encoding: "utf8", + }, +) + sourePaths->Array.forEach(path => { FsX.cpSync( ~src=NodeJs.Path.join2(projectPath, path), @@ -153,85 +239,41 @@ let updateJsonFile = (~src, ~path, ~value) => { let _ = Execa.sync("npm", ["run", "res:build"], ~options={cwd: artifactsPath}, ()) -let bundle = await Rollup.Bundle.make({ - input: jsInputPath, - // Mark S_Core.res.mjs as external so it's not inlined - // and JS/TS can reuse the same code as ReScript version in mixed codebases - external_: [%re("/S_Core\.res\.mjs/")], - plugins: [], -}) -let output: array = [ - { - file: NodeJs.Path.join2(artifactsPath, "dist/S.js"), - format: #cjs, - exports: #named, - plugins: [ - Rollup.ReplacePlugin.make({ - values: Dict.fromArray([ - (`S_Core.res.mjs`, `../src/S_Core.res.js`), - (`rescript/lib/es6`, `rescript/lib/js`), - ]), - }), - ], - }, - { - file: NodeJs.Path.join2(artifactsPath, "dist/S.mjs"), - format: #es, - exports: #named, - plugins: [ - Rollup.ReplacePlugin.make({ - values: Dict.fromArray([(`S_Core.res.mjs`, `../src/S_Core.res.mjs`)]), - }), - ], - }, -] -for idx in 0 to output->Array.length - 1 { - let outpuOptions = output->Array.getUnsafe(idx) - let _ = await bundle->Rollup.Bundle.write(outpuOptions) -} -await bundle->Rollup.Bundle.close - -let resolveRescriptRuntime = async (~format, ~path) => { +let resolveRescriptRuntime = async (~format, ~input, ~output) => { let bundle = await Rollup.Bundle.make({ - input: NodeJs.Path.join2(artifactsPath, path), - plugins: [Rollup.NodeResolvePlugin.make(), Rollup.CommonjsPluggin.make()], + input: NodeJs.Path.join2(artifactsPath, input), + plugins: [Rollup.NodeResolvePlugin.make()], }) let _ = await bundle->Rollup.Bundle.write({ - file: NodeJs.Path.join2(artifactsPath, path), + file: NodeJs.Path.join2(artifactsPath, output), format, exports: #named, }) await bundle->Rollup.Bundle.close } -// Clean up rescript artifacts so the compiled .res.js files aren't removed on the .res.mjs build -FsX.rmSync(NodeJs.Path.join2(artifactsPath, "lib"), {force: true, recursive: true}) -updateJsonFile( - ~src=NodeJs.Path.join2(artifactsPath, "rescript.json"), - ~path=["package-specs", "module"], - ~value=JSON.Encode.string("commonjs"), -) -updateJsonFile( - ~src=NodeJs.Path.join2(artifactsPath, "rescript.json"), - ~path=["suffix"], - ~value=JSON.Encode.string(".res.js"), -) -let _ = Execa.sync("npm", ["run", "res:build"], ~options={cwd: artifactsPath}, ()) +// Inline "rescript" runtime dependencies, +// so it's not required for JS/TS to install ReScript compiler +// And if the package is used together by TS and ReScript, +// the file will be overwritten by compiler and share the same code +await resolveRescriptRuntime(~format=#es, ~input="src/S_Core.res.mjs", ~output="src/S_Core.res.mjs") +// Event though the generated code is shitty, let's still have it for the sake of some users +await resolveRescriptRuntime(~format=#cjs, ~input="src/S_Core.res.mjs", ~output="src/S_Core.res.js") +// Also build cjs version, in case some ReScript libraries will use rescript-schema without running a compiler (rescript-stdlib-vendorer) +await resolveRescriptRuntime(~format=#cjs, ~input="src/S.res.mjs", ~output="src/S.res.js") +// ReScript applications don't work with type: module set on packages updateJsonFile( ~src=NodeJs.Path.join2(artifactsPath, "package.json"), ~path=["type"], ~value=JSON.Encode.string("commonjs"), ) +updateJsonFile( + ~src=NodeJs.Path.join2(artifactsPath, "package.json"), + ~path=["private"], + ~value=JSON.Encode.bool(false), +) // Clean up before uploading artifacts FsX.rmSync(NodeJs.Path.join2(artifactsPath, "lib"), {force: true, recursive: true}) FsX.rmSync(NodeJs.Path.join2(artifactsPath, "node_modules"), {force: true, recursive: true}) - -// Inline "rescript" runtime dependencies, -// so it's not required for JS/TS to install ReScript compiler -// And if the package is used together by TS and ReScript, -// the file will be overwritten by compiler and share the same code -await resolveRescriptRuntime(~format=#es, ~path="src/S_Core.res.mjs") -// Event though the generated code is shitty, let's still have it for the sake of some users -await resolveRescriptRuntime(~format=#cjs, ~path="src/S_Core.res.js") diff --git a/packages/prepack/src/Prepack.res.mjs b/packages/prepack/src/Prepack.res.mjs index 326fe9cd..2aba8ed9 100644 --- a/packages/prepack/src/Prepack.res.mjs +++ b/packages/prepack/src/Prepack.res.mjs @@ -8,8 +8,6 @@ import * as Nodepath from "node:path"; import * as Core__JSON from "@rescript/core/src/Core__JSON.res.mjs"; import * as Core__List from "@rescript/core/src/Core__List.res.mjs"; import * as Core__Option from "@rescript/core/src/Core__Option.res.mjs"; -import PluginReplace from "@rollup/plugin-replace"; -import PluginCommonjs from "@rollup/plugin-commonjs"; import * as PluginNodeResolve from "@rollup/plugin-node-resolve"; var projectPath = "."; @@ -25,8 +23,6 @@ var sourePaths = [ "RescriptSchema.gen.d.ts" ]; -var jsInputPath = Nodepath.join(artifactsPath, "src/S.js"); - function update(json, path, value) { var dict = Core__JSON.Decode.object(json); var dict$1 = dict !== undefined ? Object.assign({}, dict) : ({}); @@ -53,6 +49,297 @@ if (Nodefs.existsSync(artifactsPath)) { Nodefs.mkdirSync(artifactsPath); +var filesMapping = [ + [ + "Error", + "S.$$Error.$$class" + ], + [ + "string", + "S.string" + ], + [ + "boolean", + "S.bool" + ], + [ + "int32", + "S.$$int" + ], + [ + "number", + "S.$$float" + ], + [ + "bigint", + "S.bigint" + ], + [ + "json", + "S.json" + ], + [ + "never", + "S.never" + ], + [ + "unknown", + "S.unknown" + ], + [ + "undefined", + "S.unit" + ], + [ + "optional", + "S.js_optional" + ], + [ + "nullable", + "S.$$null" + ], + [ + "nullish", + "S.nullable" + ], + [ + "array", + "S.array" + ], + [ + "unnest", + "S.unnest" + ], + [ + "record", + "S.dict" + ], + [ + "jsonString", + "S.jsonString" + ], + [ + "union", + "S.js_union" + ], + [ + "object", + "S.object" + ], + [ + "schema", + "S.js_schema" + ], + [ + "safe", + "S.js_safe" + ], + [ + "safeAsync", + "S.js_safeAsync" + ], + [ + "reverse", + "S.reverse" + ], + [ + "convertOrThrow", + "S.convertOrThrow" + ], + [ + "convertToJsonOrThrow", + "S.convertToJsonOrThrow" + ], + [ + "convertToJsonStringOrThrow", + "S.convertToJsonStringOrThrow" + ], + [ + "reverseConvertOrThrow", + "S.reverseConvertOrThrow" + ], + [ + "reverseConvertToJsonOrThrow", + "S.reverseConvertToJsonOrThrow" + ], + [ + "reverseConvertToJsonStringOrThrow", + " S.reverseConvertToJsonStringOrThrow" + ], + [ + "parseOrThrow", + "S.parseOrThrow" + ], + [ + "parseJsonOrThrow", + "S.parseJsonOrThrow" + ], + [ + "parseJsonStringOrThrow", + "S.parseJsonStringOrThrow" + ], + [ + "parseAsyncOrThrow", + "S.parseAsyncOrThrow" + ], + [ + "assertOrThrow", + "S.assertOrThrow" + ], + [ + "recursive", + "S.recursive" + ], + [ + "merge", + "S.js_merge" + ], + [ + "strict", + "S.strict" + ], + [ + "deepStrict", + "S.deepStrict" + ], + [ + "strip", + "S.strip" + ], + [ + "deepStrip", + "S.deepStrip" + ], + [ + "custom", + "S.js_custom" + ], + [ + "standard", + "S.standard" + ], + [ + "tuple", + "S.tuple" + ], + [ + "asyncParserRefine", + "S.js_asyncParserRefine" + ], + [ + "refine", + "S.js_refine" + ], + [ + "transform", + "S.js_transform" + ], + [ + "description", + "S.description" + ], + [ + "describe", + "S.describe" + ], + [ + "name", + "S.js_name" + ], + [ + "setName", + "S.setName" + ], + [ + "removeTypeValidation", + "S.removeTypeValidation" + ], + [ + "compile", + "S.compile" + ], + [ + "port", + "S.port" + ], + [ + "numberMin", + "S.floatMin" + ], + [ + "numberMax", + "S.floatMax" + ], + [ + "arrayMinLength", + "S.arrayMinLength" + ], + [ + "arrayMaxLength", + "S.arrayMaxLength" + ], + [ + "arrayLength", + "S.arrayLength" + ], + [ + "stringMinLength", + "S.stringMinLength" + ], + [ + "stringMaxLength", + "S.stringMaxLength" + ], + [ + "stringLength", + "S.stringLength" + ], + [ + "email", + "S.email" + ], + [ + "uuid", + "S.uuid" + ], + [ + "cuid", + "S.cuid" + ], + [ + "url", + "S.url" + ], + [ + "pattern", + "S.pattern" + ], + [ + "datetime", + "S.datetime" + ], + [ + "trim", + "S.trim" + ], + [ + "setGlobalConfig", + "S.setGlobalConfig" + ] +]; + +Nodefs.writeFileSync("./src/S.mjs", Buffer.from(["import * as S from \"./S_Core.res.mjs\";"].concat(filesMapping.map(function (param) { + return "export const " + param[0] + " = " + param[1]; + })).join("\n")), { + encoding: "utf8" + }); + +Nodefs.writeFileSync("./src/S.js", Buffer.from(["var S = require(\"./S_Core.res.mjs\");"].concat(filesMapping.map(function (param) { + return "exports." + param[0] + " = " + param[1]; + })).join("\n")), { + encoding: "utf8" + }); + sourePaths.forEach(function (path) { Fs.cpSync(Nodepath.join(projectPath, path), Nodepath.join(artifactsPath, path), { recursive: true @@ -77,87 +364,29 @@ Execa.execaSync("npm", [ cwd: artifactsPath }); -var bundle = await Rollup.rollup({ - input: jsInputPath, - plugins: [], - external: [/S_Core\.res\.mjs/] - }); - -var output = [ - { - file: Nodepath.join(artifactsPath, "dist/S.js"), - format: "cjs", - exports: "named", - plugins: [PluginReplace({ - values: Object.fromEntries([ - [ - "S_Core.res.mjs", - "../src/S_Core.res.js" - ], - [ - "rescript/lib/es6", - "rescript/lib/js" - ] - ]) - })] - }, - { - file: Nodepath.join(artifactsPath, "dist/S.mjs"), - format: "es", - exports: "named", - plugins: [PluginReplace({ - values: Object.fromEntries([[ - "S_Core.res.mjs", - "../src/S_Core.res.mjs" - ]]) - })] - } -]; - -for(var idx = 0 ,idx_finish = output.length; idx < idx_finish; ++idx){ - var outpuOptions = output[idx]; - await bundle.write(outpuOptions); -} - -await bundle.close(); - -async function resolveRescriptRuntime(format, path) { +async function resolveRescriptRuntime(format, input, output) { var bundle = await Rollup.rollup({ - input: Nodepath.join(artifactsPath, path), - plugins: [ - PluginNodeResolve.nodeResolve(), - PluginCommonjs() - ] + input: Nodepath.join(artifactsPath, input), + plugins: [PluginNodeResolve.nodeResolve()] }); await bundle.write({ - file: Nodepath.join(artifactsPath, path), + file: Nodepath.join(artifactsPath, output), format: format, exports: "named" }); return await bundle.close(); } -Fs.rmSync(Nodepath.join(artifactsPath, "lib"), { - recursive: true, - force: true - }); +await resolveRescriptRuntime("es", "src/S_Core.res.mjs", "src/S_Core.res.mjs"); -updateJsonFile(Nodepath.join(artifactsPath, "rescript.json"), [ - "package-specs", - "module" - ], "commonjs"); +await resolveRescriptRuntime("cjs", "src/S_Core.res.mjs", "src/S_Core.res.js"); -updateJsonFile(Nodepath.join(artifactsPath, "rescript.json"), ["suffix"], ".res.js"); - -Execa.execaSync("npm", [ - "run", - "res:build" - ], { - cwd: artifactsPath - }); +await resolveRescriptRuntime("cjs", "src/S.res.mjs", "src/S.res.js"); updateJsonFile(Nodepath.join(artifactsPath, "package.json"), ["type"], "commonjs"); +updateJsonFile(Nodepath.join(artifactsPath, "package.json"), ["private"], false); + Fs.rmSync(Nodepath.join(artifactsPath, "lib"), { recursive: true, force: true @@ -168,10 +397,6 @@ Fs.rmSync(Nodepath.join(artifactsPath, "node_modules"), { force: true }); -await resolveRescriptRuntime("es", "src/S_Core.res.mjs"); - -await resolveRescriptRuntime("cjs", "src/S_Core.res.js"); - export { } diff --git a/packages/tests/src/benchmark/comparison.js b/packages/tests/src/benchmark/comparison.js index 1d27747e..99dd5b8d 100644 --- a/packages/tests/src/benchmark/comparison.js +++ b/packages/tests/src/benchmark/comparison.js @@ -1,7 +1,7 @@ import B from "benchmark"; import { z } from "zod"; import * as V from "valibot"; -import * as S from "rescript-schema/src/S.js"; +import * as S from "rescript-schema/src/S.mjs"; import { type } from "arktype"; const data = Object.freeze({ diff --git a/packages/tests/src/core/S_test.ts b/packages/tests/src/core/S_test.ts index f1988187..24d9af52 100644 --- a/packages/tests/src/core/S_test.ts +++ b/packages/tests/src/core/S_test.ts @@ -2,7 +2,7 @@ import { StandardSchemaV1 } from "./../../../../src/S.d"; import test, { ExecutionContext } from "ava"; import { expectType, TypeEqual } from "ts-expect"; -import * as S from "../../../../src/S.js"; +import * as S from "../../../../src/S.mjs"; import { stringSchema } from "../genType/GenType.gen.js"; type SchemaEqual< diff --git a/packages/tests/src/genType/GenType_test_type.ts b/packages/tests/src/genType/GenType_test_type.ts index c0019b72..e42987ac 100644 --- a/packages/tests/src/genType/GenType_test_type.ts +++ b/packages/tests/src/genType/GenType_test_type.ts @@ -1,6 +1,6 @@ import { expectType, TypeEqual } from "ts-expect"; -import * as S from "../../../../src/S.js"; +import * as S from "../../../../src/S.mjs"; import * as GenType from "./GenType.gen"; expectType>>( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 08f2389a..cfed3787 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,15 +56,9 @@ importers: '@rescript/core': specifier: 1.3.0 version: 1.3.0(rescript@11.1.0) - '@rollup/plugin-commonjs': - specifier: 28.0.2 - version: 28.0.2(rollup@3.21.0) '@rollup/plugin-node-resolve': specifier: 16.0.0 version: 16.0.0(rollup@3.21.0) - '@rollup/plugin-replace': - specifier: 5.0.2 - version: 5.0.2(rollup@3.21.0) execa: specifier: 7.1.1 version: 7.1.1 @@ -127,12 +121,6 @@ packages: '@jridgewell/sourcemap-codec@1.4.14': resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} - '@jridgewell/sourcemap-codec@1.4.15': - resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - - '@jridgewell/sourcemap-codec@1.5.0': - resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - '@jridgewell/trace-mapping@0.3.18': resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} @@ -157,15 +145,6 @@ packages: peerDependencies: rescript: ^11.1.0-rc.7 - '@rollup/plugin-commonjs@28.0.2': - resolution: {integrity: sha512-BEFI2EDqzl+vA1rl97IDRZ61AIwGH093d9nz8+dThxJNH8oSoB7MjWvPCX3dkaK1/RCJ/1v/R1XB15FuSs0fQw==} - engines: {node: '>=16.0.0 || 14 >= 14.17'} - peerDependencies: - rollup: ^2.68.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - '@rollup/plugin-node-resolve@16.0.0': resolution: {integrity: sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==} engines: {node: '>=14.0.0'} @@ -175,15 +154,6 @@ packages: rollup: optional: true - '@rollup/plugin-replace@5.0.2': - resolution: {integrity: sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - '@rollup/pluginutils@5.0.2': resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} engines: {node: '>=14.0.0'} @@ -353,9 +323,6 @@ packages: common-path-prefix@3.0.0: resolution: {integrity: sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==} - commondir@1.0.1: - resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} - concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -454,14 +421,6 @@ packages: fastq@1.15.0: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} - fdir@6.4.3: - resolution: {integrity: sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==} - peerDependencies: - picomatch: ^3 || ^4 - peerDependenciesMeta: - picomatch: - optional: true - figures@5.0.0: resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} engines: {node: '>=14'} @@ -620,9 +579,6 @@ packages: is-promise@4.0.0: resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==} - is-reference@1.2.1: - resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} - is-stream@3.0.0: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -687,13 +643,6 @@ packages: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} - magic-string@0.27.0: - resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==} - engines: {node: '>=12'} - - magic-string@0.30.17: - resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} - make-dir@3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} @@ -852,10 +801,6 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - picomatch@4.0.2: - resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} - engines: {node: '>=12'} - pirates@4.0.6: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} @@ -1184,10 +1129,6 @@ snapshots: '@jridgewell/sourcemap-codec@1.4.14': {} - '@jridgewell/sourcemap-codec@1.4.15': {} - - '@jridgewell/sourcemap-codec@1.5.0': {} - '@jridgewell/trace-mapping@0.3.18': dependencies: '@jridgewell/resolve-uri': 3.1.0 @@ -1212,18 +1153,6 @@ snapshots: dependencies: rescript: 11.1.0 - '@rollup/plugin-commonjs@28.0.2(rollup@3.21.0)': - dependencies: - '@rollup/pluginutils': 5.0.2(rollup@3.21.0) - commondir: 1.0.1 - estree-walker: 2.0.2 - fdir: 6.4.3(picomatch@4.0.2) - is-reference: 1.2.1 - magic-string: 0.30.17 - picomatch: 4.0.2 - optionalDependencies: - rollup: 3.21.0 - '@rollup/plugin-node-resolve@16.0.0(rollup@3.21.0)': dependencies: '@rollup/pluginutils': 5.0.2(rollup@3.21.0) @@ -1234,13 +1163,6 @@ snapshots: optionalDependencies: rollup: 3.21.0 - '@rollup/plugin-replace@5.0.2(rollup@3.21.0)': - dependencies: - '@rollup/pluginutils': 5.0.2(rollup@3.21.0) - magic-string: 0.27.0 - optionalDependencies: - rollup: 3.21.0 - '@rollup/pluginutils@5.0.2(rollup@3.21.0)': dependencies: '@types/estree': 1.0.1 @@ -1448,8 +1370,6 @@ snapshots: common-path-prefix@3.0.0: {} - commondir@1.0.1: {} - concat-map@0.0.1: {} concordance@5.0.4: @@ -1548,10 +1468,6 @@ snapshots: dependencies: reusify: 1.0.4 - fdir@6.4.3(picomatch@4.0.2): - optionalDependencies: - picomatch: 4.0.2 - figures@5.0.0: dependencies: escape-string-regexp: 5.0.0 @@ -1692,10 +1608,6 @@ snapshots: is-promise@4.0.0: {} - is-reference@1.2.1: - dependencies: - '@types/estree': 1.0.1 - is-stream@3.0.0: {} is-unicode-supported@1.3.0: {} @@ -1752,14 +1664,6 @@ snapshots: dependencies: yallist: 4.0.0 - magic-string@0.27.0: - dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 - - magic-string@0.30.17: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 - make-dir@3.1.0: dependencies: semver: 6.3.0 @@ -1886,8 +1790,6 @@ snapshots: picomatch@2.3.1: {} - picomatch@4.0.2: {} - pirates@4.0.6: {} pkg-conf@4.0.0: diff --git a/src/S.js b/src/S.js index c03b89d7..2f71ccc3 100644 --- a/src/S.js +++ b/src/S.js @@ -1,77 +1,71 @@ -import * as S from "./S_Core.res.mjs"; - -export const Error = S.$$Error.$$class; -export const string = S.string; -export const boolean = S.bool; -export const int32 = S.$$int; -export const number = S.$$float; -export const bigint = S.bigint; -export const json = S.json; -export const never = S.never; -export const unknown = S.unknown; -export const undefined = S.unit; -export const optional = S.js_optional; -export const nullable = S.$$null; -export const nullish = S.nullable; -export const array = S.array; -export const unnest = S.unnest; -export const record = S.dict; -export const jsonString = S.jsonString; -export const union = S.js_union; -export const object = S.object; -export const schema = S.js_schema; -export const safe = S.js_safe; -export const safeAsync = S.js_safeAsync; -export const reverse = S.reverse; -export const convertOrThrow = S.convertOrThrow; -export const convertToJsonOrThrow = S.convertToJsonOrThrow; -export const convertToJsonStringOrThrow = S.convertToJsonStringOrThrow; -export const reverseConvertOrThrow = S.reverseConvertOrThrow; -export const reverseConvertToJsonOrThrow = S.reverseConvertToJsonOrThrow; -export const reverseConvertToJsonStringOrThrow = - S.reverseConvertToJsonStringOrThrow; -export const parseOrThrow = S.parseOrThrow; -export const parseJsonOrThrow = S.parseJsonOrThrow; -export const parseJsonStringOrThrow = S.parseJsonStringOrThrow; -export const parseAsyncOrThrow = S.parseAsyncOrThrow; -export const assertOrThrow = S.assertOrThrow; -export const recursive = S.recursive; -export const merge = S.js_merge; -export const strict = S.strict; -export const deepStrict = S.deepStrict; -export const strip = S.strip; -export const deepStrip = S.deepStrip; -export const custom = S.js_custom; -export const standard = S.standard; -export const tuple = S.tuple; -export const asyncParserRefine = S.js_asyncParserRefine; -export const refine = S.js_refine; -export const transform = S.js_transform; -export const description = S.description; -export const describe = S.describe; -export const name = S.js_name; -export const setName = S.setName; -export const removeTypeValidation = S.removeTypeValidation; -export const compile = S.compile; - -export const port = S.port; - -export const numberMin = S.floatMin; -export const numberMax = S.floatMax; - -export const arrayMinLength = S.arrayMinLength; -export const arrayMaxLength = S.arrayMaxLength; -export const arrayLength = S.arrayLength; - -export const stringMinLength = S.stringMinLength; -export const stringMaxLength = S.stringMaxLength; -export const stringLength = S.stringLength; -export const email = S.email; -export const uuid = S.uuid; -export const cuid = S.cuid; -export const url = S.url; -export const pattern = S.pattern; -export const datetime = S.datetime; -export const trim = S.trim; - -export const setGlobalConfig = S.setGlobalConfig; +'use strict'; +var S = require("./S_Core.res.mjs"); +exports.Error = S.$$Error.$$class +exports.string = S.string +exports.boolean = S.bool +exports.int32 = S.$$int +exports.number = S.$$float +exports.bigint = S.bigint +exports.json = S.json +exports.never = S.never +exports.unknown = S.unknown +exports.undefined = S.unit +exports.optional = S.js_optional +exports.nullable = S.$$null +exports.nullish = S.nullable +exports.array = S.array +exports.unnest = S.unnest +exports.record = S.dict +exports.jsonString = S.jsonString +exports.union = S.js_union +exports.object = S.object +exports.schema = S.js_schema +exports.safe = S.js_safe +exports.safeAsync = S.js_safeAsync +exports.reverse = S.reverse +exports.convertOrThrow = S.convertOrThrow +exports.convertToJsonOrThrow = S.convertToJsonOrThrow +exports.convertToJsonStringOrThrow = S.convertToJsonStringOrThrow +exports.reverseConvertOrThrow = S.reverseConvertOrThrow +exports.reverseConvertToJsonOrThrow = S.reverseConvertToJsonOrThrow +exports.reverseConvertToJsonStringOrThrow = S.reverseConvertToJsonStringOrThrow +exports.parseOrThrow = S.parseOrThrow +exports.parseJsonOrThrow = S.parseJsonOrThrow +exports.parseJsonStringOrThrow = S.parseJsonStringOrThrow +exports.parseAsyncOrThrow = S.parseAsyncOrThrow +exports.assertOrThrow = S.assertOrThrow +exports.recursive = S.recursive +exports.merge = S.js_merge +exports.strict = S.strict +exports.deepStrict = S.deepStrict +exports.strip = S.strip +exports.deepStrip = S.deepStrip +exports.custom = S.js_custom +exports.standard = S.standard +exports.tuple = S.tuple +exports.asyncParserRefine = S.js_asyncParserRefine +exports.refine = S.js_refine +exports.transform = S.js_transform +exports.description = S.description +exports.describe = S.describe +exports.name = S.js_name +exports.setName = S.setName +exports.removeTypeValidation = S.removeTypeValidation +exports.compile = S.compile +exports.port = S.port +exports.numberMin = S.floatMin +exports.numberMax = S.floatMax +exports.arrayMinLength = S.arrayMinLength +exports.arrayMaxLength = S.arrayMaxLength +exports.arrayLength = S.arrayLength +exports.stringMinLength = S.stringMinLength +exports.stringMaxLength = S.stringMaxLength +exports.stringLength = S.stringLength +exports.email = S.email +exports.uuid = S.uuid +exports.cuid = S.cuid +exports.url = S.url +exports.pattern = S.pattern +exports.datetime = S.datetime +exports.trim = S.trim +exports.setGlobalConfig = S.setGlobalConfig \ No newline at end of file diff --git a/src/S.mjs b/src/S.mjs new file mode 100644 index 00000000..9f462fd7 --- /dev/null +++ b/src/S.mjs @@ -0,0 +1,70 @@ +import * as S from "./S_Core.res.mjs"; +export const Error = S.$$Error.$$class +export const string = S.string +export const boolean = S.bool +export const int32 = S.$$int +export const number = S.$$float +export const bigint = S.bigint +export const json = S.json +export const never = S.never +export const unknown = S.unknown +export const undefined = S.unit +export const optional = S.js_optional +export const nullable = S.$$null +export const nullish = S.nullable +export const array = S.array +export const unnest = S.unnest +export const record = S.dict +export const jsonString = S.jsonString +export const union = S.js_union +export const object = S.object +export const schema = S.js_schema +export const safe = S.js_safe +export const safeAsync = S.js_safeAsync +export const reverse = S.reverse +export const convertOrThrow = S.convertOrThrow +export const convertToJsonOrThrow = S.convertToJsonOrThrow +export const convertToJsonStringOrThrow = S.convertToJsonStringOrThrow +export const reverseConvertOrThrow = S.reverseConvertOrThrow +export const reverseConvertToJsonOrThrow = S.reverseConvertToJsonOrThrow +export const reverseConvertToJsonStringOrThrow = S.reverseConvertToJsonStringOrThrow +export const parseOrThrow = S.parseOrThrow +export const parseJsonOrThrow = S.parseJsonOrThrow +export const parseJsonStringOrThrow = S.parseJsonStringOrThrow +export const parseAsyncOrThrow = S.parseAsyncOrThrow +export const assertOrThrow = S.assertOrThrow +export const recursive = S.recursive +export const merge = S.js_merge +export const strict = S.strict +export const deepStrict = S.deepStrict +export const strip = S.strip +export const deepStrip = S.deepStrip +export const custom = S.js_custom +export const standard = S.standard +export const tuple = S.tuple +export const asyncParserRefine = S.js_asyncParserRefine +export const refine = S.js_refine +export const transform = S.js_transform +export const description = S.description +export const describe = S.describe +export const name = S.js_name +export const setName = S.setName +export const removeTypeValidation = S.removeTypeValidation +export const compile = S.compile +export const port = S.port +export const numberMin = S.floatMin +export const numberMax = S.floatMax +export const arrayMinLength = S.arrayMinLength +export const arrayMaxLength = S.arrayMaxLength +export const arrayLength = S.arrayLength +export const stringMinLength = S.stringMinLength +export const stringMaxLength = S.stringMaxLength +export const stringLength = S.stringLength +export const email = S.email +export const uuid = S.uuid +export const cuid = S.cuid +export const url = S.url +export const pattern = S.pattern +export const datetime = S.datetime +export const trim = S.trim +export const setGlobalConfig = S.setGlobalConfig \ No newline at end of file diff --git a/wallaby.conf.js b/wallaby.conf.js index 315867e5..cfd4142e 100644 --- a/wallaby.conf.js +++ b/wallaby.conf.js @@ -9,7 +9,7 @@ export default () => ({ "package.json", "src/S.res.mjs", "src/S_Core.res.mjs", - "src/S.js", + "src/S.mjs", "packages/tests/src/utils/U.res.mjs", ], tests,