github wasp-lang/wasp v0.7.0

latest releases: v0.14.2, v0.14.1, v0.14.1-rc2...
22 months ago

Changelog

v0.7.0 - Beta Release!

BREAKING CHANGES

Significant changes to Wasp project structure

This was the file tree of a newly generated project in the previous version of Wasp (i.e., this was what you used to get by running wasp new project):

.
├── ext
│   ├── Main.css
│   ├── MainPage.js
│   ├── .waspignore
│   └── waspLogo.png
├── .gitignore
├── main.wasp
└── .wasproot

This is the file tree of a newly generated project in the newest release of Wasp (i.e., this is what you will get by running wasp new project from this point onwards):

.
├── .gitignore
├── main.wasp
├── src
│   ├── client
│   │   ├── Main.css
│   │   ├── MainPage.jsx
│   │   ├── react-app-env.d.ts
│   │   ├── tsconfig.json
│   │   └── waspLogo.png
│   ├── server
│   │   └── tsconfig.json
│   ├── shared
│   │   └── tsconfig.json
│   └── .waspignore
└── .wasproot

Main differences:

  • All server-side code must be located inside the src/server directory. Wasp declarations must import this code with import foo from "@server/foo" (instead of import foo from "@ext/foo.js")
  • All client-side code must be located inside the src/client directory. Wasp declarations must import this code with import foo from "@client/bar" (instead of import bar from "@ext/bar.js")
  • All shared code (i.e., used on both the client and the server) must be located inside the src/shared and imported where needed through a relative import.
  • Each of these subdirectories (i.e., src/server, src/client, and src/shared) comes with a pregenerated tsconfig.json file. This file helps with IDE support (e.g., jumping to definitions, previewing types, etc.) and you shouldn't delete it. The same goes for react-app-env.d.ts

The new structure is fully reflected in our docs, but we'll also provide a quick guide for migrating existing projects.

Migrating an existing Wasp project to the new structure

You can easily migrate your old Wasp project to the new structure by following a series of steps. Assuming you have a project called foo inside the directory foo, you should:

  1. Install the latest version of Wasp

  2. Rename your project's root directory to something like foo_old

  3. Create a new project by running wasp new foo

  4. Copy all server-side code from foo_old/ext to foo/src/server

  5. Copy all client-side code from foo_old/ext to foo/src/client

  6. Copy all shared code (if any) from foo_old/ext to foo/src/shared and
    adapt imports in files that reference it:

    • For example, import bar from './bar.js' becomes import bar from "../shared/bar.js"
  7. Copy all lines you might have added to foo_old/.gitignore into
    foo/.gitignore

  8. Finally, copy foo_old/main.wasp to foo/main.wasp and correct external
    imports:

    • Queries, Actions, Jobs, and the Server setup function must import their code from @server
    • Pages and the Client setup function must import their code from @client

    For example, if you previously had something like:

    page LoginPage {
      // This previously resolved to ext/LoginPage.js
      component: import Login from "@ext/LoginPage.js"
    }
    
    // ...
    
    query getTasks {
      // This previously resolved to ext/queries.js
      fn: import { getTasks } from "@ext/queries.js",
    }

    You should change it to:

    page LoginPage {
      // This resolves to src/client/LoginPage.js
      component: import Login from "@client/LoginPage"
    }
    
    // ...
    
    query getTasks {
      // This resolves to src/server/queries.js
      fn: import { getTasks } from "@server/queries",
    }

    Do this for all external imports in your .wasp file. After you're done, there shouldn't be any occurences of the string "@ext".

That's it! You should now have a fully working Wasp project in the foo directory.

[NEW FEATURE] TypeScript support

Wasp now allows you to write TS and TSX files. Some (but not all) Wasp features come with type definitions. Except more type definitions and even better integration with TypeScript in future versions!

[NEW FEATURE] Dockerfile customization

You can now customize the default Wasp Dockerfile by either extending/replacing our build stages or using your own custom logic. To make use of this feature, simply add a Dockerfile to the root of your project and it will be appended to the bottom of the existing Wasp Dockerfile.

[NEW FEATURE] Tailwind CSS support

You can now use the Tailwind CSS framework in your project by simply adding two config files. Check out the Integrations section of our Docs for more!

Don't miss a new wasp release

NewReleases is sending notifications on new releases.