Description
Summary
Issue spotted with Wasp 0.14.0.
Our allowed external import extensions are all over the place:
- LSP, Snippets, and
wasp start
don't agree on what's allowed. - Different rules apply for different declarations (depending on where Wasp uses the user's code).
Let's fix this.
Details
There are three implicit categories of external imports (that I've discovered so far, there might be more). Each import falls into one or more of the categories:
- Ext imports used by the SDK (e.g., Queries).
- Ext imports used by the server (e.g., server setup function, Queries).
- Ext imports used by the web-app (e.g., pages, client setup function).
Notice how Queries fall into two categories. That's because they're copied into the SDK and also directly imported on the server (we do this to give users better error messages).
Since different imports end up in different build contexts, they are subject to different constraints (one context allows certain extensions, the other allows other extensions), making the behavior look random and confusing to users.
We've made some attempts at fixing this, and we have issues that talk about the problem:
- Bundling server with Rollup + esbuild #1714
- Adjust the way LSP finds user's files #1717
- Fix inconsistent import extensions in both .wasp file and in JS files. #1363
But we never fully committed to properly deciding what we allow and where. The situation got worse after 0.12.0, which introduced an additional context with its own set of import constraints (the SDK).
Solution
Craig made some good points here: #1363 (comment). He talks about two distinct but related problems:
- Handling extensions in the Wasp file (this issue).
- Handling extensions in user files (another issue, to be created).
We must:
- Decide which extensions we want to support. We'll discuss that here, there's also a (discord discussion).
- Implement proper import mappings in SDK generator #2224
- Implement proper mappings in the server generator.
- Implement proper mappings in the web app generator.
By "mappings" I mean "mappings in Haskell and resolve configurations in the project."
Extra problem with the SDK build:
It's possible for the SDK build to pass, leaving extensions to cause problems in runtime. That issue is covered here: #2492