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

Update swc_core to v0.75.23 #48098

Merged
merged 38 commits into from
Apr 18, 2023
Merged

Update swc_core to v0.75.23 #48098

merged 38 commits into from
Apr 18, 2023

Conversation

padmaia
Copy link
Member

@padmaia padmaia commented Apr 7, 2023

@ijjk ijjk added Turbopack Related to Turbopack with Next.js. created-by: Turbopack team PRs by the Turbopack team. type: next labels Apr 7, 2023
jridgewell
jridgewell previously approved these changes Apr 7, 2023
@ijjk
Copy link
Member

ijjk commented Apr 7, 2023

Failing test suites

Commit: 9274d5a

pnpm testheadless test/integration/link-with-multiple-child/test/index.test.js

  • single child

  • multiple child with default legacyBehavior

  • multiple child with forced legacyBehavior=false

Expand output

● single child

TypeError: Cannot read properties of null (reading 'useRef')

  363 |       // eslint-disable-next-line react-hooks/rules-of-hooks
  364 |       const hasWarned = React.useRef(false)
> 365 |       if (props.prefetch && !hasWarned.current) {
      |                                        ^
  366 |         hasWarned.current = true
  367 |         console.warn(
  368 |           'Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://nextjs.org/docs/messages/prefetch-true-deprecated'

  at Object.current [as useRef] (../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.development.js:1630:21)
  at LinkComponent (../packages/next/src/client/link.tsx:365:40)
  at renderWithHooks (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:10295:18)
  at updateForwardRef (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:14311:20)
  at beginWork$1 (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:17005:16)
  at beginWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:25733:14)
  at performUnitOfWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24582:12)
  at workLoopSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24295:5)
  at renderRootSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24260:7)
  at recoverFromConcurrentError (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23475:20)
  at performConcurrentWorkOnRoot (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23381:22)
  at flushActQueue (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2943:32)
  at act (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2830:9)
  at ../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/act-compat.js:57:25
  at renderRoot (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:157:26)
  at render (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:244:10)
  at Object.<anonymous> (integration/link-with-multiple-child/test/index.test.js:8:9)
  at TestScheduler.scheduleTests (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/TestScheduler.js:333:13)
  at runJest (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/runJest.js:387:19)
  at _run10000 (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:408:7)
  at runCLI (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:261:3)

● multiple child with default legacyBehavior

TypeError: Cannot read properties of null (reading 'useRef')

  363 |       // eslint-disable-next-line react-hooks/rules-of-hooks
  364 |       const hasWarned = React.useRef(false)
> 365 |       if (props.prefetch && !hasWarned.current) {
      |                                        ^
  366 |         hasWarned.current = true
  367 |         console.warn(
  368 |           'Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://nextjs.org/docs/messages/prefetch-true-deprecated'

  at Object.current [as useRef] (../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.development.js:1630:21)
  at LinkComponent (../packages/next/src/client/link.tsx:365:40)
  at renderWithHooks (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:10295:18)
  at updateForwardRef (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:14311:20)
  at beginWork$1 (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:17005:16)
  at beginWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:25733:14)
  at performUnitOfWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24582:12)
  at workLoopSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24295:5)
  at renderRootSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24260:7)
  at recoverFromConcurrentError (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23475:20)
  at performConcurrentWorkOnRoot (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23381:22)
  at flushActQueue (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2943:32)
  at act (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2830:9)
  at ../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/act-compat.js:57:25
  at renderRoot (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:157:26)
  at render (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:244:10)
  at Object.<anonymous> (integration/link-with-multiple-child/test/index.test.js:13:9)
  at TestScheduler.scheduleTests (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/TestScheduler.js:333:13)
  at runJest (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/runJest.js:387:19)
  at _run10000 (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:408:7)
  at runCLI (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:261:3)

● multiple child with forced legacyBehavior=false

TypeError: Cannot read properties of null (reading 'useRef')

  363 |       // eslint-disable-next-line react-hooks/rules-of-hooks
  364 |       const hasWarned = React.useRef(false)
> 365 |       if (props.prefetch && !hasWarned.current) {
      |                                        ^
  366 |         hasWarned.current = true
  367 |         console.warn(
  368 |           'Next.js auto-prefetches automatically based on viewport. The prefetch attribute is no longer needed. More: https://nextjs.org/docs/messages/prefetch-true-deprecated'

  at Object.current [as useRef] (../node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react.development.js:1630:21)
  at LinkComponent (../packages/next/src/client/link.tsx:365:40)
  at renderWithHooks (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:10295:18)
  at updateForwardRef (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:14311:20)
  at beginWork$1 (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:17005:16)
  at beginWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:25733:14)
  at performUnitOfWork (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24582:12)
  at workLoopSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24295:5)
  at renderRootSync (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:24260:7)
  at recoverFromConcurrentError (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23475:20)
  at performConcurrentWorkOnRoot (../node_modules/.pnpm/react-dom@18.3.0-next-b14f8da15-20230403_ofa6wqx4hdiriqsbsgzpdfumle/node_modules/react-dom/cjs/react-dom.development.js:23381:22)
  at flushActQueue (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2943:32)
  at act (../node_modules/.pnpm/react@18.3.0-next-b14f8da15-20230403/node_modules/react/cjs/react.development.js:2830:9)
  at ../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/act-compat.js:57:25
  at renderRoot (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:157:26)
  at render (../node_modules/.pnpm/@testing-library+react@13.0.0_3sjfv4i2tt6m45nfj3asqbemne/node_modules/@testing-library/react/dist/pure.js:244:10)
  at Object.<anonymous> (integration/link-with-multiple-child/test/index.test.js:23:9)
  at TestScheduler.scheduleTests (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/TestScheduler.js:333:13)
  at runJest (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/runJest.js:387:19)
  at _run10000 (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:408:7)
  at runCLI (../node_modules/.pnpm/@jest+core@27.0.6_ts-node@10.9.1/node_modules/@jest/core/build/cli/index.js:261:3)

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

@socket-security
Copy link

socket-security bot commented Apr 7, 2023

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
@swc/helpers@0.5.0 None +0 kdy1

🚮 Removed packages: @swc/core@1.2.203

@kdy1 kdy1 self-assigned this Apr 8, 2023
@kdy1 kdy1 force-pushed the kdy1/swc-0-74 branch 2 times, most recently from 7507ba3 to 3c38896 Compare April 8, 2023 06:01
@@ -199,7 +199,7 @@ async function postProcessHTML(
: null,
process.env.NEXT_RUNTIME !== 'edge' && renderOpts.optimizeFonts
? async (html: string) => {
const getFontDefinition = (url: string): string => {
const getFontDefinition = (url: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed WEB-875

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed by swc-project/swc#7232

@himself65
Copy link
Contributor

any updates?

@kdy1
Copy link
Member

kdy1 commented Apr 12, 2023

Investigation

export const NextDynamicNoSSRServerComponent = dynamic(
  () => import('../text-dynamic-no-ssr-server'),
  {
    ssr: false,
  }
)

this is the cause, and it works if I remove ssr: false

@kdy1 kdy1 requested a review from a team as a code owner April 12, 2023 06:52
@kdy1
Copy link
Member

kdy1 commented Apr 12, 2023

Further investigation:

  • processBinaryChunk is from react.
  • Patching ssr to false from next/dynamic does not work.
  • Execution order is a bit strange
LoadableOptions {
  loading: [Function: loading],
  ssr: false,
  modules: [ 'legacy/no-ssr.js -> ../../ui/pure-client' ]
}
isServerSide true
Loading:  [Function: loading]
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at U (/private/var/folders/pw/7l7d6f6s6ngb9z17pc912mtc0000gn/T/next-install-5bc17e2a036d2273d8f55cf46c46aea781da64281b1000bf9cb7582d1923ca4b/node_modules/.pnpm/file+..+next-repo-1c149e8656005f23f855f684eb57e24c_ea2336ebcj5zuuo46igxqabumu/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js:22:196)
    at c (/private/var/folders/pw/7l7d6f6s6ngb9z17pc912mtc0000gn/T/next-install-5bc17e2a036d2273d8f55cf46c46aea781da64281b1000bf9cb7582d1923ca4b/node_modules/.pnpm/file+..+next-repo-1c149e8656005f23f855f684eb57e24c_ea2336ebcj5zuuo46igxqabumu/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js:25:307)

Error occurred prerendering page "/dynamic". Read more: https://nextjs.org/docs/messages/prerender-error
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at U (/private/var/folders/pw/7l7d6f6s6ngb9z17pc912mtc0000gn/T/next-install-5bc17e2a036d2273d8f55cf46c46aea781da64281b1000bf9cb7582d1923ca4b/node_modules/.pnpm/file+..+next-repo-1c149e8656005f23f855f684eb57e24c_ea2336ebcj5zuuo46igxqabumu/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js:22:196)
    at c (/private/var/folders/pw/7l7d6f6s6ngb9z17pc912mtc0000gn/T/next-install-5bc17e2a036d2273d8f55cf46c46aea781da64281b1000bf9cb7582d1923ca4b/node_modules/.pnpm/file+..+next-repo-1c149e8656005f23f855f684eb57e24c_ea2336ebcj5zuuo46igxqabumu/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js:25:307)
info  - Generating static pages (0/4)
el: {
  '$$typeof': Symbol(react.element),
  type: [Function: loading],
  key: null,
  ref: null,
  props: { error: null, isLoading: true, pastDelay: false, timedOut: false },
  _owner: null
}
Render loading:  { error: null, isLoading: true, pastDelay: false }
info  - Generating static pages (1/4)
info  - Generating static pages (2/4)

@kdy1 kdy1 force-pushed the kdy1/swc-0-74 branch 2 times, most recently from c63e80d to 21bbd46 Compare April 13, 2023 04:01
@kdy1
Copy link
Member

kdy1 commented Apr 13, 2023

Further investigation:

__next_f of ((self as any).__next_f = (self as any).__next_f || []) has wrong data. I'll check code responsible for __next_f

@kdy1
Copy link
Member

kdy1 commented Apr 13, 2023

Investigation

Some modules in next.js are removed from client-reference-manifest.json.

ssrModuleMapping

image

clientModules

(next.js part)

image

image

image

image

(e2e test app part)

image

@sokra sokra marked this pull request as draft April 18, 2023 03:51
sokra
sokra previously approved these changes Apr 18, 2023
@kdy1 kdy1 marked this pull request as ready for review April 18, 2023 04:48
@kdy1 kdy1 enabled auto-merge April 18, 2023 04:48
@kdy1 kdy1 disabled auto-merge April 18, 2023 04:48
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vercel/turborepo#4470 is approved/merged along with this PR

@kdy1 kdy1 changed the title Update swc_core to v0.75.22 Update swc_core to v0.75.23 Apr 18, 2023
@sokra sokra merged commit 43d09ce into canary Apr 18, 2023
@sokra sokra deleted the kdy1/swc-0-74 branch April 18, 2023 06:59
sokra added a commit that referenced this pull request Apr 18, 2023
### What?

swc_core dependencies update

### Why?

follow-up from #48098
@Kinbaum
Copy link
Contributor

Kinbaum commented Apr 18, 2023

Hello, was hoping to get some assistance with an issue that I believe this PR introduced in 13.3.1-canary.12.
Up until this point, I have been using cypress for component testing.

When a component contained a hook like usePathname or useRouter, I was able to successfully mock those by doing the following:

import * as NextNavigation from 'next/navigation';

describe('test...', () => {
    it('should...', () => {
        const pathname = cy.stub().as('usePathname').returns('/en/public');
        cy.stub(NextNavigation, 'usePathname').returns(pathname());
    })
})

This approach worked for me up until this canary version was release. Now it throws the following error:

(uncaught exception) Error: invariant expected app router to be mounted

Does anyone have a suggestion on how to resolve this?

@Kinbaum
Copy link
Contributor

Kinbaum commented Apr 19, 2023

Update: for those who come across this as well, I managed to solve by creating my own mount function specifically for components that depend on these hooks. Here's an abbreviated implementation:

import { MountOptions, MountReturn, mount } from 'cypress/react18';
import { AppRouterContext } from 'next/dist/shared/lib/app-router-context';
import { PathnameContext } from 'next/dist/shared/lib/hooks-client-context';

declare global {
    namespace Cypress {
        interface Chainable {
            mount: typeof mount;
            nextMount: (jsx: React.ReactNode, options?: Partial<MountOptions & {
                pathname?: string;
            }>) => Chainable<MountReturn>;
        }
    }
}

Cypress.Commands.add('mount', mount);

Cypress.Commands.add('nextMount', (component, options) => {
    const router = {
        back: cy.stub().as('router:back'),
        forward: cy.stub().as('router:forward'),
        prefetch: cy.stub().as('router:prefetch'),
        push: cy.stub().as('router:push'),
        reload: cy.stub().as('router:reload'),
        refresh: cy.stub().as('router:refresh'),
        replace: cy.stub().as('router:replace')
    };

    const pathname = options?.pathname ?? '/';

    return mount(
        <AppRouterContext.Provider value={ router }>
            <PathnameContext.Provider value={ pathname }>
                { component }
            </PathnameContext.Provider>
        </AppRouterContext.Provider>
    );
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js. type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEXT-939] SIGSEGV on next build with 13.2.4
10 participants