browser icon indicating copy to clipboard operation
browser copied to clipboard

@curveball/validator is a devDependency but imported at runtime

Open arild-haugstad opened this issue 1 year ago • 1 comments

html-index.tsx has a line https://github.com/curveball/browser/blob/9f2245facb9b3f370593c222cf01fff856299b29/src/html-index.tsx#L9 but @curveball/validator is a devDependency.

This was introduced in https://github.com/curveball/browser/commit/59817874c1b831fac8594e4a14eb1fe918c560e2, and the purpose appears to be to to modify the type of Context to have member schemas via the declaration in https://github.com/curveball/validator/blob/3259fb6ac3a7decce51307668efea9462fc3247f/src/declarations.ts

Unfortunately, this import statement becomes part of the output in dist/html-index.js -- which has no obvious effect if @curveball/validator is installed, but leads to error ERR_MODULE_NOT_FOUND if it is not installed.

I believe that the "right" way of expressing import purely for side-effects on types would be

/// <reference types="@curveball/validator" />

at the start of html-index.tsx instead of the import statement; this loads the appropriate type information for type check, but without an import of @curveball/validator in the output; at least it does on my computer...

arild-haugstad avatar Aug 21 '24 19:08 arild-haugstad

Worth fixing!

evert avatar Aug 21 '24 20:08 evert