Skip to content

Make Ext import extensions consitent #2222

Open
@sodic

Description

@sodic

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:

  1. Ext imports used by the SDK (e.g., Queries).
  2. Ext imports used by the server (e.g., server setup function, Queries).
  3. 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:

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:

  1. Decide which extensions we want to support. We'll discuss that here, there's also a (discord discussion).
  2. Implement proper import mappings in SDK generator #2224
  3. Implement proper mappings in the server generator.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxshouldfixWe should do/fix this at some point

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions