Skip to content

Allow metadata related exports in TS plugin #45282

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

Merged
merged 2 commits into from
Jan 25, 2023
Merged

Allow metadata related exports in TS plugin #45282

merged 2 commits into from
Jan 25, 2023

Conversation

shuding
Copy link
Member

@shuding shuding commented Jan 25, 2023

This PR ensures that metadata and generateMetadata are valid exports for pages and layouts during the TS plugin check.

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have a helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • e2e tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have a helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running pnpm build && pnpm lint
  • The "examples guidelines" are followed from our contributing doc

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
shuding Shu Ding
@ijjk
Copy link
Member

ijjk commented Jan 25, 2023

Failing test suites

Commit: 991f35a

pnpm testheadless test/development/basic/hmr.test.ts

  • basic HMR, basePath: "/docs" > Error Recovery > should recover after webpack parse error in an imported file
Expand output

● basic HMR, basePath: "/docs" › Error Recovery › should recover after webpack parse error in an imported file

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `basic HMR, basePath: "/docs" Error Recovery should recover after webpack parse error in an imported file 2`

- Snapshot  - 3
+ Received  + 0

@@ -4,8 +4,5 @@
  | This
  | is
  > }}}
  | invalid
  | js
-
- Import trace for requested module:
- ./components/parse-error.xyz

  756 |             `"Failed to compile"`
  757 |           )
> 758 |           expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
      |                                                  ^
  759 |           "./components/parse-error.xyz
  760 |           Module parse failed: Unexpected token (3:0)
  761 |           You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

  at Object.<anonymous> (development/basic/hmr.test.ts:758:50)

Read more about building and testing Next.js in contributing.md.

pnpm testheadless test/e2e/middleware-general/test/index.test.ts

  • Middleware Runtime > with i18n > should rewrite correctly for non-SSG/SSP page
  • Middleware Runtime > without i18n > should rewrite correctly for non-SSG/SSP page
Expand output

● Middleware Runtime › with i18n › should rewrite correctly for non-SSG/SSP page

TIMED OUT: success

<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><meta name="next-head-count" content="2"><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills.js?ts=1674686248570"></script><script src="/_next/static/chunks/webpack.js?ts=1674686248570" defer=""></script><script src="/_next/static/chunks/main.js?ts=1674686248570" defer=""></script><script src="/_next/static/chunks/pages/_app.js?ts=1674686248570" defer=""></script><script src="/_next/static/chunks/pages/ssg/%5Bslug%5D.js?ts=1674686248570" defer=""></script><script src="/_next/static/development/_buildManifest.js?ts=1674686248570" defer=""></script><script src="/_next/static/development/_ssgManifest.js?ts=1674686248570" defer=""></script><noscript id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"><p id="ssg">/blog/[slug]</p><p id="query">{"slug":"first"}</p><p id="pathname">/ssg/[slug]</p><p id="as-path">/</p><p id="props">{"now":1674686248570,"params":{"slug":"first"}}</p></div><script src="/_next/static/chunks/react-refresh.js?ts=1674686248570"></script><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"now":1674686248570,"params":{"slug":"first"}},"__N_SSG":true},"page":"/ssg/[slug]","query":{"slug":"first"},"buildId":"development","isFallback":false,"gsp":true,"locale":"en","locales":["en","fr","nl"],"defaultLocale":"en","scriptLoader":[]}</script><div id="__next-build-watcher" style="position: fixed; bottom: 10px; right: 20px; width: 0px; height: 0px; z-index: 99999;"></div><next-route-announcer><p aria-live="assertive" id="__next-route-announcer__" role="alert" style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap; overflow-wrap: normal;">/</p></next-route-announcer><script src="/_next/static/chunks/pages/about/a.js"></script></body>

  559 |
  560 |   if (hardError) {
> 561 |     throw new Error('TIMED OUT: ' + regex + '\n\n' + content)
      |           ^
  562 |   }
  563 |   return false
  564 | }

  at check (lib/next-test-utils.js:561:11)
  at Object.<anonymous> (e2e/middleware-general/test/index.test.ts:425:7)

● Middleware Runtime › without i18n › should rewrite correctly for non-SSG/SSP page

TIMED OUT: success

<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><meta name="next-head-count" content="2"><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills.js?ts=1674686356453"></script><script src="/_next/static/chunks/webpack.js?ts=1674686356453" defer=""></script><script src="/_next/static/chunks/main.js?ts=1674686356453" defer=""></script><script src="/_next/static/chunks/pages/_app.js?ts=1674686356453" defer=""></script><script src="/_next/static/chunks/pages/ssg/%5Bslug%5D.js?ts=1674686356453" defer=""></script><script src="/_next/static/development/_buildManifest.js?ts=1674686356453" defer=""></script><script src="/_next/static/development/_ssgManifest.js?ts=1674686356453" defer=""></script><noscript id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"><p id="ssg">/blog/[slug]</p><p id="query">{"slug":"first"}</p><p id="pathname">/ssg/[slug]</p><p id="as-path">/</p><p id="props">{"now":1674686356454,"params":{"slug":"first"}}</p></div><script src="/_next/static/chunks/react-refresh.js?ts=1674686356453"></script><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"now":1674686356454,"params":{"slug":"first"}},"__N_SSG":true},"page":"/ssg/[slug]","query":{"slug":"first"},"buildId":"development","isFallback":false,"gsp":true,"scriptLoader":[]}</script><div id="__next-build-watcher" style="position: fixed; bottom: 10px; right: 20px; width: 0px; height: 0px; z-index: 99999;"></div><next-route-announcer><p aria-live="assertive" id="__next-route-announcer__" role="alert" style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap; overflow-wrap: normal;">/</p></next-route-announcer><script src="/_next/static/chunks/pages/about/a.js"></script></body>

  559 |
  560 |   if (hardError) {
> 561 |     throw new Error('TIMED OUT: ' + regex + '\n\n' + content)
      |           ^
  562 |   }
  563 |   return false
  564 | }

  at check (lib/next-test-utils.js:561:11)
  at Object.<anonymous> (e2e/middleware-general/test/index.test.ts:425:7)

Read more about building and testing Next.js in contributing.md.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@shuding shuding merged commit d5504ce into canary Jan 25, 2023
@shuding shuding deleted the shu/e27f branch January 25, 2023 22:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants