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

[nextjs] Fix tsconfig's path resolving #182

Merged
merged 2 commits into from
Nov 8, 2024
Merged

Conversation

brijeshb42
Copy link
Contributor

when trying to interpolate a styled component in another
Fixes #171

@brijeshb42 brijeshb42 marked this pull request as ready for review July 19, 2024 11:17
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 3, 2024
@chrros95
Copy link

Can I support the progress of this PR in any way?
I'm interested in it because as far as I researched the usage of the resolverFactory fixes the issue #211 as well. Reason for that is, that the resolverFactory searches for index files and doesn't expect the imported path to be file or a package.

@chris-skibro
Copy link

Would be amazing to see progress with this PR. Issue #171 is a blocker for us starting to use Pigment CSS. Is there anything we can do to help get this PR reviewed?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 26, 2024
@brijeshb42
Copy link
Contributor Author

brijeshb42 commented Sep 26, 2024

Would you be open to testing out the PR build package in your app and see if it's solving the issue for you ?

If yes, can you replace the Pigment CSS versions with these in your package.json ?

{
  "dependencies": {
    "@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/76e39c75/@pigment-css/react",
  },
  "devDependencies": {
    "@pigment-css/nextjs-plugin": "https://pkg.csb.dev/mui/pigment-css/commit/76e39c75/@pigment-css/nextjs-plugin"
  }
}

@chris-skibro
Copy link

Hi @brijeshb42, I've just swapped to the PR versions just now and unfortunately that didn't fix it for us. I was about to create a repro but @effektsvk has already provided a perfect repro of our problem at https://github.com/effektsvk/pigment-css-repro-next-js.

@brijeshb42
Copy link
Contributor Author

Thanks. I'll take a look.

@abriginets
Copy link

I've replaced

  "devDependencies": {
    "@pigment-css/nextjs-plugin": "^0.0.24"
  }

with

  "devDependencies": {
    "@pigment-css/nextjs-plugin": "https://pkg.csb.dev/mui/pigment-css/commit/76e39c75/@pigment-css/nextjs-plugin"
  }

and it fixed EISDIR errors for me. Is it possible to merge this in order to resolve #211 and keep working on #171 in a separate PR?

@royporter7
Copy link

The solution from @abriginets also worked for resolving the constant EISDIR errors I've been experiencing. I'd also strongly suggest a swift approval for the suggested pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 4, 2024
@valleywood
Copy link

Really hope that this PR can be merge and that there will be an updated package available soon. We're running into the EISDIR as well and are a stucked with our Pigment css migration until this is resolved 🙏

brijeshb42 and others added 2 commits November 8, 2024 12:03
when trying to internpolate a styled component in another
Fixes mui#171
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 8, 2024
Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍

@brijeshb42 brijeshb42 merged commit f3aea9a into mui:master Nov 8, 2024
12 checks passed
@brijeshb42 brijeshb42 deleted the fix/171 branch November 8, 2024 06:52
@valleywood
Copy link

Do you know when this fix will be released? 🙏

@brijeshb42
Copy link
Contributor Author

Already in the process - #308

@brijeshb42
Copy link
Contributor Author

Released v0.0.26

@valleywood
Copy link

valleywood commented Nov 8, 2024

Tried version 0.0.26 and I'm not getting the EISDIR however it fails to resolve my TS aliases in my styled components:
The @components alias works in all other files when it is not used in files that wraps code with styled from @mui/material-pigment-css

Basic example:

Openingstatus.tsx

import { styled } from '@mui/material-pigment-css';
import { Chip } from '@components/mui/Chip'; // Alias to wrapped component fails
// import { Chip } from '../../../mui/Chip'; // <= Works!

export const StyledChip = styled(Chip)(({ theme }) => {
  return {
    marginRight: theme.spacing(0.5),
  };
});

Chip.tsx:

import React from 'react';
import { default as MuiChip, ChipProps } from '@mui/material/Chip';

export const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
  function Chip(props, ref) {
    return <MuiChip {...props} ref={ref} />;
  },
);

tsconfig.json:

....
"compilerOptions": {
    "composite": true,
    "baseUrl": ".",
    "paths": {     
      "@components/*": [
        "scripts/components/*"
      ],
      "@icons/*": [
        "scripts/components/shared/icons/*"
      ],
      "@pages/*": [
        "scripts/pages/*"
      ],
      "@styles/*": [
        "styles/*"
      ],
    },
   ...
   }
...
}

=>

Error:

 prefix: "error"
    err: {
      "type": "Error",
      "message": "Cannot find module '@components/mui/Chip'\nRequire stack:\n- /project/scripts/components/sales/stores/OpeningStatus/OpeningStatus.styled.tsx in/project/scripts/components/sales/stores/OpeningStatus/OpeningStatus.styled.tsx\n",
      "stack":
          EvalError: Cannot find module '@components/mui/Chip'
          Require stack:
          - /project/scripts/components/sales/stores/OpeningStatus/OpeningStatus.styled.tsx in/project/scripts/components/sales/stores/OpeningStatus/OpeningStatus.styled.tsx
        
              at Module.evaluate (/project/node_modules/@wyw-in-js/transform/lib/module.js:224:13)
              at evaluate (/project/node_modules/@wyw-in-js/transform/lib/evaluators/index.js:14:5)
              at BaseAction.evalFile (/project/node_modules/@wyw-in-js/transform/lib/transform/generators/evalFile.js:35:43)
              at evalFile.next (<anonymous>)
              at /project/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:78
              at EventEmitter.action (/project/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:25:22)
              at BaseAction.emitAction (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:131:39)
              at nextFn (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:32)
              at processNext (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:111:28)
              at Object.next (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:120:9)
              at asyncActionRunner (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:39:102)
              at asyncActionRunner (/project/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:28)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async Object.transform (/project/node_modules/@wyw-in-js/transform/lib/transform.js:107:20)
              at async Object.transform (/project/node_modules/@pigment-css/unplugin/build/index.js:268:24)
              at async Object.transform (/project/node_modules/unplugin/dist/webpack/loaders/transform.js:120:15)
              

NOTE: I've used resolution/overrides to force all dependencies up to the 0.0.26 version of @pigment-css/react to get @mui/material-pigment-css to use the correct version

@brijeshb42
Copy link
Contributor Author

Could you share a POC with the error here ? It'll be easier to debug

@valleywood
Copy link

Could you share a POC with the error here ? It'll be easier to debug

You could use this repo pigment-css-repro-next-js

And just update these parts in package.json:

"@mui/material": "6.1.6",
"@mui/material-pigment-css": "6.1.6",
"@pigment-css/nextjs-plugin": "0.0.26",

"resolutions": {
"@pigment-css/react": "0.0.26"
}

@valleywood
Copy link

valleywood commented Nov 8, 2024

Could you share a POC with the error here ? It'll be easier to debug

@brijeshb42 Forked the other reproduction repo with updated (0.0.26) version here:
https://github.com/valleywood/pigment-css-repro-next-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

withPigment causes tsconfig compiler path option to not work
7 participants