diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52586982a..6fba0af93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,9 @@ jobs: runs-on: ubuntu-latest + env: + PUPPETEER_SKIP_DOWNLOAD: true + strategy: matrix: node-version: [ 18, 20, 22, 24 ] diff --git a/AISKU/Tests/Unit/src/AISKUSize.Tests.ts b/AISKU/Tests/Unit/src/AISKUSize.Tests.ts index f40aec3dd..87052898d 100644 --- a/AISKU/Tests/Unit/src/AISKUSize.Tests.ts +++ b/AISKU/Tests/Unit/src/AISKUSize.Tests.ts @@ -92,6 +92,7 @@ export class AISKUSizeCheck extends AITestClass { public registerTests() { this.addRawFileSizeCheck(); this.addProdFileSizeCheck(); + this.addRolldownPureAnnotationCheck(); } constructor() { @@ -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; diff --git a/rollup.base.config.js b/rollup.base.config.js index 4b6f18efb..5f3690b5b 100644 --- a/rollup.base.config.js +++ b/rollup.base.config.js @@ -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) { @@ -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; @@ -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; }; diff --git a/shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts index 8997e871d..3037ed3c3 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts @@ -67,6 +67,7 @@ export class AppInsightsCoreSizeCheck extends AITestClass { public registerTests() { this.addRawFileSizeCheck(); this.addProdFileSizeCheck(); + this.addRolldownPureAnnotationCheck(); } constructor() { @@ -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; diff --git a/shared/AppInsightsCore/src/ext/extUtils.ts b/shared/AppInsightsCore/src/ext/extUtils.ts index 9107aea2f..1a19eb2ca 100644 --- a/shared/AppInsightsCore/src/ext/extUtils.ts +++ b/shared/AppInsightsCore/src/ext/extUtils.ts @@ -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