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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

@mui/material@5.11.0 - js files has es6 syntax, which causes jest tests to stop working #35489

Closed
2 tasks done
erik-d opened this issue Dec 14, 2022 · 4 comments
Closed
2 tasks done
Assignees
Labels
core Infrastructure work going on behind the scenes status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@erik-d
Copy link

erik-d commented Dec 14, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 馃暪

Link to live example: None

Steps:

  1. Install @mui/material@5.10.17
  2. view node_modules/@mui/material/styles/useTheme.js (commonjs style)
  3. Install @mui/material@5.11.0
  4. view same file, now es6/2015

Current behavior 馃槸

Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

[... just different suggestion on how to configure jest]

Details:

/<path to my repository>/node_modules/@mui/material/styles/useTheme.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import * as React from 'react';
                                                                                  ^^^^^^

Downgrade to e.g. 5.10.17, these errors do not occur

Expected behavior 馃

Tests should pass

Context 馃敠

What I've seen so far, only affects jest tests.

Your environment 馃寧

npx @mui/envinfo
  No browser, using node 16
  I apologise, using npx @mui/envinfo hangs on my macbook (15-inch, 2016), macOS Monteray (12.6)
  Using typescript, and I'm sure it is not the issue, tsconfig.json:
  {
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "composite": true,
    "declaration": true,
    "declarationDir": "dist/types",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react-jsx",
    "jsxImportSource": "@emotion/react",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": false,
    "noFallthroughCasesInSwitch": true,
    "outDir": "dist",
    "resolveJsonModule": true,
    "strict": true,
    "target": "es5",
//    "types": ["@emotion/react/types/css-prop"],
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    ".storybook/**/*.ts",
    ".storybook/**/*.tsx",
    "mdx.d.ts",
  ],
}
@erik-d erik-d added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 14, 2022
@erik-d
Copy link
Author

erik-d commented Dec 14, 2022

Issue #35480 do not describe what I've encountered, so I rather posted my own report.

@erik-d erik-d changed the title @mui/material@5.11.0 - js files has es6 syntax, which causes e.g. jest tests to stop working @mui/material@5.11.0 - js files has es6 syntax, which causes jest tests to stop working Dec 14, 2022
@zannager zannager added the core Infrastructure work going on behind the scenes label Dec 15, 2022
@siriwatknp
Copy link
Member

@michaldudak Did we change anything related to the build script?

@michaldudak
Copy link
Member

Nothing I'm aware of should change this. I'll investigate it right away.

@michaldudak michaldudak added regression A bug, but worse and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 15, 2022
@michaldudak
Copy link
Member

The current state of things is the correct one. In 5.10.3, we inadvertently switched our main bundle build from ESM(-ish) to CJS. Thanks to #35324, the previous format is restored.

For Jest to work, use a transpiler such as Babel, as described in the docs: https://jestjs.io/docs/getting-started#using-babel

@michaldudak michaldudak closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2022
@michaldudak michaldudak added status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed regression A bug, but worse labels Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

4 participants