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

Swc coverage plugin breaking with app folder #42580

Closed
1 task done
gaetleba opened this issue Nov 7, 2022 · 2 comments
Closed
1 task done

Swc coverage plugin breaking with app folder #42580

gaetleba opened this issue Nov 7, 2022 · 2 comments
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.

Comments

@gaetleba
Copy link

gaetleba commented Nov 7, 2022

Verify canary release

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

Provide environment information

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 16.13.2
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.0.3-canary.0
      eslint-config-next: 13.0.2
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Using the new app folder with the plugin swc-plugin-coverage-instrument breaks.
I get the following error when trying to visit a simple index page:

error - (sc_server)\node_modules\next\dist\shared\lib\app-router-context.js (10:40) @ eval
error - TypeError: _react.default.createContext is not a function
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/shared/lib/app-router-context.js:297:77)
    at Object.(sc_server)/./node_modules/next/dist/shared/lib/app-router-context.js (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\app\page.js:920:1)
    at __webpack_require__ (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/client/components/app-router.js:2314:61)
    at Object.(sc_server)/./node_modules/next/dist/client/components/app-router.js (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\app\page.js:197:1)
    at __webpack_require__ (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\webpack-runtime.js:33:42)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fpage&appPaths=%2Fpage&pagePath=private-next-app-dir%2Fpage.tsx&appDir=C%3A%5CUsers%5CWarrows%5Cworkspace%5Crepronext%5Cswc-coverage%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=C%3A%5CUsers%5CWarrows%5Cworkspace%5Crepronext%5Cswc-coverage&isDev=true&tsconfigPath=tsconfig.json!:28:24)
    at Object.(sc_server)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fpage&appPaths=%2Fpage&pagePath=private-next-app-dir%2Fpage.tsx&appDir=C%3A%5CUsers%5CWarrows%5Cworkspace%5Crepronext%5Cswc-coverage%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=C%3A%5CUsers%5CWarrows%5Cworkspace%5Crepronext%5Cswc-coverage&isDev=true&tsconfigPath=tsconfig.json! (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\app\page.js:99:1)
    at __webpack_require__ (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\webpack-runtime.js:33:42)
    at __webpack_exec__ (C:\Users\Warrows\workspace\repronext\swc-coverage\.next\server\app\page.js:974:39) {
  page: '/'
}
null

It's possible to avoid the problem by using babel (with babel-plugin-istanbul) instead of swc or by staying with old pages instead of the app folder.

Expected Behavior

The index page should load

Link to reproduction

https://github.com/gaetleba/swc-plugin-coverage-instrument-bug-reproduction

To Reproduce

Try to open the index page and you should get the error.

@gaetleba gaetleba added the bug Issue was opened via the bug report template. label Nov 7, 2022
@timneutkens timneutkens added the area: app App directory (appDir: true) label Nov 7, 2022
@kwonoj
Copy link
Contributor

kwonoj commented Nov 7, 2022

kwonoj/swc-plugin-coverage-instrument#183 (comment)

I did a quick try and looks like this is not a next.js upstream bug, more of a bug in the plugin. Probably, this issue can be closed.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2022

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 Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants