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

feat!: bundle splitting #13

Merged

Conversation

gentlementlegen
Copy link
Member

@gentlementlegen gentlementlegen commented Apr 16, 2024

This aims to split the bundle to avoid importing Node modules in places where they are not required. Now the imports can be as such:

  • @ubiquibot/permit-generation/core
  • @ubiquibot/permit-generation/types
  • @ubiquibot/permit-generation/handlers

# Conflicts:
#	package.json
#	src/generate-permits-from-context.ts
#	tests/encode-decode.test.ts
#	tests/generate-payout-permit.test.ts
@gentlementlegen gentlementlegen marked this pull request as ready for review April 16, 2024 12:09
@gentlementlegen
Copy link
Member Author

Knip complaining for unknown reasons, also happens locally. But there is no unused dependencies, not unused exports in this code.

Copy link

@molecula451 molecula451 left a comment

Choose a reason for hiding this comment

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

looks like the PR adds vanilla update, looks clean

@gitcoindev
Copy link
Contributor

Knip complaining for unknown reasons, also happens locally. But there is no unused dependencies, not unused exports in this code.

Let me check the root cause.

@gitcoindev
Copy link
Contributor

Knip complaining for unknown reasons, also happens locally. But there is no unused dependencies, not unused exports in this code.

Let me check the root cause.

It took me almost 3 hours, which was completely ridiculous but I was able to find and fix this.
I had the same observations as you, failures were shown though dependencies were set up and used correctly.
I tried different settings but no luck.

During a debugging session I discovered that Knip parses .gitignore file!
I found in the .gitignore for this repository three folders used for build artifacts and Knip matched the same folder names in src (source) folder, and excluded those folders for dependency traversal.

The solution was to add a slash so that only build artifacts are not considered :
cbb4b67

Time to sleep now, tomorrow i am back to other issues -)

@molecula451 molecula451 merged commit 38eb308 into ubiquity-os:development Apr 16, 2024
2 checks passed
@gentlementlegen
Copy link
Member Author

@gitcoindev thanks a lot for you help. This would mean it happens in every other repository potentially? Or just on this one.

@gentlementlegen gentlementlegen deleted the feat/bundle-splitting branch April 17, 2024 02:12
@gitcoindev
Copy link
Contributor

@gentlementlegen potentially in other repositories as well. The usual place to place build artifacts is dist folder, in this case the errors are not shown as other source folders are usually not named 'dist'. It is worth to remember about this behavior though in cases, when configuration seems correct but knip still detects unused exports.

@gentlementlegen
Copy link
Member Author

@gitcoindev Okay I see. The reason why I am not using dist is because if I do then we would need to import like @ubiquibot/permit-generation/dist/... which looked odd.

@gitcoindev
Copy link
Contributor

@gitcoindev Okay I see. The reason why I am not using dist is because if I do then we would need to import like @ubiquibot/permit-generation/dist/... which looked odd.

I solved it for tsup with a package.json exports configuration, see https://github.com/ubiquity/ubiquibot-logger/blob/development/package.json#L23

There is a good article explaining how this works : https://dev.to/tigawanna/building-and-publishing-npm-packages-with-typescript-multiple-entry-points-tailwind-tsup-and-npm-9e7

You hopefully should be able to achieve similar setup withrollup, which is used in this repository.

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.

3 participants