fix webignore patterns for appinsights

also, web: look for minified entrypoints as well

Closes: #140158
This commit is contained in:
Joao Moreno 2022-01-07 15:18:18 +01:00
parent 35c70dc0a2
commit a9acf06479
No known key found for this signature in database
GPG key ID: 896B853774D1A575
3 changed files with 30 additions and 5 deletions

View file

@ -32,3 +32,7 @@ xterm-addon-webgl/out/**
# This makes sure the model is included in the package
!@vscode/vscode-languagedetection/model/**
@microsoft/applicationinsights*/**
@microsoft/dynamicproto-js/**
!@microsoft/applicationinsights-web/dist/applicationinsights-web.min.js

View file

@ -323,10 +323,17 @@ function acquireWebNodePaths() {
}
// Remove any starting path information so it's all relative info
if (entryPoint.startsWith('./')) {
entryPoint = entryPoint.substr(2);
entryPoint = entryPoint.substring(2);
}
else if (entryPoint.startsWith('/')) {
entryPoint = entryPoint.substr(1);
entryPoint = entryPoint.substring(1);
}
// Search for a minified entrypoint as well
if (/(?<!\.min)\.js$/i.test(entryPoint)) {
const minEntryPoint = entryPoint.replace(/\.js$/i, '.min.js');
if (fs.existsSync(path.join(root, 'node_modules', key, minEntryPoint))) {
entryPoint = minEntryPoint;
}
}
nodePaths[key] = entryPoint;
}

View file

@ -384,23 +384,37 @@ export function acquireWebNodePaths() {
for (const key of Object.keys(webPackages)) {
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
let entryPoint = packageData.browser ?? packageData.main;
let entryPoint: string = packageData.browser ?? packageData.main;
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
if (!entryPoint) {
// TODO @lramos15 remove this when jschardet adds an entrypoint so we can warn on all packages w/out entrypoint
if (key !== 'jschardet') {
console.warn(`No entry point for ${key} assuming dist/${key}.min.js`);
}
entryPoint = `dist/${key}.min.js`;
}
// Remove any starting path information so it's all relative info
if (entryPoint.startsWith('./')) {
entryPoint = entryPoint.substr(2);
entryPoint = entryPoint.substring(2);
} else if (entryPoint.startsWith('/')) {
entryPoint = entryPoint.substr(1);
entryPoint = entryPoint.substring(1);
}
// Search for a minified entrypoint as well
if (/(?<!\.min)\.js$/i.test(entryPoint)) {
const minEntryPoint = entryPoint.replace(/\.js$/i, '.min.js');
if (fs.existsSync(path.join(root, 'node_modules', key, minEntryPoint))) {
entryPoint = minEntryPoint;
}
}
nodePaths[key] = entryPoint;
}
return nodePaths;
}