Components.js is a semantic dependency injection framework for TypeScript and JavaScript projects, leveraging JSON-LD or other RDF serializations for declarative component configuration. It allows developers to define and wire software components using unique, globally identifiable URIs, promoting modular and easily reconfigurable applications. The current stable version is 6.4.0, with major releases occurring periodically, introducing breaking changes primarily related to configuration file syntax and API usage. A key differentiator is its reliance on semantic configuration, enabling dynamic component injection without hard-coding dependencies. This makes it suitable for complex applications requiring flexible component orchestration, such as the Comunica query engine.
npm install componentsjsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a minimal Components.js module, define a class, create a semantic JSON-LD configuration, and then instantiate that class using the ComponentsManager. It includes a simulated `package.json` and TypeScript compilation step for a self-contained example.
Review configuration files and update parameter definitions to use explicit RDF lists for arrays and new parameter range syntax. Consult the official v6 migration guide.
For upgrades from v4, configurations must be updated to align with the v5 parameter range and RDF list changes. Consult the official v5 migration guide.
Ensure that all `@context` URLs in `config.jsonld` (and other configuration files) use the correct major version range for `componentsjs` and any custom modules. For example, `https://linkedsoftwependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld`.
Add `"lsd:module": true` to your `package.json` and ensure `componentsjs-generator` is installed as a dev dependency and run as part of your build process, usually via an `npm run build:components` script. Verify the output directory for TypeScript (`.d.ts`) files aligns with the generator's expected input (default `lib/`) or use the `-s` flag.
Ensure `npm run build:components` (or equivalent) has been executed after compiling TypeScript/JavaScript. Verify that the generator is targeting the correct source files and outputting metadata to the expected location.
Add `"lsd:module": true` to the `package.json` of the module containing the component. Double-check that `mainModulePath` passed to `ComponentsManager.build()` correctly points to the root of the npm package.
Ensure your project's `package.json` includes `"type": "module"` if you intend to use ESM globally, or rename files using `import` to `.mjs`. For older Node.js, stick to CommonJS `require()` or transpile your code.
Refer to the `CHANGELOG` for your Components.js major version (v5 or v6) and update your component configuration to align with the new parameter range and RDF list requirements. Ensure all array values are explicitly defined with `@list`.
No dependency data recorded yet.