-
Notifications
You must be signed in to change notification settings - Fork 706
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
Link KDS to Kolibri via webpack aliases #11446
Link KDS to Kolibri via webpack aliases #11446
Conversation
Open to suggestions. |
Build Artifacts
|
@Jaspreet-singh-1032 Great, thanks so much! I will test it out manually. @rtibbles could I ask you to have a look at code? |
This works like a charm! Thansk @Jaspreet-singh-1032. it will be incredibly helpful for anyone working with KDS. I tested the following
|
package.json
Outdated
@@ -25,6 +25,7 @@ | |||
"frontend-devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:hashi-dev --", | |||
"app-devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:app-python-devserver yarn:hashi-dev --", | |||
"devserver": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly {1}\" yarn:python-devserver yarn:hashi-dev --", | |||
"devserver-with-kds": "concurrently --passthrough-arguments --kill-others \"yarn:watch --watchonly --kds --kds-path={1}\" yarn:python-devserver yarn:hashi-dev --", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make more sense to use yarn:watch-hot
instead of yarn:watch
? Hot reload actually worked for me even without it, but I don't understand why..In any case, I think we use the hot reload the most often.
Let's wait for @rtibbles's thoughts before making any updates though, since my understanding of kolibri tools and webpack machinery is rather poor
After we're done with the review, I'd suggest to rebase to the release v16 branch, so that we can start using it immediately (it's optional @Jaspreet-singh-1032, I can do that myself) |
It's possible this might be a result of webpack caching - the easiest way to test this would be to run with the new command. Stop the server, delete the webpack cache (the easiest way to do this is just to delete the node_modules folder and then reinstall with |
packages/kolibri-tools/lib/cli.js
Outdated
@@ -224,6 +226,8 @@ program | |||
list, | |||
[] | |||
) | |||
.option('--kds', 'Flag to use local kds', false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my only comment is that having two flags seems like one too many! I would prefer to avoid the default behaviour and just require the explicit path to KDS.
The other reason this is preferable is that in situations where kolibri-tools
is being used outside of the Kolibri repo, the exact nested path that is encoded in the default may not match.
I see, this is due to the webpack caching. I tested it by deleting the webpack cache folder at |
Thanks @Jaspreet-singh-1032 - I'm going to have to think on this for a minute for how we might address this without having people manually delete their webpack cache! |
It looks like the best way to handle this would be to add an exclusion for KDS to the managedPaths option in webpack: https://webpack.js.org/configuration/other-options/#managedpaths - but only add this when the kdsPath option is active. Note that the managedPaths should default to |
Hi @rtibbles, I tried the above approach but could not make it work. I need some suggestions if there is an issue with the regex or the way I implemented it or should I try any other approach. const defaultManagedPaths = [
// /^(.+?[\\/]node_modules)[\\/]((?!kolibri-design-system)).*[\\/]*/,
// /^(.*[\\/]node_modules[\\/].*kolibri-design-system[\\/].*)/,
// /^(.+?[\\/]node_modules[\\/](?!kolibri-design-system[\\/]).+?)[\\/]/,
// path.join(data.plugin_path, 'node_modules'),
path.join(process.cwd(), 'node_modules'),
// /^(.+?[\\/]node_modules[\\/](kolibri-design-system[\\/].+))[\\/]/,
// /^(?!.*[\\/]node_modules[\\/]kolibri-design-system[\\/]).*$/,
]
if (kdsPath) {
defaultManagedPaths.push(new RegExp(`^(?!${kdsPath.replace(/\//g, '\\/')}).*`));
} |
@Jaspreet-singh-1032 hey, got your email on the subject, thanks for reaching out. We've never experienced the alias caching issue you mentioned. We did however switch over to using vite and use the alias functionality in a similar manner. You can see an example of that here: https://github.com/TeselaGen/tg-oss/blob/master/vite.react.config.ts#L182 |
Thanks everybody for looking into this. Just noting that Richard, who is best familiar with Webpack and this work, is out for a couple of weeks. We will come back to this. |
@tnrich Wonderful article, Thomas, thank you! And @Jaspreet-singh-1032 thanks for your perseverance and continuous contributions. This will save us plenty of time and some troubles :) |
Thanks @tnrich for your response. I appreciate you taking the time to look into my query. I'll definitely check out the example you provided. |
OK - I think maybe that was a bad idea, sorry it didn't work! My next idea is instead to optionally add the kdsPath, if specified, to the buildDependencies array: https://github.com/learningequality/kolibri/blob/release-v0.16.x/packages/kolibri-tools/lib/webpack.config.base.js#L94 - it seems this is compatible with passing in a filename, so it should take a full hash of the kdsPath to check if the cache is valid or not. If not specified, then the hash should be different with it not being present. |
Thanks, @rtibbles, I will try this approach and will share how this goes... |
I actually meant:
|
Hi @MisRob, I have pushed a commit, and the cache issue should be fixed now. It would be great if you could give it a try and let me know if it is working as expected. |
This is great @Jaspreet-singh-1032 and @rtibbles. I can confirm that the caching issue is gone and everything works as expected on my end. Do you think it'd be possible to show an error when the KDS path is not provided? When you run plain |
Yes, maybe we can do that. But Currently, if the kds path is not provided then it works as a regular |
I think it would be fine to raise an error if the |
It actually failed for me, I saw some errors around imports, I believe. I'd say that's actually better though when compared to it working as a regular devserver command since that'd be quite confusing (I doubt devs read the content of package.json command). Anyways, this is nothing blocking. I can open a follow-up. @Jaspreet-singh-1032 just let us know what would work best for you. We can merge this PR. |
Sure @MisRob, we can have a follow-up. |
Alright, @Jaspreet-singh-1032. Thank you for all this work! @rtibbles I think I could retarget this to the release branch before merging, right? It'd be nice to have it available. |
Yes, that should work, although it may require a rebase, depending on where it was branched from! |
Okay, will do |
9ba2b07
to
9d5aa5a
Compare
closes #10847
Summary
Added script
devserver-with-kds
to run kolibri using local kds.By default, it will consider kds directory at same level as kolibri.
To pass different kds path use.
…
References
…
Reviewer guidance
…
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)