Open NiklasPor opened 3 weeks ago
I can confirm that this is due to the dynamic module loading of @sinclair/typebox/compiler
. I just monkey patched my package.
Before:
// File node_modules/@typeschema/typebox/dist/index.js
// src/validation.ts
var import_core = require("@typeschema/core");
var importValidationModule = (0, import_core.memoize)(async () => {
try {
var dynamicallyImportedModule = await import(
/* webpackIgnore: true */
"@sinclair/typebox/compiler"
);
} catch (moduleImportError) {
throw moduleImportError;
}
const { TypeCompiler } = dynamicallyImportedModule;
return { TypeCompiler };
});
var validationAdapter = async (schema) => {
const { TypeCompiler } = await importValidationModule();
After:
// File node_modules/@typeschema/typebox/dist/index.js
// src/validation.ts
const { TypeCompiler } = require("@sinclair/typebox/compiler");
var validationAdapter = async (schema) => {
const result = TypeCompiler.Compile(schema);
As I'm using the package anyway it's not a problem for me to load it statically. It would be nice if we could find a better fix 👍
It seems like the TypeBox adapter is not respecting global settings. In my example I've got a simple email validator:
Now if you try to use it via TypeBox wrap:
My first suspicion would be that the dynamic import inside @typeschema/typebox conflicts with the global module configuration in my node application:
Versions:
Upvote & Fund