Skip to content
Open
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:

runs-on: ubuntu-latest

env:
PUPPETEER_SKIP_DOWNLOAD: true

strategy:
matrix:
node-version: [ 18, 20, 22, 24 ]
Expand Down
27 changes: 27 additions & 0 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class AISKUSizeCheck extends AITestClass {
public registerTests() {
this.addRawFileSizeCheck();
this.addProdFileSizeCheck();
this.addRolldownPureAnnotationCheck();
}

constructor() {
Expand All @@ -105,6 +106,32 @@ export class AISKUSizeCheck extends AITestClass {
private addProdFileSizeCheck(): void {
this._checkFileSize(true);
}

private addRolldownPureAnnotationCheck(): void {
this.testCase({
name: "Test AISKU dist canonicalizes PURE annotation spacing",
test: () => {
let request = new Request(this.rawFilePath, { method: "GET" });
return fetch(request).then((response) => {
if (!response.ok) {
Assert.ok(false, `fetch AISKU dist for PURE annotation check error: ${response.statusText}`);
return;
}

return response.text().then((text) => {
// Validate the final bundle no longer contains spaced PURE comment forms.
let nonCanonicalPurePattern = /\(\s+\/\*\s*[#@]__PURE__\s*\*\/|\(\s*\/\*\s*[#@]__PURE__\s*\*\/\s+/g;
let matches = text.match(nonCanonicalPurePattern) || [];
Assert.equal(0, matches.length, `Found ${matches.length} non-canonical PURE annotations in AISKU dist`);
}, (error: Error) => {
Assert.ok(false, `AISKU dist PURE annotation check response error: ${error}`);
});
}).catch((error: Error) => {
Assert.ok(false, `AISKU dist PURE annotation check error: ${error}`);
});
}
});
}

private _checkFileSize(isProd: boolean): void {
let _filePath = isProd? this.prodFilePath : this.rawFilePath;
Expand Down
26 changes: 26 additions & 0 deletions rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ function doCleanup() {
})
}

function fixPureAnnotations() {
const PURE_COMMENT_CANONICALIZE = /\(\s*\/\*\s*([#@])__PURE__\s*\*\/\s*/g;

return {
name: "fix-pure-annotations",
renderChunk(code) {
let normalized = code.replace(PURE_COMMENT_CANONICALIZE, "(/*$1__PURE__*/");

if (normalized === code) {
return null;
}

return {
code: normalized,
map: null
};
}
};
}

const getNamespace = (prefix, namespaces, baseName, rootName) => {
var result = prefix + "var " + baseName + "=" + rootName;
if (namespaces.length > 0) {
Expand Down Expand Up @@ -361,6 +381,9 @@ const browserRollupConfigFactory = (isOneDs, banner, importCheckNames, targetTyp
);
}

// Keep this as the final pass so all generated/included PURE comments are normalized.
browserRollupConfig.plugins.push(fixPureAnnotations());

// console.log(`Browser: ${JSON.stringify(browserRollupConfig)}`);

return browserRollupConfig;
Expand Down Expand Up @@ -422,6 +445,9 @@ const nodeUmdRollupConfigFactory = (banner, importCheckNames, targetType, theNam
);
}

// Keep this as the final pass so all generated/included PURE comments are normalized.
nodeRollupConfig.plugins.push(fixPureAnnotations());

return nodeRollupConfig;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class AppInsightsCoreSizeCheck extends AITestClass {
public registerTests() {
this.addRawFileSizeCheck();
this.addProdFileSizeCheck();
this.addRolldownPureAnnotationCheck();
}

constructor() {
Expand All @@ -80,6 +81,32 @@ export class AppInsightsCoreSizeCheck extends AITestClass {
private addProdFileSizeCheck(): void {
this._fileSizeCheck(true);
}

private addRolldownPureAnnotationCheck(): void {
this.testCase({
name: "Test applicationinsights-core dist canonicalizes PURE annotation spacing",
test: () => {
let request = new Request(this.rawFilePath, { method: "GET" });
return fetch(request).then((response) => {
if (!response.ok) {
Assert.ok(false, `fetch applicationinsights-core dist for PURE annotation check error: ${response.statusText}`);
return;
}

return response.text().then((text) => {
// Validate the final bundle no longer contains spaced PURE comment forms.
let nonCanonicalPurePattern = /\(\s+\/\*\s*[#@]__PURE__\s*\*\/|\(\s*\/\*\s*[#@]__PURE__\s*\*\/\s+/g;
let matches = text.match(nonCanonicalPurePattern) || [];
Assert.equal(0, matches.length, `Found ${matches.length} non-canonical PURE annotations in AppInsightsCore dist`);
}, (error) => {
Assert.ok(false, `applicationinsights-core dist PURE annotation check response error: ${error}`);
});
}).catch((error: Error) => {
Assert.ok(false, `applicationinsights-core dist PURE annotation check error: ${error}`);
});
}
});
}

private _fileSizeCheck(isProd: boolean): void {
let _filePath = isProd? this.prodFilePath : this.rawFilePath;
Expand Down
2 changes: 1 addition & 1 deletion shared/AppInsightsCore/src/ext/extUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isReactNative } from "../utils/EnvUtils";
/**
* Identifies the version for the extended SDK
*/
export const ExtVersion = "4.4.1";
export const ExtVersion = "#extVersion#";

/**
* Identifies the full version for the extended SDK
Expand Down
Loading