Effect CommunityEC
Effect Communityβ€’3y agoβ€’
60 replies
tomchristensen

Minification Issues with Schema and Vite

Has anyone else had bundling / minification issues with Schema? Using Vite to bundle and minify a web app, and it seems like some of the unused exports from AST.ts aren't being tree-shaked correctly, e.g. this source code:
export const undefinedKeyword: UndefinedKeyword = {
  _tag: "UndefinedKeyword",
  annotations: {
    [TitleAnnotationId]: "undefined"
  }
}

becomes a floating expression after bundling:
({
  _tag: "UndefinedKeyword",
  annotations: {
    [TitleAnnotationId]: "undefined"
  }
});

and after minification it becomes R+""; where R=Symbol.for("@effect/schema/annotation/Title"), which results in a nice little runtime error: Schema-929fa510.js:1 Uncaught TypeError: Cannot convert a Symbol value to a string. If I create a schema in my app that uses S.undefined, the undefinedKeyword export ends up being bundled correctly
Was this page helpful?