Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ coverage/
htmlcov/
.coverage
coverage*.xml

# Isolated source-build validation staging
/test-submodules/
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ package-version changes or publication and does not trigger or gate consumer
submodule updates.

Consumers are responsible for building both runtimes from their intended pinned
revision. Automated artifact-provenance enforcement and reliable build
invalidation remain roadmap S4 follow-up work rather than a package-version
release requirement.
revision. See [building from a pinned submodule](README.md#building-from-a-pinned-submodule)
for the build and packaging contract. Consumer pipeline enforcement and
compatibility testing remain extension-owned.

## Reporting Issues

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ remain supported. Neither identity is a registry-facing consumption API: do not
add a bare dependency or registry install for it. This repository publishes
neither npm nor PyPI packages.

### Building from a pinned submodule

`npm run build` in `typescript` cleans `dist` before compiling, including outputs
for removed sources. Run it before type-checking or packaging the extension;
an existing `dist/index.js` is not a freshness check.

For release CI, start from a fresh checkout with submodules initialized at their
recorded gitlinks. Check that the shared submodule matches the expected commit
and has no source changes. Build TypeScript and install Python from that same
checkout using the commands above, then package those outputs rather than
reusing artifacts from another pin. Consumer pipeline enforcement, dependency
locks, and compatibility tests remain the extension's responsibility.

### Dependabot updates

The consuming extensions configure Dependabot's `gitsubmodule` ecosystem to
Expand Down
2 changes: 1 addition & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dist/"
],
"scripts": {
"build": "tsc",
"build": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\" && tsc",
"watch": "tsc --watch",
"lint": "eslint src",
"format-check": "prettier --check src/**/*.ts",
Expand Down
44 changes: 44 additions & 0 deletions typescript/tests/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { assert } from "chai";
import { execFileSync } from "node:child_process";
import {
existsSync,
mkdirSync,
mkdtempSync,
rmSync,
writeFileSync,
} from "node:fs";
import * as path from "node:path";

suite("TypeScript build", () => {
test("removes obsolete JavaScript and declarations before compiling", function () {
this.timeout(60_000);
const npmCli = process.env.npm_execpath;
if (!npmCli) {
throw new Error("Run this test using npm test.");
}
const root = path.resolve(__dirname, "..", "..");
const dist = path.join(root, "dist");
mkdirSync(dist, { recursive: true });
const stale = mkdtempSync(path.join(dist, "stale-build-"));
writeFileSync(path.join(stale, "removed.js"), "module.exports = {};\n");
writeFileSync(path.join(stale, "removed.d.ts"), "export {};\n");
try {
execFileSync(process.execPath, [npmCli, "run", "build"], {
cwd: root,
timeout: 60_000,
stdio: "pipe",
});
assert.isFalse(
existsSync(stale),
"Outputs for removed sources must not survive the build",
);
assert.isTrue(existsSync(path.join(dist, "index.js")));
assert.isTrue(existsSync(path.join(dist, "index.d.ts")));
} finally {
rmSync(stale, { recursive: true, force: true });
}
});
});
Loading