/ jupyterlab Public
Require 'package' instead of 'package/' so webpack activates sharing #9300
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge.
This addresses the underlying problem in at least part of #9289.
Webpack module federation was not creating shared modules for the direct extensions, only for their dependencies. For example, @jupyterlab/application was packaged as a shared module, but @jupyterlab/application-extension was not.
The reasoning here is a bit subtle. The problem came down to how these top-level extensions were imported. The template made the require statements similar to @jupyterlab/application-extension/, with a trailing slash (which was nominally a slash between the package name and the actual import in the package, but mostly that actual import was an empty string, so we’d just be left with a trailing slash). However, webpack interpreted that trailing slash as indicating the import was only for paths starting with the package name, and not as a top-level package import. This meant that webpack did not see that these modules were being used, so did not include them in the list of modules packaged as shared modules. In other words, these top-level imports were treated as this case:
instead of as this case:
The fix here is simple - only put the slash in the require statement if we actually have a path to import.