How is `@theia/api-samples` linked into the `theia/examples` apps?

Hi guys,

Newbie question:
I’ve been struggling to figure out how the @theia/api-samples is linked into the example applications.

@theia/api-samples is referenced as an ordinary NPM/Yarn dependency in theia/examples/browser/package.json:

{
  "private": true,
  "name": "@theia/example-browser",
  "version": "1.3.0",
  "license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
  "theia": {
    "frontend": {
      "config": {
        "applicationName": "Theia Browser Example",
        "preferences": {
          "files.enableTrash": false
        }
      }
    }
  },
  "dependencies": {
    "@theia/api-samples": "^1.3.0",
    "@theia/callhierarchy": "^1.3.0",
    "@theia/console": "^1.3.0",
    "@theia/core": "^1.3.0",
    "@theia/debug": "^1.3.0",
    "@theia/editor": "^1.3.0",
    "@theia/editor-preview": "^1.3.0",
    "@theia/file-search": "^1.3.0",
    "@theia/filesystem": "^1.3.0",
    "@theia/getting-started": "^1.3.0",
    "@theia/git": "^1.3.0",
    "@theia/keymaps": "^1.3.0",
    "@theia/languages": "^1.3.0",
    "@theia/markers": "^1.3.0",
    "@theia/messages": "^1.3.0",
    "@theia/metrics": "^1.3.0",
    "@theia/mini-browser": "^1.3.0",
    "@theia/monaco": "^1.3.0",
    "@theia/navigator": "^1.3.0",
    "@theia/outline-view": "^1.3.0",
    "@theia/output": "^1.3.0",
    "@theia/plugin-dev": "^1.3.0",
    "@theia/plugin-ext": "^1.3.0",
    "@theia/plugin-ext-vscode": "^1.3.0",
    "@theia/plugin-metrics": "^1.3.0",
    "@theia/preferences": "^1.3.0",
    "@theia/preview": "^1.3.0",
    "@theia/process": "^1.3.0",
    "@theia/scm": "^1.3.0",
    "@theia/scm-extra": "^1.3.0",
    "@theia/search-in-workspace": "^1.3.0",
    "@theia/task": "^1.3.0",
    "@theia/terminal": "^1.3.0",
    "@theia/typehierarchy": "^1.3.0",
    "@theia/userstorage": "^1.3.0",
    "@theia/variable-resolver": "^1.3.0",
    "@theia/vsx-registry": "^1.3.0",
    "@theia/workspace": "^1.3.0"
  },
  "scripts": {
    "prepare": "yarn run clean && yarn build",
    "clean": "theia clean",
    "build": "theia build --mode development",
    "watch": "yarn build --watch",
    "start": "theia start --plugins=local-dir:../../plugins",
    "start:debug": "yarn start --log-level=debug",
    "test": "theia test . --plugins=local-dir:../../plugins --test-spec=../api-tests/**/*.spec.js",
    "test:debug": "yarn test --test-inspect",
    "coverage": "yarn test --test-coverage && yarn coverage:report",
    "coverage:report": "nyc report --reporter=html",
    "coverage:clean": "rimraf .nyc_output && rimraf coverage"
  },
  "devDependencies": {
    "@theia/cli": "^1.3.0"
  }
}

If I clone the eclipse-theia/theia repository, then navigate to theia/examples/browser and run yarn, the project builds fine, but if I copy that package.json into an empty folder, Yarn complains that it can’t find the @theia/api-samples package:

David@Soyuz MINGW64 ~/theia-api-samples-test
$ yarn
yarn install v1.22.4
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@theia%2fapi-samples: Not found".

So where does this package come from?
In any case, I managed to work around this by including it as a file in the package.json:

"@theia/api-samples": "file:./node_modules/@theia/api-samples"

but nonetheless I’m still interested to know what is going on in the background here that makes this work.

Thanks guys!

Cheers,
David

The @theia/api-samples is an example extension which is not released to npm (as seen by the private property in its package.json. It is available and consumed by the main repository through yarn workspaces. It should not be used by downstream apps besides being a reference as it is not actually published.

Hi Vince,

Thanks for your answer.
Much appreciated.

Cheers,
David