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

Are the types wrong? #229

Merged
merged 8 commits into from
Aug 25, 2024
Merged

Conversation

lishaduck
Copy link
Contributor

@lishaduck lishaduck commented Aug 24, 2024

Yes they were!

Fixed by dropping CJS from the builds following #225.

Supersedes/closes #161.

Copy link

changeset-bot bot commented Aug 24, 2024

🦋 Changeset detected

Latest commit: dad6ad9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
eslint-config-sheriff Minor
@sherifforg/constants Minor
@sherifforg/types Minor
@sherifforg/cli Minor
tsconfig Minor
sheriff-webservices Patch
docs-website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Aug 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sheriff ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 25, 2024 9:09pm

@lishaduck lishaduck changed the title Are the type wrong? Are the types wrong? Aug 24, 2024
@lishaduck
Copy link
Contributor Author

lishaduck commented Aug 24, 2024

CI is failing b/c it doesn't exclude as expected. I posted dist/index.js to a gist: https://gist.github.com/lishaduck/0a0d893fc6b3877b82aa29d17f4266f2 (search for node_modules/.pnpm/)

@lishaduck
Copy link
Contributor Author

lishaduck commented Aug 24, 2024

Oh, you know... that nice noExternal thing isn't going to keep #150 solved. NPM'll still try to install it. The published package.json needs to not include it all, not just in the bundle. It's in the bundle either way. I'm going to revert that change.

EDIT: Reverted

packages/sheriff-constants/package.json Outdated Show resolved Hide resolved
packages/sheriff-constants/package.json Outdated Show resolved Hide resolved
packages/sheriff-constants/package.json Outdated Show resolved Hide resolved
packages/sheriff-constants/package.json Outdated Show resolved Hide resolved
@AndreaPontrandolfo
Copy link
Owner

@lishaduck you know, i'm thinking an even better thing we could do to simplify stuff.
Just like with constants, we shouldn't ship the @sherifforg/types as a separate package. We can just re-export it from eslint-config-sheriff.
I don't see any downsides to it, only upsides, now that i think about it.

@lishaduck
Copy link
Contributor Author

I don't see any downsides to it, only upsides, now that i think about it.

If I can get tsup to bundle constants, yeah, that'd work.
Right now, it's not bundling constants, which breaks a ton. I'm going to try both noExternal + devDep and see if that helps.

@lishaduck
Copy link
Contributor Author

I don't see any downsides to it, only upsides, now that i think about it.

If I can get tsup to bundle constants, yeah, that'd work. Right now, it's not bundling constants, which breaks a ton. I'm going to try both noExternal + devDep and see if that helps.

That works! I also fixed the types (more undocumented behavior, sorry 😁)

@lishaduck
Copy link
Contributor Author

Ok, downgraded my node and I can reproduce. I guess it's a node bug? Not blocking prod, just attw.

@lishaduck
Copy link
Contributor Author

lishaduck commented Aug 24, 2024

Ok, downgraded my node and I can reproduce. I guess it's a node bug? Not blocking prod, just attw.

Nope, it doesn't support the workspace protocol. Will need to switch to pnpm pack (arethetypeswrong/arethetypeswrong.github.io#173 (comment); note that the pr that fixed it was reverted)

@AndreaPontrandolfo
Copy link
Owner

AndreaPontrandolfo commented Aug 24, 2024

Ok, downgraded my node and I can reproduce. I guess it's a node bug? Not blocking prod, just attw.

Nope, it doesn't support the workspace protocol. Will need to switch to pnpm pack (arethetypeswrong/arethetypeswrong.github.io#173 (comment); note that the pr that fixed it was reverted)

Ye, it seems like they deprecated the version with the PNPM support because it was breaking everything. Crazy!

@lishaduck
Copy link
Contributor Author

Conflicts! Already!
I despair 😫

🤣

@lishaduck
Copy link
Contributor Author

This should pass ci now and have 0 merge conflicts! Yay!
Only thought left is that maybe we should add a tsup-config internal package to keep it all in sync.

@lishaduck
Copy link
Contributor Author

lishaduck commented Aug 25, 2024

Also, it should be noted that despite attw claiming we support node 10, we don't 😅
I just suppressed the node10 errors, as they're not necessary for esm-only packages (they are for all cjs projects though, as node10 is the TS default for moduleResolution b/c history).

@lishaduck
Copy link
Contributor Author

Forgot to push 🤦‍♂️

This finishes the job by shrinking the bundle.
It also fixes attw.
_Never_, _ever_, use "node" (or stick with the default, which is "node").
Always use "Node16"if you won't bundle, "Bundler" otherwise.
Not sure why this is still needed, but ci fails otherwise.
Follow js conventions.
Fixes some publint infos.
This fixes a bunch of unrelated things that flaked!
@AndreaPontrandolfo
Copy link
Owner

This should pass ci now and have 0 merge conflicts! Yay! Only thought left is that maybe we should add a tsup-config internal package to keep it all in sync.

Nah, it's fine. The eslint config and the CLI have different requirements. It makes sense that they rely on different bundling configs.

@AndreaPontrandolfo
Copy link
Owner

Also, it should be noted that despite attw claiming we support node 10, we don't 😅 I just suppressed the node10 errors, as they're not necessary for esm-only packages (they are for all cjs projects though, as node10 is the TS default for moduleResolution b/c history).

i guess we need to keep an eye on this: arethetypeswrong/arethetypeswrong.github.io#112

@AndreaPontrandolfo
Copy link
Owner

AndreaPontrandolfo commented Aug 25, 2024

CI fails with:

Error: 1:30 error Parse errors in imported module 'eslint-config-sheriff': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding { ecmaVersion: 2015 } to the parser options. (undefined:undefined) import/no-named-as-default

I'm not exactly sure why this error surfaces here and now.
Anyway, to fix it, i think it's enough to add a ecmaVersion here:

      files: [supportedFileTypes],
      plugins: { import: fixupPluginRules(pluginImport) },
      rules: importHandPickedRules,
      languageOptions: {
        parserOptions: {
          sourceType: 'module', // required for https://github.com/import-js/eslint-plugin-import/blob/09476d7dac1ab36668283f9626f85e2223652b37/src/rules/no-default-export.js#L16
        },
      },

In this file: packages/eslint-config-sheriff/src/getBaseConfig.ts.
We can try { ecmaVersion: "latest" }, if that works. Otherwise we will have to specify a version, like 6, or 2022...

@lishaduck
Copy link
Contributor Author

lishaduck commented Aug 25, 2024

CI fails with:

Error: 1:30 error Parse errors in imported module 'eslint-config-sheriff': sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding { ecmaVersion: 2015 } to the parser options. (undefined:undefined) import/no-named-as-default

I'm not exactly sure why this error surfaces here and now. Anyway, to fix it, i think it's enough to add a ecmaVersion here:

      files: [supportedFileTypes],
      plugins: { import: fixupPluginRules(pluginImport) },
      rules: importHandPickedRules,
      languageOptions: {
        parserOptions: {
          sourceType: 'module', // required for https://github.com/import-js/eslint-plugin-import/blob/09476d7dac1ab36668283f9626f85e2223652b37/src/rules/no-default-export.js#L16
        },
      },

In this file: packages/eslint-config-sheriff/src/getBaseConfig.ts. We can try { ecmaVersion: "latest" }, if that works. Otherwise we will have to specify a version, like 6, or 2022...

Yeah, I'd fixed it locally but, as always, forgot to push it 😅

@AndreaPontrandolfo
Copy link
Owner

AndreaPontrandolfo commented Aug 25, 2024

@lishaduck can you add the changeset?

@AndreaPontrandolfo AndreaPontrandolfo merged commit ff57cfc into AndreaPontrandolfo:master Aug 25, 2024
3 checks passed
@lishaduck lishaduck deleted the attw branch August 25, 2024 21:16
@lishaduck
Copy link
Contributor Author

lishaduck commented Sep 3, 2024

I'm excited to note that this drastically shrunk the size of dist/index.js, from 17,002 lines to 1,159.

EDIT: Though I realized that the actual types are still wrong 🤣 (see egoist/tsup#366)

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

Successfully merging this pull request may close these issues.

2 participants