-
Notifications
You must be signed in to change notification settings - Fork 43
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
Enable PNPM and rspack #385
base: master
Are you sure you want to change the base?
Conversation
c6ff314
to
187dfa2
Compare
@@ -108,7 +109,9 @@ def update_statics_and_assets(self, force, debug=False, log_file=None): | |||
if op[-1] in messages: | |||
click.secho(messages[op[-1]], fg="green") | |||
response = run_interactive( | |||
op, env={"PIPENV_VERBOSITY": "-1"}, log_file=log_file | |||
op, | |||
env={"PIPENV_VERBOSITY": "-1", **js_pkg_man.env_overrides()}, |
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.
here we tell invenio
about the JS package manager that we want to use, via environment variables
ops = [py_pkg_man.run_command("invenio", "collect", "--verbose")] | ||
|
||
if force: | ||
ops.append(pkg_man.run_command("invenio", "webpack", "clean", "create")) | ||
ops.append(pkg_man.run_command("invenio", "webpack", "install")) | ||
ops.append(py_pkg_man.run_command("invenio", "webpack", "clean", "create")) | ||
ops.append(py_pkg_man.run_command("invenio", "webpack", "install")) | ||
else: | ||
ops.append(pkg_man.run_command("invenio", "webpack", "create")) | ||
ops.append(py_pkg_man.run_command("invenio", "webpack", "create")) | ||
ops.append(self._statics) | ||
ops.append(pkg_man.run_command("invenio", "webpack", "build")) | ||
ops.append(py_pkg_man.run_command("invenio", "webpack", "build")) |
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.
there is still a good amount of optimization potential by calling the invenio
command only once and thus saving all the redundant application initializations which eat up a lot of time.
one way to move forward is to implement a single larger command (e.g. in invenio-app-rdm
) that performs all the steps currently implemented here, based on the provided CLI args.
@ntarocco has pointed out to me that something very much like that has already been done in Invenio-App-ILS
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.
8e073f3
to
62a7f3a
Compare
* bump pynpm dependency for the PNPMPackage * tell invenio about which JS package manager is actually selected currently (npm or pnpm), via the new `ASSETS_NPM_PKG_CLS` config * also, use the module_pkg to execute the install command in the target path (rather than the instance's path, which made a difference in the case of pnpm)
* as discussed, we implement the `pnpm link` to basically do the same thing as the current `npm link` procedure, to not require any changes in JS packages
62a7f3a
to
0ee5d67
Compare
AssetsFunction(_prelink_dist, "Executing prelink-dist script..."), | ||
AssetsFunction(_link_package_single_step, "Linking module to assets..."), | ||
AssetsFunction(_postlink_dist, "Executing postlink-dist script..."), |
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.
3 is better than 1!
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.
as discussed, we're basically executing the same scripts with pnpm
as we did with npm
, except for the part where the actual linking happens (which is more sane with pnpm
.
since we don't have preprelink-dist
, postprelink-dist
, prepostlink-dist
and postpostlink-dist
scripts defined in our packages i think we should be executing the same set of scripts as before here.
# This is geared towards Invenio JS packages... | ||
# But so are all the other steps | ||
status_code = assets_pkg.link( | ||
str(module_pkg.package_json_path.parent / "dist") |
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.
the fact that we're linking against the "dist"
directory and not using the scripts requires some knowledge about the target package... but so does executing the link-dist
script, which is not exactly a standard AFAIK 😅
class AssetsFunction: | ||
"""Function to run an assets command with `assets_pkg` and `module_pkg`.""" | ||
|
||
function: Callable[[NPMPackage, NPMPackage], ProcessResponse] |
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.
the dataclass wants to have some type annotation, but Callable
should do the trick already.
i have no strong attachment to this type hint otherwise.
Second part of #383 – support for
pnpm
andrspack
Current state
This PR won't work as standalone, it still requires changes to core Invenio packages.
Either inveniosoftware/invenio-assets#176
Or inveniosoftware/invenio-assets#172, inveniosoftware/flask-webpackext#26, inveniosoftware/pywebpack#47
Depending on the choice, some tweaks need to be performed in this PR here.
Also,
npm
is still hard-coded in React-Invenio-Forms which needs to be addressed.