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

refactor(tests): remove postcss deps from serializer builds #151

Merged
merged 6 commits into from
Jul 9, 2024

Conversation

thompsonsj
Copy link
Owner

#145 identifies and issue where postcss and postcss-js are included as dependencies in the builds for serializers such as @slate-serializers/html and @slate-serializers/dom.

Investigation reveals that this is an issue caused by the project structure and a major refactor/reorganisation is required.

Each change detailed under headings:

Move tests that use transformStyleObjectToString or transformStyleStringToObject

The tests package was excluded from NX using nxignore. See #100. Not sure about the rationale for this but I imagine the tests library may have been causing issues with the build process (see next heading!)? Either that or I wanted to exclude a library that didn't need to be built?

Either way, it is back, and all the tests that use transformStyleObjectToString or transformStyleStringToObject have been moved there. These functions are optional - they can be imported from @slate-serializers/utilities and offer a comprehensive way to encode a style object as a string and vice versa. However, these are the functions that use the postcss libraries.

Move tests that cause circular dependencies

Moving tests into tests causes build issues such as:

Circular dependency between "html" and "tests" detected: html -> tests -> html

Circular file chain:
- packages/html/src/lib/serializers/expectedDifferencesHtmlSlateBothWays.spec.ts
- [
    packages/tests/src/lib/html/sameHtmlSlateBothWays.spec.ts,
    packages/tests/src/lib/html/snapshots/htmlToSlateToHtml.spec.ts,
    packages/tests/src/lib/html/withStyleObject.spec.ts
  ]eslint@nx/enforce-module-boundaries
module "/Users/st/www/personal/slate-serializers/packages/tests/src/index"
 NX   Could not execute command because the task graph has a circular dependency

html:build --> tests:build --> html:build

Tests are moved into the tests folder that import from tests to resolve this.

Remove any function imports from @slate-serializers/utilities

It seems that the purpose of @slate-serializers/utilities is mixed/confused. On the one hand, it offers convenient pre-defined functions for style object conversion. On the other hand, it contains functions intended to be shared across serializers?

The 'shared' purpose isn't really working out, and functions are moved into a more appropriate place. This refactor work means that internal dependencies on @slate-serializers/utilities are removed which helps achieve the end result of the NX build process excluding dependencies (i.e. those postcss dependencies!) from serializer builds.

Further considerations

  • Move all tests into tests?

@thompsonsj thompsonsj merged commit c360d4d into main Jul 9, 2024
2 checks passed
@thompsonsj thompsonsj changed the title refactor(tests): remove postcss deps from html and dom builds refactor(tests): remove postcss deps from serializer builds Jul 9, 2024
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.

1 participant