Publish a precompiled distribution
Compile your package before publishing and declare it as a distribution, so that the CDN delivers your outputs instead of compiling your sources.
- Availability: Planned
- Evidence: Read from source
- How-to guide
Starting state
You want to control the build yourself: you compile the package first and publish the result. The CDN recognizes the package as a distribution and does not compile its sources. For the other form see Publish Beyond source to npm.
Declare the form
{
"name": "@acme/cart",
"version": "2.0.1",
"type": "module",
"exports": { "./summary": "./summary.js", "./checkout": "./checkout.js" },
"beyond": {
"publication": {
"protocol": "beyond-publication/1",
"form": "distribution",
"compiler": { "name": "@beyond-js/packages", "version": "0.4.0" },
"formats": ["esm", "system"],
"conditions": ["browser", "production"],
"sourcemaps": true
}
}
}| Member | Required | Meaning |
|---|---|---|
protocol |
Yes | beyond-publication/1 |
form |
Yes | distribution |
compiler |
Yes | The name and version of the compiler that produced the outputs. It is part of what makes two outputs comparable. |
formats |
Yes | At least one of esm and system |
conditions |
No | The conditions the outputs were built for |
sourcemaps |
No | Whether the distribution includes source maps |
The example values are those of the contract's fixture, not a recommended compiler version.
Include the distribution manifest
The declaration has no member that names a file, so the layout is fixed: a distribution carries beyond-distribution.json at the package root, with the protocol beyond-distribution/1. It lists, for each public module, its references (eager, lazy or style), its assets and its variants; each variant names its conditions, its format and its output files with their media, digest and bytes.
The CDN reads a distribution from this manifest and never compiles it. It returns the listed files complete or not at all, after verifying every digest.
Publish
Publish the compiled package with your usual npm tooling. No Beyond tool runs npm publish for you.
What the CDN can serve from it
The CDN can only deliver what the distribution contains. An application that requests a format or a condition the distribution was not built for cannot get it from this package: the preparation reports the input it cannot satisfy instead of compiling something else.
| Situation | Outcome |
|---|---|
form: "distribution" without compiler or formats |
An error: the field is invalid |
beyond-distribution.json is missing or unreadable, a listed file is missing, or a digest does not match |
The distribution is refused; nothing is served from it |
| No variant matches the requested conditions and format | The preparation names the variants the distribution holds |
| The field mixes members of both forms | Rejected |
The application needs format=system and the distribution lists only esm |
The output is not available from this package |
Choosing between the two forms
| Source | Distribution | |
|---|---|---|
| Who compiles | The CDN, through Packages | You, before publishing |
| Formats and conditions | Whatever each application prepares | Only what you built |
| Compiler version | The one the CDN runs | The one you declare |
| What is downloaded by others | Your sources | Your outputs |