Js-Brecht / gatsby-plugin-pnpm

Provides PNPM compatible module resolvers to Webpack for Gatsby
MIT License
48 stars 6 forks source link

Gatsby 5 #18

Open 383bd03d opened 1 year ago

383bd03d commented 1 year ago

warn Plugin gatsby-plugin-pnpm is not compatible with your gatsby version 5.3.3 - It requires gatsby@~2.x.x || ~3.x.x || ~4.x.x

lnhrdt commented 1 year ago

@Js-Brecht I saw that you merged #16 a couple months ago. Any chance of getting a new release soon that includes that PR to support Gatsby 5?

darylwright commented 1 year ago

It seems like this project could benefit from using semantic-release and therefore converting to conventional commits. That last commit to master should have been a release. The existing tag name format is already compatible and it wouldn't take much to add a semantic-release job to the master.yml workflow (Edit: in addition to some configuration in package.json, which is also trivial).

Amit0617 commented 1 year ago

Yes actually it only needs to be built and published. I made a clone of it, built it manually and published for myself as npm was failing due to dependency conflicts. Here is the cloned repo. For obvious reasons, I can't publish it with same name and hence it can be found as gatsby-plugin-pnpm-gatsby-5 on npm.

darylwright commented 1 year ago

This plugin isn't quite ready for Gatsby v5. I discovered this after hours of fighting with manual MDX page generation. Consider the following code in gatsby-node.ts:

posts.forEach((post: Queries.MdxNodeFieldsFragment) => {
  createPage({
    path: post.node.fields.slug,
    context: {
      id: post.node.id,
    },
    component: `${contentTemplate}?__contentFilePath=${post.node.internal.contentFilePath}`,
  });
});

When using pnpm as my package manager, the MDX on my pages doesn't render with the contentTemplate layout. The MDX can render with component: post.node.internal.contentFilePath but it does so without the layout. The layout is also able to render on its own but without the MDX content.

My last resort to getting this issue resolved was to switch back to yarn by deleting my node_modules folder, deleting pnpm-lock.yaml, commenting out gatsby-plugin-pnpm in gatsby-config.ts, and reinstalling all my packages with yarn. This worked.

There is something wrong with this plugin that prevents Gatsby from grabbing the MDX content in the createPage API function. I have also encountered the exact same issue when using the File System Route API.

I'll be sticking to yarn for now and may investigate this issue further when I have the time, as I'd prefer to switch to pnpm.

Edit: I just realized I haven't tried configuring the plugin with strict: false. I'll give this a try and see if this works.

Edit2: strict: false doesn't work and neither does adding MDX packages to the include option. That's it for potential quick fixes.

Amit0617 commented 1 year ago

I doubt you are looking at wrong plugin for your problems. It is just for resolving node modules, which are created as symlinks by pnpm for webpack. Nothing else.

arsinclair commented 1 year ago

Any traction here? @Js-Brecht ? Could you publish a new version to the npm store?

rafalkrupinski commented 1 year ago

Does this help? https://www.npmjs.com/package/gatsby-plugin-pnpm-gatsby-5 looks like the latest version was ~accidentally~ published ~under another name~ by someone.

arsinclair commented 1 year ago

Hmm, looks fishy, since it still points to this repo. Either someone forgot, or intentionally didn't update the meta-information in the package.json, but I'm unable to find from which repository the gatsby-plugin-pnpm-gatsby-5 is originating.

YKalashnikov commented 1 year ago

any updates on making this package compatible with Gatxby 5 ? :)

kevinstubbs commented 1 year ago

Hmm, looks fishy, since it still points to this repo. Either someone forgot, or intentionally didn't update the meta-information in the package.json, but I'm unable to find from which repository the gatsby-plugin-pnpm-gatsby-5 is originating. @arinsclair

@Amit0617 who published that gatsby 5 compatible package has noted earlier in this thread, the repo can be found at https://github.com/amit0617/gatsby-plugin-pnpm