Skip to content

[Bug]: TypeCheck failure when building / prerendering using NextJS v14.2.3Β #3202

@jaydubb12

Description

@jaydubb12

Describe the Bug

When user builds a NextJS project and utilizes the provided configuration the page pre-rendering & typeCheck will fail will fail due to an undefined property as outlined in the error below.

NOTE, there are other Typechecking issues with NextJS and Browserlist, but I have removed that dependency and config to rule that out.

Compilation Error

β¨― TypeError: Cannot read properties of undefined (reading 'xs') ```

### NextJS Config

## NextJS Config
```  experimental: {
   optimizePackageImports: ['@storefront-ui/react'],  ```


### Expected behavior

TypeChecking would be performed successfully

### Steps to reproduce

1. Install Next v14.1+
2. Install @storefront-iu/react as a dependency
3. Set the NextJS config file to utilize the following configs

experimental: {
optimizePackageImports: ['@storefront-ui/react'],

transpilePackages: ['@storefront-ui/react'], // transpile and bundle dependencies from local packages


4. Execute build command

### SFUI version

@storefront-ui/react2.6.0 and 2.6.3

### Framework

NextJS v14.1.0 and v14.2.3

### Node version

20.11.0

### Browser

Chrome 

### OS

MacOS Sonoma 14.5

### Relevant log output

```shell
Next.js 14.1.0
   - Local:        http://localhost:3000
   - Environments: .env

> [PWA] PWA support is disabled
> [PWA] PWA support is disabled
 βœ“ Ready in 3.8s
 β—‹ Compiling /middleware ...
 βœ“ Compiled /middleware in 743ms (109 modules)
 β—‹ Compiling / ...
 βœ“ Compiled / in 8s (1422 modules)
 β¨― node_modules/@storefront-ui/react/dist/components/SfLoaderCircular/SfLoaderCircular.cjs.js (1:128) @ xs
 β¨― TypeError: Cannot read properties of undefined (reading 'xs')
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at eval (./components/ExistingSelectionModal/ExistingSelectionModal.tsx:9:104)
    at (ssr)/./components/ExistingSelectionModal/ExistingSelectionModal.tsx (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/app/(default)/page.js:348:1)
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at eval (./builder-registry.ts:8:115)
    at (ssr)/./builder-registry.ts (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/app/(default)/page.js:293:1)
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at eval (page.tsx:10:75)
    at (ssr)/./app/(default)/page.tsx (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/app/(default)/page.js:271:1)
    at __webpack_require__ (/Users/jasonwolf/IdeaProjects/VirtualSelection/packages/showroom-ui/.next/server/webpack-runtime.js:33:42)
    at JSON.parse (<anonymous>)
null

Able to fix / change the documentation?

  • Yes
  • No

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions