Skip to content

LATE_SETUP_CALL error with Next.js #12

Description

@rstacruz

Hi there! Great work with Twind... it's an amazing concept and I am really loving the API.

I tried integrating it with Next.js + Webpack 5 and got this error:

info  - ready on http://localhost:3000
Error: [LATE_SETUP_CALL] {}
    at withTwindDocument (/home/rsc/@dev/@rstacruz/til-2021/node_modules/@twind/next/document/document.cjs:38:27)
    at eval (webpack-internal:///./pages/_document.js:42:123)
    at Object../pages/_document.js (/home/rsc/@dev/@rstacruz/til-2021/.next/server/pages/_document.js:22:1)
    ...

A lot of times it's not really causing any issues (pages continue to work) but sometimes they cause Internal Server Error to show up for some pages.

package.json
  "dependencies": {
    "@twind/next": "^1.0.7",
    "next": "10.1.3",
    "next-mdx-remote": "^2.1.4",
    "twind": "^0.16.13",
  }
twind.config.js
import * as colors from 'twind/colors'
/** @type {import('twind').Configuration} */

export default {
  // mode: 'strict',
  theme: {
    extend: {
      borderColor: {
        line: colors.gray['200'],
      },
      textColor: {
        mute: colors.gray['600'],
        accent: colors.red['600'],
      },
    },
    fontFamily: {
      sans: ['Roboto', 'ui-sans', 'sans-serif'],
      serif: ['Eczar', 'ui-serif', 'Georgia', 'Cambria', 'sans-serif'],
    },
    maxWidth: {
      article: '580px',
    },
  },
}
pages/_document.js
import withTwindDocument from '@twind/next/document'
import twindConfig from '../twind.config'
export default withTwindDocument(twindConfig)
pages/_app.js
import twindConfig from '../twind.config'
import withTwindApp from '@twind/next/app'
import '../styles/globals.css'
import '@fontsource/eczar/400.css'
import '@fontsource/roboto/400.css'
import '@fontsource/roboto/700.css'
import { css, tw } from 'twind/css'

function MyApp({ Component, pageProps }) {
  // tw(
  //   css({
  //     ':global': { body: { '@apply': 'font-sans', },
  //     },
  //   })
  // )

  return <Component {...pageProps} />
}

export default withTwindApp(twindConfig, MyApp)
next.config.js
module.exports = {
  future: { webpack5: true },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions