Skip to content

Use a single, unique symbol for resources#150

Merged
cowboyd merged 1 commit into
masterfrom
universal-symbol
Jun 16, 2020
Merged

Use a single, unique symbol for resources#150
cowboyd merged 1 commit into
masterfrom
universal-symbol

Conversation

@cowboyd

@cowboyd cowboyd commented Jun 16, 2020

Copy link
Copy Markdown
Member

Motivation

When installing bigtest into an existing codebase, we ended up with multiple versions of effection. That meant that resources created with one version were not being recognized by another. An example was when we created a ParceProcess to build the manifest. Because the calling context (@bigtest/server) did not recognize the child resource that was returned by @bigtest/parcel as a resource. As a result, the child process was shutdown immediately.

Approach

This uses the Symbol.for method to always return the same symbol no matter which version of effection that it is imported from.

Note that this will only work for all versions of effection that include this specific change. Previous versions will continue to have the same problem.

When installing bigtest into an existing codebase, we ended up with
multiple versions of effection. That meant that resources created with
one version were not being recognized by another. An example was when
we created a ParceProcess to build the manifest. Because the calling
context (@bigtest/server) did not recognize the child resource that
was returned by @bigtest/parcel as a resource. As a result, the child
process was shutdown immediately.

This uses the [Symbol.for][1] method to always return the same symbol
no matter which version of effection that it is imported from.

Note that this will only work for all versions of effection that
include this specific change. Previous versions will continue to have
the same problem.
@cowboyd cowboyd requested review from jnicklas and pittst3r June 16, 2020 18:11
@changeset-bot

changeset-bot Bot commented Jun 16, 2020

Copy link
Copy Markdown

🦋 Changeset is good to go

Latest commit: 0e8951f

We got this.

This PR includes changesets to release 5 packages
Name Type
effection Minor
@effection/subscription Major
@effection/events Major
@effection/node Major
@effection/fetch Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cowboyd cowboyd changed the title Use a single, unique symbol for resourcels Use a single, unique symbol for resources Jun 16, 2020
@github-actions

Copy link
Copy Markdown
Contributor

The preview packages of this pull request have been published.
Click on the following packages for instructions on how to install them:

effection

Install using the following command:

$ npm install effection@universal-symbol

Or update your package.json file:

{
  "effection": "universal-symbol"
}

@effection/events

Install using the following command:

$ npm install @effection/events@universal-symbol

Or update your package.json file:

{
  "@effection/events": "universal-symbol"
}

@effection/fetch

Install using the following command:

$ npm install @effection/fetch@universal-symbol

Or update your package.json file:

{
  "@effection/fetch": "universal-symbol"
}

@effection/node

Install using the following command:

$ npm install @effection/node@universal-symbol

Or update your package.json file:

{
  "@effection/node": "universal-symbol"
}

@effection/subscription

Install using the following command:

$ npm install @effection/subscription@universal-symbol

Or update your package.json file:

{
  "@effection/subscription": "universal-symbol"
}

Generated by 🚫 dangerJS against 0e8951f

@cowboyd cowboyd merged commit 4beeca0 into master Jun 16, 2020
@cowboyd cowboyd deleted the universal-symbol branch June 16, 2020 18:38
taras added a commit that referenced this pull request Jul 5, 2026
`@deno/doc` v2 (>=0.195.0) changed `Location.line` from 1-indexed to 0-indexed
(deno_doc #150/#777). The GitHub `#L<n>` anchor is 1-indexed, so the source
links generated in package.ts / package/node.ts pointed one line above the
symbol's declaration. Add `+ 1`.
taras added a commit that referenced this pull request Jul 5, 2026
`@deno/doc` v2 changed `Location.line` from 1-indexed to 0-indexed (deno_doc
#150/#777). GitHub's `#L<n>` anchor is 1-indexed, so the source links generated
in package.ts / package/node.ts pointed one line above the symbol's
declaration. Add `+ 1`.
taras added a commit that referenced this pull request Jul 5, 2026
* ⬆️ Upgrade @deno/doc to 0.199.0 and migrate docs pipeline to v2

Bumps `@deno/doc` 0.188.0 -> 0.199.0 and `@deno/graph` 0.89.0 -> 0.100.1, and
aligns the www CI job to Deno v2.9.1 (matches #1202).

`@deno/doc` >= 0.195.0 replaced the flat v1 `DocNode[]` model with the v2
`Document`/`Symbol`/`Declaration` model. The docs-rendering pipeline is migrated
to consume it natively:

- `doc()` returns `Record<url, Document>`; `Document.symbols` group declarations
  by name. `DocPageSection` holds a raw `Declaration`; render helpers receive
  the owning symbol via `type SymbolInfo = Omit<Symbol, "declarations">`
  (`extract(declaration, symbol)`, `Type({ declaration, symbol })`,
  `exportHash(declaration, symbol, i)`).
- `.def` replaces the per-kind def fields; `ClassMethodDef.def`; every
  `TsType*Def` payload is `.value`; namespace members recurse over
  `NamespaceDef.elements` (member Symbols).
- `kind === "import"` checks dropped; `Uint8Array` cast in blog-image-route.ts.

Note: `@deno/doc` 0.200.0-0.202.0 ship broken wasm bindings that fail to
instantiate under Deno (`__wbindgen_placeholder__`), so 0.199.0 is the newest
usable v2 release.

* 🐛 Fix off-by-one in API "View code" source links

`@deno/doc` v2 changed `Location.line` from 1-indexed to 0-indexed (deno_doc
#150/#777). GitHub's `#L<n>` anchor is 1-indexed, so the source links generated
in package.ts / package/node.ts pointed one line above the symbol's
declaration. Add `+ 1`.

---------

Co-authored-by: Taras Mankovski <74687+taras@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants