GLSP-1742: Rework client feature configuration with lazy feature definitions - #33
Open
haydar-metin wants to merge 1 commit into
Open
haydar-metin wants to merge 1 commit into
haydar-metin wants to merge 1 commit into
Conversation
haydar-metin
added this pull request to stack #34
September 28, 2026 13:15
haydar-metin
force-pushed
the
client-feature-configuration
branch
2 times, most recently
from
September 29, 2026 12:48
e3f8501 to
20a0e96
Compare
2 tasks done
…nitions - Add namespaced feature keys (`FeatureKey`, `GLSPFeatureKey`) to the protocol; `CapabilityKey` is now an alias of `FeatureKey` - Add `FeatureDefinition` (`defineFeature`, `toModuleOptions`) and resolve container configurations before loading (`resolveFeatures`, `loadFeatures`, `initializeContainerAsync`): remove/replace by key, `requires`/`extends` dependencies, dependency ordering and `FeatureResolutionError`s for duplicates, missing dependencies, cycles, mismatching modules and invalid ids (also in `add`/`replace`), and warn about removed keys that are not configured - Define all client features next to their modules (`*-feature.ts`, e.g. `boundsFeatureDef` for `boundsModule`) with key registries `GLSPClientFeature`, `GLSPStandaloneFeature` and `SprottyFeature`; modules derive their options from their definition - Load default features lazily via dynamic `import()`: `initializeDiagramContainer` is now async and uses `DEFAULT_FEATURES`, `GLSPOptionalFeatures` and `STANDALONE_FEATURES` instead of `DEFAULT_MODULES` and `STANDALONE_MODULES` - Move standalone-only modules to `integration/standalone` - Prefix the wrapped sprotty modules with `sprotty` (e.g. `sprottyButtonModule`) - Reject a replacement of the default client feature that declares dependencies, as it is always loaded first - Add `sideEffects` metadata (protocol keeps `di/re-decorate` as side effect) and a bundle test that guards that the sources stay splittable. The published lib is still CommonJS, so removed features are not yet excluded from adopter bundles - Server: define all feature keys in `GLSPServerFeature` (`server-feature-keys.ts`), reference required features by key and rename the `ServerFeature` service identifier to `ServerFeatureDescription` - Update the workflow examples and document the configuration and migration in the client README Part of: eclipse-glsp/glsp#1742
haydar-metin
force-pushed
the
client-feature-configuration
branch
from
September 30, 2026 11:22
20a0e96 to
c215bb8
Compare
Contributor
haydar-metin
commented
Sep 30, 2026
|
|
||
| This project is built with `pnpm` and is available from npm via [@eclipse-glsp/client](https://www.npmjs.com/package/@eclipse-glsp/client). | ||
|
|
||
| ## Configuring features |
Contributor
Author
There was a problem hiding this comment.
Todo: move this to a proper migration.md / changelog.md file
haydar-metin
marked this pull request as ready for review
September 30, 2026 11:31
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.Suggestion cannot be applied right now. Please check back later.
What it does
Reworks the client container configuration around lazily loaded feature definitions that are referenced by stable, namespaced keys. Stacked on #21 (GLSP-1741), which should be merged first.
FeatureKey,GLSPFeatureKey) to the protocol;CapabilityKeyis now an alias ofFeatureKeyFeatureDefinition(defineFeature,FeatureDefinition.toModuleOptions,FeatureDefinition.fromModule) and resolve container configurations before loading (resolveFeatures,loadFeatures,initializeContainerAsync):requires(hard) andextends(soft) dependencies, dependency orderingFeatureResolutionErrors for duplicates, missing dependencies, cycles, mismatching modules and invalid ids (top-level,addandreplaceentries)*-feature.ts, e.g.boundsFeatureDefforboundsModule) with the key registriesGLSPClientFeature,GLSPStandaloneFeatureandSprottyFeature; modules derive their feature id and requirements from their definitionimport():initializeDiagramContaineris now async and usesDEFAULT_FEATURES,GLSPOptionalFeaturesandSTANDALONE_FEATURESinstead ofDEFAULT_MODULESandSTANDALONE_MODULESGLSPClientFeature.Defaultfeature is always loaded first; a replacement that declares dependencies is rejectedintegration/standalonesprotty(e.g.sprottyButtonModule)sideEffectsmetadata (@eclipse-glsp/protocolkeepsdi/re-decorateas side effect) and a bundle test that guards that the sources stay splittableGLSPServerFeature(server-feature-keys.ts), reference required features by key and rename theServerFeatureservice identifier toServerFeatureDescriptionNote
Lazy loading currently means that a removed feature's module is never evaluated (no registration code, no stylesheet injection). It does not reduce the bundle size for adopters yet: the published
libis CommonJS, whereimport()compiles torequire, which bundlers treat as a static dependency. See follow-ups.Closes eclipse-glsp/glsp#1742
How to test
pnpm build && pnpm test: seecontainer-configuration.spec.ts,client-init.spec.tsandclient-feature-definitions.bundle.spec.tspnpm dev: the standalone workflow example removesGLSPClientFeature.ToolPaletteby key inexamples/workflow-standalone/src/common/di.config.ts. Verify that the diagram loads without the tool palette and that all other features work as before{ remove: GLSPClientFeature.ElementTemplate }, and check that it fails with aFeatureResolutionErrorstating thatglsp.nodeCreationToolrequiresglsp.elementTemplateFollow-ups
lib(dual CJS/ESM) so that bundlers can split removed features into separate chunks. Importing through theindexbarrel also needs work: with esbuild, theexport *of every feature module keeps modules that import a stylesheet (a declared side effect) in the entry chunk, even with ESM. One option is to load a feature's stylesheet in itsload()factory instead of in the module fileinitializeDiagramContainerChangelog
Breaking changes (see the migration section in
packages/client/client/README.md):initializeDiagramContaineris async and returns aPromise<Container>. Container factories that call it (e.g.createWorkflowDiagramContainer) become async as well:const container = await initializeDiagramContainer(c, ...config);DEFAULT_MODULESandSTANDALONE_MODULESare removed. UseDEFAULT_FEATURESandSTANDALONE_FEATURES(lists ofFeatureDefinitions);STANDALONE_MODULE_CONFIGis still availableaccessibilityModule,gridModule,helperLineModuleanddebugModuleare also available asGLSPOptionalFeatures.Accessibility,.Grid,.HelperLineand.Debug(the module objects still work)@eclipse-glsp/sprottyare renamed:buttonModule,edgeEditModule,edgeIntersectionModule,edgeJunctionModule,edgeLayoutModule,expandModule,fadeModule,modelSourceModule,moveModule,openModuleandupdateModulebecomesprottyButtonModule,sprottyEdgeEditModule, … Their feature ids are nowFeatureKey.toId(SprottyFeature.X)instead of plainSymbolsrequiresnow fails with aFeatureResolutionErrorinstead of silently skipping the dependent feature. In the defaults,NodeCreationToolrequiresElementTemplateandZorderrequiresBounds, so remove the dependent feature as wellFeatureKey.toId(GLSPClientFeature.X)). Areplacewith a custom module only matches a default feature if it uses the same feature id; preferdefineFeature(GLSPClientFeature.X, ...)standaloneDefaultModule,standaloneShortcutsModule,saveModule,undoRedoModule,CopyPasteStartup, …) moved tosrc/integration/standalone. Imports from the package entry point are unaffected; deep imports from@eclipse-glsp/client/lib/...must be updatedServerFeatureservice identifier is renamed toServerFeatureDescription.container.bind(ServerFeature)becomescontainer.bind(ServerFeatureDescription)