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

Monorepo structure #2300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Monorepo structure #2300

wants to merge 2 commits into from

Conversation

gchoqueux
Copy link
Contributor

@gchoqueux gchoqueux commented Mar 21, 2024

Description

Refactoring iTowns to monorepo structure.

The goal is to split itowns down into feature packages.
As an example, I've started with the geographic functionalities. (@itowns/geographic)

  • move unit test
  • improve dev server
  • babel resolver plugin is broken
  • documentation
  • coverage
  • bump version
  • move all src in packages
  • watch src packages
  • publishing, auto publish with github actions
  • create organization NPM to support @iTowns
  • move dependencies to packages
  • webpack : use alias to resolve dependencies instead of exportsFields
  • use babel monorepo configuration
  • move export from private root package.json
  • write all readme.md files

For the moment Debug and Widget modules are private.

Motivation and Context

Split code in packages for clearly structured code.
Simplifies development and facilitates contributions.
Increases the scope of users who only want to use a few functions.
This structure makes it necessary to make functions independent

Code movement

The classes Coordinates, Crs, Ellipsoid, Extent, OrientationUtils files are moved to ./packages/geographic/src.
The proj4 dependency moves to geographic package.

The unit tests moves to packages/xxx/test.
the code utils/debug moves packages/Debug
the code src/Utils/Gui moves packages/Widget

dependencies

This proposal from monorepo doesn't use monorepo package (by example Lerna).
New dev dependency is Concurrently, it's used to watch script in parallel
Itowns dependencies (three, proj4...) are moved to the packages that use them

node scripts

The scripts uses the options --workspaces or -ws , to call the corresponding script in each sub packages.

@gchoqueux
Copy link
Contributor Author

gchoqueux commented Mar 27, 2024

@Desplandis I resolve some issues

  • resolve module with exportsFields option
  • remove lerna with --workspace cli option

@Desplandis
Copy link
Contributor

Desplandis commented Mar 27, 2024

@gchoqueux Nice! I will take a quick look of your changes and write a todo list of things that should absolutely be tested before reviewing more thoroughly this PR. Expect it for tomorrow or next tuesday!

@jailln @mgermerie @ftoromanoff @AnthonyGlt I think we'll need your inputs on this change! ;)

This should be a good start to fix #2197, #1930, #2201 (list not exhaustive, feel free to complete). Shall we create a meta-issue to aggregate all those issues?

@gchoqueux gchoqueux force-pushed the subpackages branch 5 times, most recently from e5ec2ea to b2308ff Compare April 3, 2024 12:02
@gchoqueux gchoqueux marked this pull request as ready for review April 3, 2024 13:54
@gchoqueux gchoqueux force-pushed the subpackages branch 6 times, most recently from ea0116d to 962c99d Compare April 9, 2024 14:56
@Desplandis
Copy link
Contributor

Hi, I'm currently reviewing your PR. I didn't had time to answer to the proposal. I'll submit both review and answer to the proposal tomorrow morning (TLDR; I agree with the package-splitting of this PR and have a few comments for future package-splitting).

@gchoqueux
Copy link
Contributor Author

for the moment I haven't completely correlated the proposal with the PR.

For example:
in PR : @itowns/main -> @itowns/main in proposal
in PR : @itowns/debug -> @itowns/plugins/debug in proposal

Copy link
Contributor

@Desplandis Desplandis left a comment

Choose a reason for hiding this comment

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

Hi! This is first batch of my review of this PR. Unfortunately I'm kinda blocked on testing the distribution since the compiled code for the itowns package is incorrect (especially with imports to relative modules).

Moreover, there is a lot of points that I would like you to address. I'll resume the review once those points have been resolved.

Since this PR is massive, @jailln there may be some things that eluded me, do not hesitate to complement this review. =)

Monorepo_Roadmap.md Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
Gruntfile.cjs Outdated Show resolved Hide resolved
Gruntfile.cjs Outdated Show resolved Hide resolved
package-lock.json Show resolved Hide resolved
packages/Main/.eslintignore Outdated Show resolved Hide resolved
"test-with-coverage_lcov": "c8 -n src --reporter=lcov cross-env npm run test-unit",
"watch": "cross-env BABEL_DISABLE_CACHE=1 babel --watch src --out-dir lib",
"postinstall": "cross-env NO_UPDATE_NOTIFIER=true node ./scripts/prepare.mjs && node ./scripts/replace.config.mjs",
"prepublishOnly": "npx copyfiles -u 1 \"../../examples/**/*\" ./examples/ && npx copyfiles -u 1 \"../../docs/**/*\" ./docs/ && npx copyfiles -u 1 \"../../dist/**/*\" ./dist/ ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Or just not distribute examples and docs like most other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to be decided

Comment on lines 16 to 19
"alias": {
"@itowns/geodesy": "../Geodesy/src/Main.js",
"itowns": "../Main/src/Main.js"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Once again this leads to incorrect compilation of path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 21 to 24
["babel-plugin-inline-import", {
"extensions": [
".json",
".geojson",
".glsl",
".css"
]
}],
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary since we do not imports from file with those extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 35 to 40
["minify-replace", {
"replacements": [{
"identifierName": "__DEBUG__",
"replacement": {
"type": "booleanLiteral",
"value": false
}
}]
}],
["minify-dead-code-elimination"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@gchoqueux gchoqueux force-pushed the subpackages branch 3 times, most recently from d578888 to 1bd17ac Compare November 7, 2024 17:51
@gchoqueux gchoqueux force-pushed the subpackages branch 12 times, most recently from f0ddd49 to 61e950f Compare November 13, 2024 17:22
@gchoqueux
Copy link
Contributor Author

Hi! This is first batch of my review of this PR. Unfortunately I'm kinda blocked on testing the distribution since the compiled code for the itowns package is incorrect (especially with imports to relative modules).

Moreover, there is a lot of points that I would like you to address. I'll resume the review once those points have been resolved.

Since this PR is massive, @jailln there may be some things that eluded me, do not hesitate to complement this review. =)

@Desplandis

I've finished answering/fixing all your comments.
I've also corrected the transpiling for the tests.

Copy link
Contributor

@jailln jailln left a comment

Choose a reason for hiding this comment

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

Not much to add to @Desplandis review.

I just think we should explain this new structure in the README and add sub package installation possibilities.

Also, how does it work with releasing and versioning? does subpackage all have the same version or can we (should we?) release them independently ?

@@ -0,0 +1,51 @@
## iTowns Geographic
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought: we may update the doc template to be structured per subpackage and export this page as the welcome page of the subpackage. WDYT @gchoqueux @Desplandis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I think it would be recommended for future implementations to structure documentation by sub-module.

* [Extent](http://www.itowns-project.org/itowns/docs/#api/Geographic/Extent) : Extent is geographical bounding rectangle defined by 4 limits: west, east, south and north.
* [Crs](http://www.itowns-project.org/itowns/docs/#api/Geographic/CRS) : This module provides basic methods to manipulate a CRS (as a string). Visiting [epsg.io](https://epsg.io/) to more coordinate system worldwide. Use **Proj4js** definition in epsg.io.
* [OrientationUtils](http://www.itowns-project.org/itowns/docs/#api/Geographic/OrientationUtils) : it provides methods to compute the quaternion that models a rotation defined with various conventions, including between different CRS.
* Ellipsoid : In geodesy, a reference ellipsoid is a mathematically defined surface that approximates the geoid.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should add all classes here as they already each have their own doc? WDYT @Desplandis? If we keep this list, we should add all classes though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's a good idea to introduce the module's features and point to the detailed documentation.

If we keep this list, we should add all classes though

Except for the Main sub-module, which has yet to be divided.

package.json Outdated Show resolved Hide resolved
@gchoqueux gchoqueux force-pushed the subpackages branch 2 times, most recently from ac0a1ad to 451da03 Compare November 28, 2024 12:16
@gchoqueux
Copy link
Contributor Author

I just think we should explain this new structure in the README and add sub package installation possibilities.

Yes, I'll document

Also, how does it work with releasing and versioning? does subpackage all have the same version or can we (should we?) release them independently ?

In a monorepo, it's more complicated to manage a different version for each module, but if we can find a simple and robust solution we can implement it later.

@gchoqueux gchoqueux force-pushed the subpackages branch 2 times, most recently from 6f3ada2 to d4616ba Compare November 28, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants