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

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

Open
1 task
JustFly1984 opened this issue Mar 2, 2024 · 25 comments
Open
1 task
Labels
million-lint This issue is related to Million Lint

Comments

@JustFly1984
Copy link

JustFly1984 commented Mar 2, 2024

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.

Copy link

github-actions bot commented Mar 2, 2024

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

@JustFly1984
Copy link
Author

Also seeing warning on yarn install: "@million/lint > react-start-transition@0.0.2" has incorrect peer dependency "react@^16.13.1"

@JustFly1984
Copy link
Author

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

@lmsutter
Copy link

lmsutter commented Mar 4, 2024

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.

@JustFly1984
Copy link
Author

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.

@tobySolutions
Copy link
Contributor

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

@lmsutter
Copy link

lmsutter commented Mar 4, 2024

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

@tobySolutions
Copy link
Contributor

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

@lmsutter
Copy link

lmsutter commented Mar 4, 2024

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.

@tobySolutions
Copy link
Contributor

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.

@Aslemammad
Copy link
Collaborator

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
Copy link
Collaborator

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

@lmsutter
Copy link

lmsutter commented Mar 5, 2024

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
Copy link

lmsutter commented Mar 5, 2024

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.

@JustFly1984
Copy link
Author

update: updated to 0.0.66, still getting navigator error

@Aslemammad
Copy link
Collaborator

update: updated to 0.0.66, still getting navigator error

My fix has not been included yet.

@Aslemammad
Copy link
Collaborator

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

@ericmasiello
Copy link

I'm running into the same issue.

@tobySolutions
Copy link
Contributor

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

@lxsmnsyc lxsmnsyc added the million-lint This issue is related to Million Lint label Mar 20, 2024
Copy link

github-actions bot commented Apr 5, 2024

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 github-actions bot added the Stale label Apr 5, 2024
@JustFly1984
Copy link
Author

not stale

@github-actions github-actions bot removed the Stale label Apr 6, 2024
Copy link

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 github-actions bot added the Stale label Apr 21, 2024
@ericmasiello
Copy link

Not stale

@github-actions github-actions bot removed the Stale label Apr 22, 2024
Copy link

github-actions bot commented May 8, 2024

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 github-actions bot added the Stale label May 8, 2024
@ericmasiello
Copy link

Not stale

@github-actions github-actions bot removed the Stale label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
million-lint This issue is related to Million Lint
Projects
None yet
Development

No branches or pull requests

6 participants