Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Orion/Dependency resolution

Dependency resolution refers to the ability to resolve a type of cross-file dependency to a file in the workspace at development time. Examples of dependencies within our scope are:

  • src and href attributes in an HTML file
  • @import statements in a CSS file
  • define([ deps.. ]) and require([ deps.. ]) in a JS file (AMD modules)
  • require( "dep/path" ) in a JS file (Node.js/CommonJS)
  • importScripts( urls.. ) in a JS file (web worker API)

Dependency resolution is a prerequisite feature to cross-file type inference and content assist. This document deals with the simplest possible case of dependency resolution: deciding whether the referenced file exists or not. In other words, if we implement everything in this document, it should be trivial to write a validator that puts a red *X* on missing resources in HTML, CSS, and JS files (for the JS contexts: Node, AMD, worker).

Concepts

  • Dependency: a reference to some logical path (LP).
  • Logical path (LP): whatever goes inside the src="..", @import "..", require(..), etc.
    • The LP is opaque to everything but a Resolver, which can translate LP to a workspace path.
    • Example: in JS, depending on the context, the LP can be a commonJS module path (Node.js), a path in the local file system (Node.js), a web path (browser/worker), or an AMD module ID.
  • Resolver: resolves a LP to a workspace path (WP).
    • Workspace paths can be fetched/parsed by the tooling using the usual Orion FileClient API.
  • Web Path Configuration (WPD): captures the path-translation info necessary to map from an LP that is a web location.
    • The notion of WPD is important because a resource's location on a web server is generally not the same as its location in the workspace. For example, a file located at a repo path of /src/webapp/static/js/foo.js may be exposed on the web as /admin/js/foo.js.
    • The WPD is of interest to any Resolvers that may encounter web paths as LPs.
    • A WPD is a subset of the site structure defined by an Orion site configuration. Should factor out any commonality here.

Back to the top