Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build a Redwood 4.2 app with Chakra-UI 2.x #1

Open
adriatic opened this issue Feb 27, 2023 · 1 comment
Open

How to build a Redwood 4.2 app with Chakra-UI 2.x #1

adriatic opened this issue Feb 27, 2023 · 1 comment

Comments

@adriatic
Copy link
Owner

adriatic commented Feb 27, 2023

Introduction

This article is the first part in the series of posts describing the use of several UI component libraries, starting with Chakra UI. The impetus for writing this article comes from Sergei's post in Discord with additional comments by dennemark and david-thyresson.

To illustrate the modifications needed to use Chakra-UI 2.x UI component library with Redwood 4.2 based application, I selected the egghead tutorial by Lazar Nikolov, a core team member of Chakra. The tutorial is organized as a series of lessons, each lesson being accessible as a branch of this repo. For example, lesson 3 is accessible as branch 3.

The Redwood 4.2 application I used is defined in the beginning of the RedwoodJS tutorial, up to the second page. I did not want to include any of the "UI constructs", built in the following tutorial chapters.

The final UI is shown below and the matching app is in RW-Chakra repository

image

Modifications to a minimalist Redwood 4.2 app

1. Typescript 4.2 import paths

The most relevant "discovery" is that the most recent Typescript changed the processing of import statements, manifested by

error TS2307: Cannot find module 'src' or its corresponding type declarations.

image

Note the wiggly lines stating how the import files cannot be found while the application behaves correctly

This issue is further discussed in Suppressing "The import path cannot end with a '.ts' extension" error, as well as in .d.ts Extensions Cannot Be Used In Import Paths. It is far from obvious how will this issue be addressed finally. I was able to "ignore" this situation by changing the original tsconfig.com (as generated by running the command yarn create redwood-app --ts ./redwoodblog) with this one

{
  "compilerOptions": {
    "noEmit": true,
    "allowJs": true,
    "esModuleInterop": true,
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "skipLibCheck": false,
    "baseUrl": "./",
    "rootDirs": [
      "./src",
      "../.redwood/types/mirror/api/src"
    ],
    "paths": {
      "src/*": [
        "./src/*",
        "../.redwood/types/mirror/api/src/*"
      ],
      "types/*": ["./types/*", "../types/*"],
      "@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/api"]
    },
    "typeRoots": [
      "../node_modules/@types",
      "./node_modules/@types"
    ],
    "types": ["jest"],
  },
  "include": [
    "src",
    "../.redwood/types/includes/all-*",
    "../.redwood/types/includes/api-*",
    "../types"
  ]
}

This configuration is a result of guessing what Typescript expects - I am hoping someone will be able to define the content more precisely.

@adriatic
Copy link
Owner Author

2. Other issues

This section reserved for eventual new findings, discovered in subsequent discussions to folow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant