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

import config in _app raises https://err.sh/vercel/next.js/invalid-page-config #16775

Closed
hk86 opened this issue Sep 2, 2020 · 10 comments · Fixed by #16834
Closed

import config in _app raises https://err.sh/vercel/next.js/invalid-page-config #16775

hk86 opened this issue Sep 2, 2020 · 10 comments · Fixed by #16834
Assignees
Labels
good first issue Easy to fix issues, good for newcomers
Milestone

Comments

@hk86
Copy link

hk86 commented Sep 2, 2020

Bug report

Describe the bug

I use the package @fortawesome/fontawesome-svg-core and since nextjs 9.5.3 it causes an error, due to this code in _app:

import { config } from '@fortawesome/fontawesome-svg-core';
config.autoAddCss = false;

The error:

error - ./pages/_app.js
Error: C:\Projects\nextapp\pages\_app.js: Invalid page config export found. Expected object but got import in file \pages\_app.js. See: https://err.sh/vercel/next.js/invalid-page-config

Is this behavior expected?

Workaround

An alias named import solves the issue:

import { config as fontawesomeConfig } from '@fortawesome/fontawesome-svg-core';
fontawesomeConfig.autoAddCss = false;
@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers kind: bug labels Sep 2, 2020
@timneutkens timneutkens added this to the backlog milestone Sep 2, 2020
@Timer Timer removed this from the backlog milestone Sep 2, 2020
@zipquote
Copy link

zipquote commented Sep 2, 2020

I'd like to work on this issue. May I give it a shot?

@Timer Timer added this to the backlog milestone Sep 2, 2020
@chadlittle
Copy link

This looks like a regression, can you verify it builds fine in 9.5.2?

@m0rg-dev
Copy link

m0rg-dev commented Sep 2, 2020

I'm experiencing what appears to be a similar issue - here's a minimal example:

package.json:

{
  "name": "nextjs-test-case",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "digitalagedragon",
  "license": "0BSD",
  "dependencies": {
    "next": "=9.5.3",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  }
}

pages/test.js:

import Head from "next/head";
import { config } from '../config';

export async function getServerSideProps() {
}

export default function Page() {
 return (
    <>
      <Head>
      </Head>
    </>
  );
}

config.js is an empty file in the top-level directory.

This builds successfully with Next 9.5.2, or if the config import is removed, or if the getServerSideProps export is removed.

@hk86
Copy link
Author

hk86 commented Sep 2, 2020

I'm not exactly sure, which 9.5.2 canary version raised the issue, I guess something around v9.5.3-canary.5.

@ijjk
Copy link
Member

ijjk commented Sep 2, 2020

Hi, this is most likely related to this PR, starting with adding the case where this error is incorrectly being shown to this test suite would be good

@zipquote
Copy link

zipquote commented Sep 3, 2020

I think this issue is beyond my skill level. Am not going anywhere with this. Someone else should take this up.

@klapec
Copy link

klapec commented Sep 3, 2020

This is causing my builds to fail after the 9.5.3 update.
I'm having

import {
  config,
  slotPropTypes,
  initialDataLayerDataPropTypes,
  contentDataLayerDataPropTypes,
} from '@config';

in one of my pages and it fails to build with

Invalid page config export found. Expected object but got import in file...

@config is resolved thanks to jsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@config": ["src/config"],
...
}

My getServerSideProps (actually wrapped with next-redux-wrapper) is referencing that imported config, is this the cause of my build failing after updating to 9.5.3?

@ijjk ijjk self-assigned this Sep 3, 2020
@ijjk ijjk added the point: 2 label Sep 3, 2020
@kodiakhq kodiakhq bot closed this as completed in #16834 Sep 4, 2020
@Timer Timer modified the milestones: backlog, iteration 8 Sep 4, 2020
kodiakhq bot pushed a commit that referenced this issue Sep 4, 2020
This corrects detecting of invalid page config exports and adds additional test cases for non-invalid config import/exports

Closes: #16775
@Vadorequest
Copy link
Contributor

Vadorequest commented Sep 7, 2020

I'm also encountering this issue Invalid page config export found. Expected object but got import in file /src/pages/_app.tsx

What should we do? Use a 4.5.3 canary version? Use a lower version until it's released as non-canary version?

Edit FYI: Using 9.5.4-canary.4 makes the error go away. 👍

@bivainis
Copy link

bivainis commented Sep 7, 2020

I got this error after updating to 9.5.3 just now. As a workaround I was able to alias my imports to avoid the error, e.g.:

import { config as MyConfig } from '@my-config`

Vadorequest added a commit to UnlyEd/next-right-now that referenced this issue Sep 7, 2020
Migrate to v9.5.3 is not possible due to [this bug](vercel/next.js#16775), app will be migrated to a canary version for now.
Vadorequest added a commit to UnlyEd/next-right-now that referenced this issue Sep 7, 2020
Migrate to v9.5.3 is not possible due to [this bug](vercel/next.js#16775), app will be migrated to a canary version for now.
HitoriSensei pushed a commit to HitoriSensei/next.js that referenced this issue Sep 26, 2020
This corrects detecting of invalid page config exports and adds additional test cases for non-invalid config import/exports

Closes: vercel#16775
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.