million icon indicating copy to clipboard operation
million copied to clipboard

npx @million/lint@latest gatsby.js option doesn't work with gatsby-node.ts

Open JustFly1984 opened this issue 11 months ago • 25 comments

What version of million are you using?

@million/lint@latest

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

Running npx @million/lint@latest in gatsby project. I have my Gatsby config files as ts. After choosing the framework as Gatsby, instead of editing existing gatsby-node.ts file. it just created fresh gatsby-node.js with onCreateWebpackConfig hook.

PS: I already have million/compiler setup in gatsby-node.ts. In this case, should I use both?

import million from 'million/compiler'
import { webpack } from '@million/lint';


export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] =
  function onCreateWebpackConfig({ actions }): void {
    actions.setWebpackConfig({
      plugins: [webpack(), million.webpack({ mode: 'react', server: true, auto: true })],
    })
 }

Thank you for your great work and project!

What's the expected result?

It should edit existing ts file and editing existing onCreateWebpackConfig function, instead of creating js file.

Link to Minimal Reproducible Example

sorry

Participation

  • [ ] I am willing to submit a pull request for this issue.

Update: getting an error while running gatsby dev:

 ⚡ Million Lint v0.0.58
 ✓ Ready in 0.64ms

  ⚡ Million.js 3.0.3
  - Tip:     use // million-ignore for errors
  - Hotline: https://million.dev/hotline


 ⚡ <Html> now renders ~50% faster
 ⚡ <Unverified> now renders ~33% faster
 ⚡ <ProfileIncomplete> now renders ~40% faster
 🎁 Million Wrapped: https://million.dev/wrapped/36c5af2124fc2496ce68d8689f14b313
 ⚡ <DropdownOption> now renders ~83% faster
 ⚡ <ListBox> now renders ~67% faster

 ERROR  UNKNOWN

There was an error compiling the html.js component for the development server.
See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html ReferenceError:
navigator is not defined


  1 | import { useEffect, useState } from "react";
> 2 | var isInputPendingSupported = "scheduling" in navigator &&
    | ^
  3 |     navigator.scheduling &&
  4 |     "isInputPending" in navigator.scheduling;
  5 | var tasks = [];


  WebpackError: ReferenceError: navigator is not defined

commenting out webpack() fixes an issue.

JustFly1984 avatar Mar 02 '24 06:03 JustFly1984

Thanks for opening this issue! A maintainer will review it soon.

github-actions[bot] avatar Mar 02 '24 06:03 github-actions[bot]

Also seeing warning on yarn install: "@million/lint > [email protected]" has incorrect peer dependency "react@^16.13.1"

JustFly1984 avatar Mar 02 '24 18:03 JustFly1984

possible solution is to add a type guard typeof document !== 'undefined' to make the code SSR friendly.

JustFly1984 avatar Mar 02 '24 18:03 JustFly1984

I'm having this same issue, thanks for working on it! I have mostly the same setup, except I set mine up according to the automatic instructions here: https://million.dev/docs/install.

I'm using gatsby version 4.24 & react version 18.2.

lmsutter avatar Mar 04 '24 19:03 lmsutter

I had the same install process, but had generated js file as output. I'm using ts version, so I've just copied settings from js to ts, but got issues on dev build.

JustFly1984 avatar Mar 04 '24 20:03 JustFly1984

Thanks for this @JustFly1984, but, @NisargIO can help you here.

tobySolutions avatar Mar 04 '24 20:03 tobySolutions

I'm having this same issue, thanks for working on it! I have mostly the same setup, except I set mine up according to the automatic instructions here: https://million.dev/docs/install.

I'm using gatsby version 4.24 & react version 18.2.

Actually the gatsby develop runs without the navigator error now, but when I try and access the local dev site it serves up, I get an "unhandled runtime error, cannot read properties of null (reading 'innerHTML') from line 6565 in the million/dist/packages/react-sever.mjs file.

When I try to run gatsby build I get this error: WebpackError: RangeError: Maximum call stack size exceeded

lmsutter avatar Mar 04 '24 20:03 lmsutter

Thank you @JustFly1984 and @lmsutter, I have helped reported this to core team. Someone will respond to you soon.

tobySolutions avatar Mar 04 '24 20:03 tobySolutions

Thank you @JustFly1984 and @lmsutter, I have helped reported this to core team. Someone will respond to you soon.

Never mind, I was confused but it got resolved.

lmsutter avatar Mar 04 '24 20:03 lmsutter

Thank you @JustFly1984 and @lmsutter, I have helped reported this to core team. Someone will respond to you soon.

Never mind, I was confused but it got resolved.

Wait, I'm curious; could you share what you did please? Thanks.

tobySolutions avatar Mar 04 '24 20:03 tobySolutions

I'm having this same issue, thanks for working on it! I have mostly the same setup, except I set mine up according to the automatic instructions here: https://million.dev/docs/install.

@lmsutter I think that's a completely different issue with million itself and not million lint. Let me know, if yes, create another issue please. Thank you so much.

Aslemammad avatar Mar 05 '24 06:03 Aslemammad

I fixed this issue and it'll be included in the latest release soon.

Aslemammad avatar Mar 05 '24 10:03 Aslemammad

I'm having this same issue, thanks for working on it! I have mostly the same setup, except I set mine up according to the automatic instructions here: https://million.dev/docs/install.

@lmsutter I think that's a completely different issue with million itself and not million lint. Let me know, if yes, create another issue please. Thank you so much.

yes, sorry, thank you!

lmsutter avatar Mar 05 '24 14:03 lmsutter

Thank you @JustFly1984 and @lmsutter, I have helped reported this to core team. Someone will respond to you soon.

Never mind, I was confused but it got resolved.

Wait, I'm curious; could you share what you did please? Thanks.

Sounds like this is resolved. I was confused and I didn't want to add to the confusion, if it helps to hear my process though. Million/lint is not working for me currently but I'm looking forward to trying the new release.

So I am using the typescript version of gatsby-node.ts like the original poster. When I ran pnpx install @million/lint@latest (pnpm is my package manager) the install went fine and it added a gatsby-node.js file with what looks like the correct setup. I am able to run my gatsby app fine (gatsby develop) but I don't see anything besides the basic text in the million/lint plugin section of vs code.

When I try to add in the webpack config to my gatsby-node.ts file like this:

export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = (
  args,
) => {
  args.actions.setWebpackConfig({
    plugins: [MillionCompiler.webpack()],
  });
  createPathAliases(args);
  disableSourceMaps(args);
};

and run gatsby develop I get this error:

ERROR #11321 PLUGIN

"gatsby-node.js" threw an error while running the onCreateNode lifecycle:

Cannot access 'i' before initialization

25 | }; 26 |

27 | export const onCreateNode: GatsbyNode['onCreateNode'] = async (args) => { | ^ 28 | await createAssetNodes(args); 29 | await createInlineSvgNodeField(args); 30 | await createStoryblokPageNode(args);

File: gatsby-node.ts:27:14

My onCreateNode export is right after the onCreateWebpack config export so I'm guessing that's maybe why the error is showing up for that line?

Deleting the gatsby-node.js file didn't help.

Hope that helps, sorry! Sounds like this has been resolved. Thanks for reaching out.

lmsutter avatar Mar 05 '24 14:03 lmsutter

update: updated to 0.0.66, still getting navigator error

JustFly1984 avatar Mar 05 '24 23:03 JustFly1984

update: updated to 0.0.66, still getting navigator error

My fix has not been included yet.

Aslemammad avatar Mar 06 '24 04:03 Aslemammad

@lmsutter Could you please create another issue for this? So I investigate it.

Aslemammad avatar Mar 06 '24 04:03 Aslemammad

I'm running into the same issue.

ericmasiello avatar Mar 07 '24 20:03 ericmasiello

Thank you for reporting this @JustFly1984, I have communicated this issue with the team. Thank you!

tobySolutions avatar Mar 19 '24 01:03 tobySolutions

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days.

github-actions[bot] avatar Apr 05 '24 00:04 github-actions[bot]

not stale

JustFly1984 avatar Apr 05 '24 01:04 JustFly1984

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days.

github-actions[bot] avatar Apr 21 '24 00:04 github-actions[bot]

Not stale

ericmasiello avatar Apr 21 '24 14:04 ericmasiello

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days.

github-actions[bot] avatar May 08 '24 00:05 github-actions[bot]

Not stale

ericmasiello avatar May 08 '24 21:05 ericmasiello