Closed limbic-derek closed 4 months ago
I tried removing as const satisfies MyType
and I'm still getting this failure. Other files seem fine, but I'm not sure what is unique about this one.
OK it looks like this package (js_parser) is being invoked here: https://github.com/esm-dev/esm.sh/blob/main/server/utils.go#L205
It looks like that only validates JavaScript files using this: https://github.com/ije/esbuild-internal/blob/master/js_parser/js_parser.go
Although, it seems to allow TypeScript files to be "found" and passed in. Writing a small test, I think this is the root cause:
--- FAIL: TestStrictMode (0.00s)
--- FAIL: TestStrictMode/import{A,B}from"C";export_const_D={}_as_const_satisfies_A;export_default_B(D); (0.00s)
js_parser_test.go:286:
+<stdin>: ERROR: Expected ";" but found "as"
The util should probably make use of the ts_parser if one of the ts extensions is selected: https://github.com/ije/esbuild-internal/blob/master/js_parser/ts_parser.go
This was a confusing error because the message states require either javascript OR typescript, so it made me assume both were valid here. Upon inspection, I believe TS isn't properly supported.
Wishing I could see the actual <stdin>
errors that are being produced in situ to confirm further.
Confirmed locally that enabling TS parsing allows these files to be properly served via esm.sh.
i just pushed docker image to v135_2 with your patch, thanks for contributing
Please release this fix, as 135 still fails, for example:
https://esm.sh/v135/@rhds/elements@1.4.1/es2022/lib/context/color/context-color.css.js
/* esm.sh - error */
throw new Error("[esm.sh] " + "esmLexer: invalid syntax, require javascript/typescript");
export default null;
and https://esm.sh/v135_2/@rhds/elements@1.4.1/es2022/lib/context/color/context-color.css.js 404s
Thank you for making this helpful service available.
I have a basic TypeScript file like this:
esm.sh (v135, running locally in docker) fails with this message:
I'm wondering if the
satisfies
keyword is causing issues? I am not getting much else with loglevel=debug. Strangely, files that depend on those exports are working fine, and I seeFoo
being inlined into them (which I don't want, but that's OK for now). I am expecting this file to still be addressable/exist.