mirror of
https://github.com/ChromeDevTools/chrome-devtools-mcp.git
synced 2026-09-28 11:22:57 +08:00
fix(build): resolve node export conditions in rollup bundle (#2814)
pkce-challenge (a dependency of @modelcontextprotocol/client) defines package.json exports with only 'browser' and 'node' conditions and no 'default' condition. Because @rollup/plugin-node-resolve defaults to ['default', 'module', 'import'], it failed to resolve pkce-challenge during 'npm run bundle'. Rollup then emitted an UNRESOLVED_IMPORT warning and left an unbundled external 'import "pkce-challenge"' in build/src/third_party/index.js, causing the published npm package to fail at runtime with ERR_MODULE_NOT_FOUND. Configure nodeResolve with exportConditions: ['node'] and preferBuiltins: true, mark optional @puppeteer/browsers peer dependencies (proxy-agent, yauzl) as external, and fail the Rollup build on any UNRESOLVED_IMPORT warning. Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/2813
This commit is contained in:
+23
-3
@@ -293,8 +293,19 @@ const bundleDependency = (
|
||||
listBundledDeps(),
|
||||
commonjs(),
|
||||
json(),
|
||||
nodeResolve(),
|
||||
nodeResolve({
|
||||
exportConditions: ['node'],
|
||||
preferBuiltins: true,
|
||||
}),
|
||||
],
|
||||
onwarn(warning, warn) {
|
||||
if (warning.code === 'UNRESOLVED_IMPORT') {
|
||||
throw new Error(
|
||||
`Unresolved import: ${warning.message}. All third-party dependencies must be bundled or explicitly marked as external.`,
|
||||
);
|
||||
}
|
||||
warn(warning);
|
||||
},
|
||||
external,
|
||||
});
|
||||
|
||||
@@ -305,10 +316,19 @@ export default [
|
||||
inlineDynamicImports: true,
|
||||
},
|
||||
(source, importer, _isResolved) => {
|
||||
const normalizedImporter = importer?.replaceAll('\\', '/');
|
||||
if (
|
||||
source === 'yargs' &&
|
||||
importer &&
|
||||
importer.includes('puppeteer-core')
|
||||
normalizedImporter &&
|
||||
normalizedImporter.includes('puppeteer-core')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
(source === 'proxy-agent' || source === 'yauzl') &&
|
||||
normalizedImporter &&
|
||||
normalizedImporter.includes('@puppeteer/browsers')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1155,6 +1155,36 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
-------------------- DEPENDENCY DIVIDER --------------------
|
||||
|
||||
Name: pkce-challenge
|
||||
URL: https://github.com/crouchcd/pkce-challenge#readme
|
||||
Version: <VERSION>
|
||||
License: MIT
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
-------------------- DEPENDENCY DIVIDER --------------------
|
||||
|
||||
Name: uri-js
|
||||
|
||||
Reference in New Issue
Block a user