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

fix: 📌Fixed type error "Cannot find module 'rollup/parseAst'" #242

Conversation

madogiwa0124
Copy link
Contributor

@madogiwa0124 madogiwa0124 commented Jan 11, 2024

fixed: #237

As shown below, a type error TS2307 occurs in [email protected].

$ cd book/impls/10_minimum_example/070_sfc_compiler2
$ pnpm install
$ pnpm tsc --noEmit

../../../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.d.ts:6:41 - error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations.

6 export { parseAst, parseAstAsync } from 'rollup/parseAst';
                                          ~~~~~~~~~~~~~~~~~

Found 1 error in ../../../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.d.ts:6

Therefore, changed moduleResolution to bundler.

@ubugeeei
Copy link
Owner

@madogiwa0124
Thanks!
Hmm, this seems like a bit of a challenging issue.
As consider some audience, perhaps it would be best to consider rewriting everything from the setup chapter. 😓
Would you mind revising the entire PR?
If reviewing their contributions becomes bothersome for you, I'd be happy to assist.

@ubugeeei ubugeeei marked this pull request as draft January 11, 2024 14:08
@ubugeeei ubugeeei self-assigned this Jan 11, 2024
@ubugeeei ubugeeei self-requested a review January 11, 2024 14:09
Copy link
Owner

@ubugeeei ubugeeei left a comment

Choose a reason for hiding this comment

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

@ubugeeei ubugeeei added the fix label Jan 11, 2024
@madogiwa0124
Copy link
Contributor Author

@ubugeeei

Thanks for the review!

I see, so the tsconfig.json in the docs and the tsconfig.json in the sample implementation should be changed from moduleResolution to Bundler regardless of the type error? 👀.

If there is no conflict, I would like to change the moduleResolution in the "Getting Started" and "Minimam Example" sample code in this PR and in the tsconfig.json in the documentation to Bundler first? What do you think ?

If you want to modify all the sample code and documentation at once, that's fine 😄.

@ubugeeei
Copy link
Owner

@madogiwa0124

If there is no conflict, I would like to change the moduleResolution in the "Getting Started" and "Minimam Example" sample code in this PR and in the tsconfig.json in the documentation to Bundler first? What do you think ?

I think it's necessary to make changes to the code that is crucial to the context of the chapters all at once, as partially updating it might confuse the readers due to the significance of the context.
.
.
.
.
.
However, since it's already broken, I'm starting to think maybe we shouldn't worry about that too much and should just go ahead and merge it first. 🫠.
.
.
Shall we go with that?

@madogiwa0124
Copy link
Contributor Author

@ubugeeei

Thanks for the comment !

I think it's necessary to make changes to the code that is crucial to the context of the chapters all at once, as partially updating it might confuse the readers due to the significance of the context.

I get what you're saying. Here are the commits I tried to correct the moduleResolution in all the tsconfig.json to bundler that are causing the type errors in the docs and in the sample code .

I confirmed that "Cannot find module 'rollup/parseAst'" does not occur locally.

The difference is a bit large, but what do you think ? 👀

If it looks OK, I will update the Pull Request with the contents of this commit 😄.

As an addendum, regarding the above commit, The tsconfig.json for each playground is now excluded.

Because it is created in vite v4.2 series and in that case, moduleResolution in tsconfig.json is Node.
(We may want to update this one eventually... 💦 )

nlx [email protected]
Packages: +1
+
Progress: resolved 1, reused 0, downloaded 1, added 1, done
✔ Project name: … sample-vite
✔ Select a framework: › Vanilla
✔ Select a variant: › TypeScript

Scaffolding project in sample-vite...

Done. Now run:

  cd sample-vite
  pnpm install
  pnpm run dev

$ cat sample-vite/tsconfig.json 
{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ESNext", "DOM"],
    "moduleResolution": "Node",
    "strict": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "skipLibCheck": true
  },
  "include": ["src"]
}

@ubugeeei
Copy link
Owner

@madogiwa0124

Because it is created in vite v4.2 series and in that case, moduleResolution in tsconfig.json is Node.
(We may want to update this one eventually... 💦 )

Yes, your are right.

The difference is a bit large, but what do you think ? 👀

Oh! You were already working on it (?)
In that case, let's go ahead and apply all of it!
The differences are big, but it's better than being misaligned. Besides, it's already broken anyway...

As shown below, a type error TS2307 occurs in `[email protected]`.

```sh
$ cd book/impls/10_minimum_example/070_sfc_compiler2
$ pnpm install
$ pnpm tsc --noEmit

../../../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.d.ts:6:41 - error TS2307: Cannot find module 'rollup/parseAst' or its corresponding type declarations.

6 export { parseAst, parseAstAsync } from 'rollup/parseAst';
                                          ~~~~~~~~~~~~~~~~~

Found 1 error in ../../../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.d.ts:6
```

Therefore, changed `moduleResolution` to `bundler`.
@madogiwa0124 madogiwa0124 force-pushed the 237-fixed-type-error-rollup-parseast-for-minimum-example branch from da351f4 to ece9620 Compare January 16, 2024 11:55
@madogiwa0124 madogiwa0124 changed the title fix: 📌Fixed type error "Cannot find module 'rollup/parseAst'" in Minimum Example sample code. fix: 📌Fixed type error "Cannot find module 'rollup/parseAst'" Jan 16, 2024
@madogiwa0124 madogiwa0124 marked this pull request as ready for review January 16, 2024 11:56
@madogiwa0124
Copy link
Contributor Author

@ubugeeei

In that case, let's go ahead and apply all of it!

I tried to correct the moduleResolution in all the tsconfig.json to bundler that are causing the type errors in the docs and in the sample code 👍🏻 .

Copy link
Owner

@ubugeeei ubugeeei left a comment

Choose a reason for hiding this comment

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

@madogiwa0124

I truly appreciate it from the bottom of my heart. Thank you. I'll merge now!

@ubugeeei ubugeeei merged commit 709888e into ubugeeei:main Jan 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants