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

compiler.relay must NOT have additional properties #38967

Closed
1 task done
artola opened this issue Jul 24, 2022 · 15 comments · Fixed by #39010
Closed
1 task done

compiler.relay must NOT have additional properties #38967

artola opened this issue Jul 24, 2022 · 15 comments · Fixed by #39010
Labels
bug Issue was opened via the bug report template.

Comments

@artola
Copy link

artola commented Jul 24, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
Binaries:
  Node: 16.15.0
  npm: 8.5.5
  Yarn: 3.2.0
  pnpm: N/A
Relevant packages:
  next: 12.2.4-canary.0
  eslint-config-next: 12.1.6
  react: 0.0.0-experimental-c1f5884ff-20220705
  react-dom: 0.0.0-experimental-c1f5884ff-20220705

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

This bug happens in the last canary, a week ago it was ok. The compiler works, that means that the values passed are properly arriving to the compiler, but we have a bunch of disturbing warning messages.

This config for a relay project warns:

module.exports = {
// ..
  compiler: {
    relay: {
      // THIS 3 ARE OK
      src: 'scenes',
      schema: 'schema/server.graphql',
      language: 'flow',

      // ANYTHING ELSE WARNS      
      customScalars: {
        DateTime: 'string',
        Upload: 'File',
      },
    }
  }
warn  - Invalid next.config.js options detected: 
[
  {
    "instancePath": "/compiler/relay",
    "schemaPath": "#/properties/compiler/properties/relay/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "schema"
    },
    "message": "must NOT have additional properties"
  },
  {
    "instancePath": "/compiler/relay",
    "schemaPath": "#/properties/compiler/properties/relay/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "schemaExtensions"
    },
    "message": "must NOT have additional properties"
  },
  {
    "instancePath": "/compiler/relay",
    "schemaPath": "#/properties/compiler/properties/relay/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "customScalars"
    },
    "message": "must NOT have additional properties"
  },
  {
    "instancePath": "/compiler/relay",
    "schemaPath": "#/properties/compiler/properties/relay/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "noFutureProofEnums"
    },
    "message": "must NOT have additional properties"
  }
] 

Expected Behavior

Must not be warnings for needed parameters in compiler.relay.

Link to reproduction

https://stackblitz.com/edit/vercel-next-js-gjket8?file=next.config.js

To Reproduce

Start on dev and see the warnings in the console.

@artola artola added the bug Issue was opened via the bug report template. label Jul 24, 2022
@KieraDOG
Copy link

KieraDOG commented Jul 25, 2022

We are having the same warning after upgrade to next@12.2.3 this morning

const { withSentryConfig } = require('@sentry/nextjs')
const withPlugins = require('next-compose-plugins')
const withTM = require('next-transpile-modules')

module.exports = withPlugins([
  withTM(['...']),
  (nextConfig) => withSentryConfig(nextConfig, { silent: true }), 
], {
  assetPrefix: process.env.ASSET_PREFIX || '',
  basePath: process.env.BASE_PATH || '',
  reactStrictMode: true,
  generateBuildId: () => process.env.BUILD_NUMBER || null,
  eslint: {
    dirs: ['src'],
  },
  env: {
    ENVIRONMENT: process.env.ENVIRONMENT,
    BASE_PATH: process.env.BASE_PATH,
  },
})

@rikers
Copy link

rikers commented Jul 25, 2022

Same type of warning, no problem with next@12.2.2:

[
	{
		'instancePath': '',
		'schemaPath': '#/additionalProperties',
		'keyword': 'additionalProperties',
		'params': {
			'additionalProperty': 'webpackDevMiddleware'
		},
		'message': 'must NOT have additional properties'
	},
	{
		'instancePath': '',
		'schemaPath': '#/additionalProperties',
		'keyword': 'additionalProperties',
		'params': {
			'additionalProperty': 'configOrigin'
		},
		'message': 'must NOT have additional properties'
	},
	{
		'instancePath': '',
		'schemaPath': '#/additionalProperties',
		'keyword': 'additionalProperties',
		'params': {
			'additionalProperty': 'target'
		},
		'message': 'must NOT have additional properties'
	},
	{
		'instancePath': '',
		'schemaPath': '#/additionalProperties',
		'keyword': 'additionalProperties',
		'params': {
			'additionalProperty': 'analyticsId'
		},
		'message': 'must NOT have additional properties'
	},
	{
		'instancePath': '',
		'schemaPath': '#/additionalProperties',
		'keyword': 'additionalProperties',
		'params': {
			'additionalProperty': 'webpack5'
		},
		'message': 'must NOT have additional properties'
	},
	{
		'instancePath': '/amp/canonicalBase',
		'schemaPath': '#/properties/amp/properties/canonicalBase/minLength',
		'keyword': 'minLength',
		'params': {
			'limit': 1
		},
		'message': 'must NOT have fewer than 1 characters'
	},
	{
		'instancePath': '/assetPrefix',
		'schemaPath': '#/properties/assetPrefix/minLength',
		'keyword': 'minLength',
		'params': {
			'limit': 1
		},
		'message': 'must NOT have fewer than 1 characters'
	},
	{
		'instancePath': '/basePath',
		'schemaPath': '#/properties/basePath/minLength',
		'keyword': 'minLength',
		'params': {
			'limit': 1
		},
		'message': 'must NOT have fewer than 1 characters'
	},
	{
		'instancePath': '/experimental/outputFileTracingRoot',
		'schemaPath': '#/properties/experimental/properties/outputFileTracingRoot/minLength',
		'keyword': 'minLength',
		'params': {
			'limit': 1
		},
		'message': 'must NOT have fewer than 1 characters'
	},
	{
		'instancePath': '/generateEtags',
		'schemaPath': '#/properties/generateEtags/isFunction',
		'keyword': 'isFunction',
		'params': {},
		'message': 'must pass "isFunction" keyword validation'
	},
	{
		'instancePath': '/i18n',
		'schemaPath': '#/properties/i18n/type',
		'keyword': 'type',
		'params': {
			'type': 'object'
		},
		'message': 'must be object'
	}
];

dirkdev98 added a commit to lightbasenl/scaffold that referenced this issue Jul 25, 2022
Note this ignores the Next.js update to v12.2.3 since it adds warnings about unknown next.config.js properties; see vercel/next.js#38967

Closes #261, #263, #264, #265, #266, #267, #268
dirkdev98 added a commit to lightbasenl/scaffold that referenced this issue Jul 25, 2022
Note this ignores the Next.js update to v12.2.3 since it adds warnings about unknown next.config.js properties; see vercel/next.js#38967

Closes #261, #263, #264, #265, #266, #267, #268
@bobevsky
Copy link

bobevsky commented Jul 25, 2022

Same type of warnings appear for me as well on next@12.2.2 - i had to downgrade to 12.1.4. Also with 12.2.2 i am running into an error if i try to use fetch inside my middleware (no problems with 12.1.4).

image

Edit: using fetch inside middleware actually does not work for me in any version of nextjs :(

Edit: i can confirm that fetch inside middleware works for me in next@12.2.2 - related to this one #38963 where it also states that fetch inside middleware works for that version only.

@MonstraG
Copy link

Same warnings with additional propertes in i18n from next-i18next.
(fallbackLng, keySeparator, nsSeparator, localePath, reloadOnPrerender)

@Jonashr
Copy link

Jonashr commented Jul 26, 2022

Getting this message here. Same with v12.2.

[
  {
    "instancePath": "/images/path",
    "schemaPath": "#/properties/images/properties/path/type",
    "keyword": "type",
    "params": {
      "type": "string"
    },
    "message": "must be string"
  }
] 

Due to images config.

  images: {
    path: ['https://my-super-fun-domain.imgix.net'],
    loader: 'imgix',
    dangerouslyAllowSVG: true,
    contentSecurityPolicy: 'default-src \'self\'; script-src \'none\'; sandbox;',
  },

@MonstraG
Copy link

@ijjk , #39010 won't fix same problems with other sections like i18n and images, right? Do I need to create a separate issue for that?

@ijjk
Copy link
Member

ijjk commented Jul 26, 2022

@MonstraG the i18n one appears to be valid warnings as you are adding invalid config, this should be fixed in next-i18next itself.

@ijjk
Copy link
Member

ijjk commented Jul 26, 2022

@Jonashr the config error you are seeing is also valid images.path can not be an array.

@gascenciom1998
Copy link

Seeing these kinds of warnings after updating to react 18? can they be safely ignored?

@ghost
Copy link

ghost commented Jul 28, 2022

@ijjk this is my config file

const shell = require('shelljs');
const withPlugins = require('next-compose-plugins');
const optimizedImages = require('next-optimized-images');
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
const RollbarSourcemapPlugin = require('rollbar-sourcemap-webpack-plugin');

const isDev = process.env.NODE_ENV !== 'production';

const packages = JSON.parse(
  shell.exec('npx lerna list --all --json', {
    silent: true,
  }).stdout,
);

const packageNames = packages
  .reduce((a, currentPackage) => [...a, currentPackage.name], [])
  .filter(item => item.includes('@assets'));

const withTM = require('next-transpile-modules')(packageNames);

const nextConfig = {
  async redirects() {
    return [
      {
        source: '/signup',
        destination: '/',
        permanent: false,
      },
    ];
  },
  productionBrowserSourceMaps: true,
  generateBuildId: async () => {
    if (process.env.NEXT_PUBLIC_COMMIT_HASH) {
      return process.env.NEXT_PUBLIC_COMMIT_HASH;
    }
    // return null to use default next.js build id if there is no commit hash
    return null;
  },
  assetPrefix: isDev ? 'http://localhost:3000' : '',
  webpack: (config, { dev, buildId }) => {
    config.module.rules.push({
      test: /\.(eot|woff|woff2|ttf)$/,
      type: 'asset/resource',
    });

    config.plugins.push(
      new FilterWarningsPlugin({
        exclude: /mini-css-extract-plugin[^]*Conflicting order between:/,
      }),
    );

    // to upload source maps to rollbar, we follow this example as reference
    // https://github.com/thredup/rollbar-sourcemap-webpack-plugin/blob/c7569ddf99fc01041f12a3d4b2998ea0f93a8dbe/examples/next-js/next.config.js
    if (!dev) {
      // Generate a common `id` to be used when initializing Rollbar & when uploading the sourcemaps.
      // This could be any common value, as long as it is used in `_document.js` when initializing Rollbar.
      const codeVersion = JSON.stringify(buildId);

      config.plugins.push(
        new RollbarSourcemapPlugin({
          accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
          version: codeVersion,
          publicPath: `${process.env.FRONTEND_ENDPOINT}/_next/`,
        }),
      );
    }

    return config;
  },
};

module.exports = withPlugins(
  [
    [withTM()],
    {
      images: {
        disableStaticImages: true,
        dangerouslyAllowSVG: true,
        contentSecurityPolicy:
          "default-src 'self'; script-src 'none'; sandbox;",
      },
    },
    [
      optimizedImages,
      {
        optimizeImagesInDev: true,
      },
    ],
  ],
  nextConfig,
);

and i get the same error:

frontend: warn  - Invalid next.config.js options detected: 
frontend: [
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "webpackDevMiddleware"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "configOrigin"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "target"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "analyticsId"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "webpack5"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "",
frontend:     "schemaPath": "#/additionalProperties",
frontend:     "keyword": "additionalProperties",
frontend:     "params": {
frontend:       "additionalProperty": "optimizeImagesInDev"
frontend:     },
frontend:     "message": "must NOT have additional properties"
frontend:   },
frontend:   {
frontend:     "instancePath": "/amp/canonicalBase",
frontend:     "schemaPath": "#/properties/amp/properties/canonicalBase/minLength",
frontend:     "keyword": "minLength",
frontend:     "params": {
frontend:       "limit": 1
frontend:     },
frontend:     "message": "must NOT have fewer than 1 characters"
frontend:   },
frontend:   {
frontend:     "instancePath": "/assetPrefix",
frontend:     "schemaPath": "#/properties/assetPrefix/minLength",
frontend:     "keyword": "minLength",
frontend:     "params": {
frontend:       "limit": 1
frontend:     },
frontend:     "message": "must NOT have fewer than 1 characters"
frontend:   },
frontend:   {
frontend:     "instancePath": "/basePath",
frontend:     "schemaPath": "#/properties/basePath/minLength",
frontend:     "keyword": "minLength",
frontend:     "params": {
frontend:       "limit": 1
frontend:     },
frontend:     "message": "must NOT have fewer than 1 characters"
frontend:   },
frontend:   {
frontend:     "instancePath": "/experimental/outputFileTracingRoot",
frontend:     "schemaPath": "#/properties/experimental/properties/outputFileTracingRoot/minLength",
frontend:     "keyword": "minLength",
frontend:     "params": {
frontend:       "limit": 1
frontend:     },
frontend:     "message": "must NOT have fewer than 1 characters"
frontend:   },
frontend:   {
frontend:     "instancePath": "/generateEtags",
frontend:     "schemaPath": "#/properties/generateEtags/isFunction",
frontend:     "keyword": "isFunction",
frontend:     "params": {},
frontend:     "message": "must pass \"isFunction\" keyword validation"
frontend:   },
frontend:   {
frontend:     "instancePath": "/i18n",
frontend:     "schemaPath": "#/properties/i18n/type",
frontend:     "keyword": "type",
frontend:     "params": {
frontend:       "type": "object"
frontend:     },
frontend:     "message": "must be object"
frontend:   }
frontend: ] 
frontend: See more info here: https://nextjs.org/docs/messages/invalid-next-config

I'm not using much of the parameters, are they all mandatory fields?

@Jonashr
Copy link

Jonashr commented Jul 29, 2022

@ijjk Thanks, you are right. That removed the warning. I am still stuck with one more warning though.

[
  {
    "instancePath": "",
    "schemaPath": "#/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "enabled"
    },
    "message": "must NOT have additional properties"
  }
] 

This is coming from the @next/bundle-analyzer package.
enabled: process.env.ANALYZE === 'true',

Removing this line, removes the warning.

@ijjk
Copy link
Member

ijjk commented Jul 29, 2022

@Jonashr can you share your config the @next/bundle-analyzer package should not be adding an enabled field to the returned config as can be seen here

@TheThirdRace
Copy link

@ijjk

Given @Jonashr didn't share his config, I'll provide you with a basic one that will reproduce the problem.

const withPlugins = require('next-compose-plugins')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
	enabled: process.env.ANALYZE === 'true'
})

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
	reactStrictMode: true,
}

module.exports = withPlugins([[withBundleAnalyzer], nextConfig])

You correctly pointed out that @next/bundle-analyzer is adding enabled property to next.config.js.

I'm a bit confused after reading your comment. It's like you thought @next/bundle-analyzer was a third-party package and we should open a ticket in their repo... But @next/bundle-analyzer is part of NextJs, it's directly in the main repo in the packages folder https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer 😅

Would you need a new ticket for @next/bundle-analyzer so you can prioritize it?

@ijjk
Copy link
Member

ijjk commented Aug 12, 2022

@TheThirdRace my above comment was pointing out that @next/bundle-analyzer does not add enabled to the returned config as can be seen here https://github.com/vercel/next.js/blob/canary/packages/next-bundle-analyzer/index.js

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants