Skip to content

Commit e0b7b6b

Browse files
committed
fix build
1 parent a1e7794 commit e0b7b6b

File tree

10 files changed

+52
-26
lines changed

10 files changed

+52
-26
lines changed

.github/workflows/run-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242

4343
- name: Build
4444
run: npm run bundle
45+
env:
46+
NODE_OPTIONS: "--max_old_space_size=4096"
4547

4648
- name: Set up Node.js
4749
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
@@ -62,7 +64,7 @@ jobs:
6264
- name: Run tests
6365
shell: bash
6466
if: ${{ matrix.node != '20' }}
65-
run: npm run test
67+
run: npm run test:no-build
6668

6769
# Gating job for branch protection.
6870
test-success:

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"main": "index.js",
88
"scripts": {
99
"clean": "node -e \"require('fs').rmSync('build', {recursive: true, force: true})\"",
10-
"bundle": "npm run clean && npm run build && rollup -c rollup.config.mjs",
10+
"bundle": "npm run clean && npm run build && rollup -c rollup.config.mjs && node -e \"require('fs').rmSync('build/node_modules', {recursive: true, force: true})\"",
1111
"build": "tsc && node --experimental-strip-types --no-warnings=ExperimentalWarning scripts/post-build.ts",
1212
"typecheck": "tsc --noEmit",
1313
"format": "eslint --cache --fix . && prettier --write --cache .",
@@ -16,11 +16,12 @@
1616
"docs:generate": "node --experimental-strip-types scripts/generate-docs.ts",
1717
"start": "npm run build && node build/src/index.js",
1818
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
19-
"test:node20": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test build/tests",
20-
"test": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --experimental-print-required-tla --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
21-
"test:only": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
22-
"test:only:no-build": "node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
23-
"test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
19+
"test:node20": "node --import ./build/tests/setup.js --test-reporter spec --test-force-exit --test build/tests",
20+
"test:no-build": "node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --experimental-print-required-tla --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
21+
"test": "npm run build && node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --experimental-print-required-tla --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"",
22+
"test:only": "npm run build && node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
23+
"test:only:no-build": "node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"",
24+
"test:update-snapshots": "npm run build && node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"",
2425
"prepare": "node --experimental-strip-types scripts/prepare.ts",
2526
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts"
2627
},

rollup.config.mjs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* and modified to specific requirement.
2020
*/
2121

22-
import path from 'node:path';
2322
import fs from 'node:fs';
23+
import path from 'node:path';
2424

2525
import commonjs from '@rollup/plugin-commonjs';
2626
import json from '@rollup/plugin-json';
@@ -98,29 +98,51 @@ const bundleDependency = (
9898
});
9999

100100
// Manual license handling for chrome-devtools-frontend third_party
101-
const tsConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'tsconfig.json'), 'utf-8'));
102-
const thirdPartyDirectories = tsConfig.include.filter(location => {
101+
const tsConfig = JSON.parse(
102+
fs.readFileSync(
103+
path.join(process.cwd(), 'tsconfig.json'),
104+
'utf-8',
105+
),
106+
);
107+
const thirdPartyDirectories = tsConfig.include.filter(location => {
103108
return location.includes(
104109
'node_modules/chrome-devtools-frontend/front_end/third_party',
105110
);
106111
});
107112

108113
const manualLicenses = [];
109114
// Add chrome-devtools-frontend main license
110-
const cdtfLicensePath = path.join(process.cwd(), 'node_modules/chrome-devtools-frontend/LICENSE');
115+
const cdtfLicensePath = path.join(
116+
process.cwd(),
117+
'node_modules/chrome-devtools-frontend/LICENSE',
118+
);
111119
if (fs.existsSync(cdtfLicensePath)) {
112-
manualLicenses.push(['Name: chrome-devtools-frontend', 'License: Apache-2.0', '', fs.readFileSync(cdtfLicensePath, 'utf-8')].join('\n'));
120+
manualLicenses.push(
121+
[
122+
'Name: chrome-devtools-frontend',
123+
'License: Apache-2.0',
124+
'',
125+
fs.readFileSync(cdtfLicensePath, 'utf-8'),
126+
].join('\n'),
127+
);
113128
}
114129

115130
for (const thirdPartyDir of thirdPartyDirectories) {
116131
const fullPath = path.join(process.cwd(), thirdPartyDir);
117132
const licenseFile = path.join(fullPath, 'LICENSE');
118133
if (fs.existsSync(licenseFile)) {
119-
const name = path.basename(thirdPartyDir);
120-
manualLicenses.push([`Name: ${name}`, `License: Custom`, '', fs.readFileSync(licenseFile, 'utf-8').replaceAll('\r', '')].join('\n'));
134+
const name = path.basename(thirdPartyDir);
135+
manualLicenses.push(
136+
[
137+
`Name: ${name}`,
138+
`License: Custom`,
139+
'',
140+
fs.readFileSync(licenseFile, 'utf-8').replaceAll('\r', ''),
141+
].join('\n'),
142+
);
121143
}
122144
}
123-
145+
124146
if (manualLicenses.length > 0) {
125147
stringified_dependencies.push(...manualLicenses);
126148
}

scripts/post-build.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function writeFile(filePath: string, content: string): void {
2020
fs.writeFileSync(filePath, content, 'utf-8');
2121
}
2222

23-
2423
function main(): void {
2524
const devtoolsThirdPartyPath =
2625
'node_modules/chrome-devtools-frontend/front_end/third_party';
@@ -96,7 +95,12 @@ function copyDevToolsDescriptionFiles() {
9695
const devtoolsIssuesDescriptionPath =
9796
'node_modules/chrome-devtools-frontend/front_end/models/issues_manager/descriptions';
9897
const sourceDir = path.join(process.cwd(), devtoolsIssuesDescriptionPath);
99-
const destDir = path.join(BUILD_DIR, devtoolsIssuesDescriptionPath);
98+
const destDir = path.join(
99+
BUILD_DIR,
100+
'src',
101+
'third_party',
102+
'issue-descriptions',
103+
);
100104
fs.cpSync(sourceDir, destDir, {recursive: true});
101105
}
102106

src/issue-descriptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as path from 'node:path';
99

1010
const DESCRIPTIONS_PATH = path.join(
1111
import.meta.dirname,
12-
'../node_modules/chrome-devtools-frontend/front_end/models/issues_manager/descriptions',
12+
'third_party/issue-descriptions',
1313
);
1414

1515
let issueDescriptions: Record<string, string> = {};

tests/DevtoolsUtils.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ import {afterEach, describe, it} from 'node:test';
99

1010
import sinon from 'sinon';
1111

12-
import {
13-
AggregatedIssue,
14-
DebuggerModel,
15-
} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
1612
import {
1713
extractUrlLikeFromDevToolsTitle,
1814
urlsEqual,
1915
mapIssueToMessageObject,
2016
UniverseManager,
2117
} from '../src/DevtoolsUtils.js';
2218
import {ISSUE_UTILS} from '../src/issue-descriptions.js';
19+
import {AggregatedIssue, DebuggerModel} from '../src/third_party/index.js';
2320
import type {Browser, Target} from '../src/third_party/index.js';
2421

2522
import {

tests/PageCollector.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {beforeEach, describe, it} from 'node:test';
1010
import type {Frame, HTTPRequest, Target, Protocol} from 'puppeteer-core';
1111
import sinon from 'sinon';
1212

13-
import {AggregatedIssue} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
1413
import type {ListenerMap} from '../src/PageCollector.js';
1514
import {
1615
ConsoleCollector,
1716
NetworkCollector,
1817
PageCollector,
1918
} from '../src/PageCollector.js';
19+
import {AggregatedIssue} from '../src/third_party/index.js';
2020

2121
import {getMockRequest, getMockBrowser} from './utils.js';
2222

tests/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (!it.snapshot) {
2020
};
2121
}
2222

23-
// This is run by Node when we execute the tests via the --require flag.
23+
// This is run by Node when we execute the tests via the --import flag.
2424
it.snapshot.setResolveSnapshotPath(testPath => {
2525
// By default the snapshots go into the build directory, but we want them
2626
// in the tests/ directory.

tests/tools/console.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import assert from 'node:assert';
88
import {before, describe, it} from 'node:test';
99

10-
import {AggregatedIssue} from '../../node_modules/chrome-devtools-frontend/mcp/mcp.js';
1110
import {loadIssueDescriptions} from '../../src/issue-descriptions.js';
1211
import {McpResponse} from '../../src/McpResponse.js';
12+
import {AggregatedIssue} from '../../src/third_party/index.js';
1313
import {
1414
getConsoleMessage,
1515
listConsoleMessages,

tests/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import type {
1717
} from 'puppeteer-core';
1818
import sinon from 'sinon';
1919

20-
import {AggregatedIssue} from '../node_modules/chrome-devtools-frontend/mcp/mcp.js';
2120
import {McpContext} from '../src/McpContext.js';
2221
import {McpResponse} from '../src/McpResponse.js';
2322
import {stableIdSymbol} from '../src/PageCollector.js';
23+
import {AggregatedIssue} from '../src/third_party/index.js';
2424

2525
export function getTextContent(
2626
content: CallToolResult['content'][number],

0 commit comments

Comments
 (0)