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

Regression TypeScript parser: "Critical dependency: the request of a dependency is an expression" #12338

Closed
ayroblu opened this issue Feb 20, 2022 · 10 comments · Fixed by #12485

Comments

@ayroblu
Copy link

ayroblu commented Feb 20, 2022

Looks like a regression of #11269 and #11076

Environments:

  • Prettier Version: 2.5.1
  • Running Prettier via: webpack browser
  • Runtime: webpack v5
  • Operating System: macOS
  • Prettier plugins (if any): parser-typescript

Steps to reproduce:

Add this line of code to repo that has webpack:

return () => import("prettier/parser-typescript");

Expected behavior:
No warnings

Actual behavior:
Big webpack warning about "Critical dependency: the request of a dependency is an expression"

@brabeji
Copy link

brabeji commented Feb 22, 2022

I confirm this seems to be broken since 2.3.1.

@fisker fisker added this to the 2.6 milestone Mar 7, 2022
@fisker
Copy link
Member

fisker commented Mar 13, 2022

I'm not sure how to reproduce this.

@fisker fisker added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Mar 13, 2022
@fisker fisker modified the milestones: 2.6, 2.7 Mar 13, 2022
@fisker
Copy link
Member

fisker commented Mar 13, 2022

I've moved this to 2.7 milestone, to unblock v2.6 release, but we can release a patch release if necessary.

@liuzhaowei55
Copy link

I got this error on 2.6.0 , fallback 2.5.1to is OK

@fisker
Copy link
Member

fisker commented Mar 16, 2022

I can't help without a reproduction.

@ayroblu
Copy link
Author

ayroblu commented Mar 16, 2022

What's the issue I explain how to reproduce in the issue + linked to a bunch of other tickets which have further reproductions. Would you like me to create a repo for the reproduction?

@no-response no-response bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Mar 16, 2022
@fisker fisker closed this as completed Mar 16, 2022
@fisker fisker reopened this Mar 16, 2022
@fisker
Copy link
Member

fisker commented Mar 16, 2022

Yes, please.

@ayroblu
Copy link
Author

ayroblu commented Mar 17, 2022

With create react app:
https://github.com/ayroblu/prettier-bug

yarn create react-app prettier-bug
cd prettier-bug
yarn add prettier
vi src/App.js
yarn start

Main change looks like:

diff --git a/package.json b/package.json
index 4fcd053..2b6e0c5 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
     "@testing-library/jest-dom": "^5.14.1",
     "@testing-library/react": "^12.0.0",
     "@testing-library/user-event": "^13.2.1",
+    "prettier": "^2.6.0",
     "react": "^17.0.2",
     "react-dom": "^17.0.2",
     "react-scripts": "5.0.0",
diff --git a/src/App.js b/src/App.js
index 3784575..6b6dbe2 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,7 +1,8 @@
-import logo from './logo.svg';
-import './App.css';
+import logo from "./logo.svg";
+import "./App.css";
 
 function App() {
+  console.log(import("prettier/parser-typescript"));
   return (
     <div className="App">
       <header className="App-header">
diff --git a/yarn.lock b/yarn.lock
index 3cd6d5d..c898d48 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6852,6 +6852,11 @@ prelude-ls@~1.1.2:
   resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
   integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
 
+prettier@^2.6.0:
+  version "2.6.0"
+  resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4"
+  integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==
+
 pretty-bytes@^5.3.0, pretty-bytes@^5.4.1:
   version "5.6.0"
   resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb"

Output looks like:

image

I see that the error is different that what I originally posted, but I'm sure create react app is doing some more fancier things. By default raw webpack will spit out the error that I have shown in my original post.

@fisker
Copy link
Member

fisker commented Mar 18, 2022

Thank you, I'll take a look.

@fisker
Copy link
Member

fisker commented Mar 18, 2022

I was able to reproduce on CI now, https://github.com/prettier/prettier/runs/5595666668?check_suite_focus=true#step:6:6, I'll look into it.

@fisker fisker removed this from the 2.7 milestone Mar 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants