Skip to content

Commit

Permalink
fix webignore patterns for appinsights
Browse files Browse the repository at this point in the history
also, web: look for minified entrypoints as well

Closes: microsoft#140158
  • Loading branch information
joaomoreno committed Jan 7, 2022
1 parent 35c70dc commit a9acf06
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions build/.webignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 9 additions & 2 deletions build/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 17 additions & 3 deletions build/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a9acf06

Please sign in to comment.