export * and typescript statements only files => 404 #1589
Replies: 6 comments 10 replies
-
I just started using Snowpack, and I always use Edit: Oh, I see, |
Beta Was this translation helpful? Give feedback.
-
Workaround, add this line (last line) to all your files that happen to be type-only :) export interface Reporter {
log: (message: string) => void;
}
const _SNOWPACK = true; // https://github.com/snowpackjs/snowpack/discussions/1589 |
Beta Was this translation helpful? Give feedback.
-
what about generated files? (my apis are generated by openapi-generator and lots of files only contains interfaces) |
Beta Was this translation helpful? Give feedback.
-
This is a pretty serious issue IMO. It doesn't make much sense to add arbitrary things to your files. |
Beta Was this translation helpful? Give feedback.
-
This is fixed in the 3.1.0 prereleases being tested out in #2707. See this conversation starting https://github.com/snowpackjs/snowpack/pull/2707#issuecomment-786406311 for more info |
Beta Was this translation helpful? Give feedback.
-
This seems like a huge problem. I just moved from webpack to snowpack and I'm running into this issue which leaves me dead in the water. The current fix is to add some workaround code to the offending ts files but what about libs that I don't control. I'm supposed to fork any ts project that causes snowpack to fail? Am I misunderstanding the issue? |
Beta Was this translation helpful? Give feedback.
-
Hello! First of all congratulations for the amazing work on Snowpack, I've been using it for almost a month now and it's truly boosting my productivity.
I've recently tried to add some code generated by openapi generator and the typescript-rxjs generator, and that basically broke my snowpack build. After some digging, I managed to understand (more or less) what was happening and I also could put in place a minimal working example for reproducing the problem: https://github.com/terlenbach/snowpack_404.
Some explanations: there is an
index.ts
file which exports everything from some other files, these other files sometimes contain real code, and sometimes only typescript definitions. Theindex.ts
is compiled into a JS file which will try to load all the referenced modules, but it looks like the esbuild output for the file that contains only typescript statements is just empty and then snowpack won't create any js file, which makes the app fail because of a 404 error.This patch fixes the problem:
but I feel that we can do way better than this. WDYT?
Beta Was this translation helpful? Give feedback.
All reactions