Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azure-devops-symbols-webpack-plugin

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-devops-symbols-webpack-plugin - npm Package Compare versions

Comparing version 1.3.3 to 1.4.0

19

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Fri, 25 Mar 2022 15:57:26 GMT",
"date": "Tue, 12 Jul 2022 20:18:34 GMT",
"tag": "azure-devops-symbols-webpack-plugin_v1.4.0",
"version": "1.4.0",
"comments": {
"minor": [
{
"author": "yfeigelson@microsoft.com",
"package": "azure-devops-symbols-webpack-plugin",
"commit": "ff2b13510854cdcb28823fec5b2751ef3b936d0b",
"comment": "Adding an optional configuration to use Edge devtools + ADO PAT"
}
]
}
},
{
"date": "Fri, 25 Mar 2022 15:57:32 GMT",
"tag": "azure-devops-symbols-webpack-plugin_v1.3.3",

@@ -15,3 +30,3 @@ "version": "1.3.3",

"comment": "Bump azure-devops-symbols-sourcemap to v1.2.1",
"commit": "d922f7cc2efaddf7ce258179af5ba1377a0d35ef"
"commit": "2ac6862c4513849c518ad4d177cf84f38164e0ed"
}

@@ -18,0 +33,0 @@ ]

# Change Log - azure-devops-symbols-webpack-plugin
This log was last generated on Fri, 25 Mar 2022 15:57:26 GMT and should not be manually modified.
This log was last generated on Tue, 12 Jul 2022 20:18:34 GMT and should not be manually modified.
<!-- Start content -->
## 1.4.0
Tue, 12 Jul 2022 20:18:34 GMT
### Minor changes
- Adding an optional configuration to use Edge devtools + ADO PAT (yfeigelson@microsoft.com)
## 1.3.3
Fri, 25 Mar 2022 15:57:26 GMT
Fri, 25 Mar 2022 15:57:32 GMT

@@ -11,0 +19,0 @@ ### Patches

import * as webpackTypes from "webpack";
export interface AzureDevOpsSymbolsPluginOptions {
organization: string;
useEdgePAT?: boolean;
}
export declare class AzureDevOpsSymbolsPlugin {
organization: string;
useEdgePAT: boolean;
constructor(options?: AzureDevOpsSymbolsPluginOptions);
apply(compiler: webpackTypes.Compiler): void;
}

36

lib/plugin.js

@@ -19,4 +19,6 @@ "use strict";

this.organization = "<Organization>";
this.useEdgePAT = false;
if (options) {
this.organization = options.organization;
this.useEdgePAT = !!options.useEdgePAT;
}

@@ -45,5 +47,5 @@ }

};
compiler.hooks.compilation.tap(pluginName, compilation => {
compiler.hooks.compilation.tap(pluginName, (compilation) => {
// Register a hook just before CommonJsChunkFormatPlugin runs
// and add field to the .js.map sourceMap file that contains the
// and add field to the .js.map sourceMap file that contains the
// symbol client key to which the Azure DevOps symbol upload task

@@ -61,4 +63,7 @@ // should push the symbols.

if (sourceMap) {
// Compute the hash of the sourcefile (before appending the sourceUrl comment)
const hash = compiler.webpack.util.createHash(compilation.outputOptions.hashFunction || "md4");
// Compute the hash of the sourcefile (this is the hash before appending the sourceUrl comment, if appended)
const hashFunc = this.useEdgePAT
? "sha256"
: compilation.outputOptions.hashFunction || "md4";
const hash = compiler.webpack.util.createHash(hashFunc);
asset.source.updateHash(hash);

@@ -72,3 +77,9 @@ const clientKey = hash.digest("hex");

const source = new webpack.sources.SourceMapSource(asset.source.buffer(), asset.name, sourceMap, undefined, undefined, true);
compilation.updateAsset(asset.name, source, info => Object.assign(info, { adoSourecMapEnabled: true, related: { sourceMapLineToAppend: sourceMapLineToAppend, clientKey: clientKey } }));
compilation.updateAsset(asset.name, source, (info) => Object.assign(info, {
adoSourecMapEnabled: true,
related: {
sourceMapLineToAppend: sourceMapLineToAppend,
clientKey: clientKey,
},
}));
}

@@ -81,10 +92,13 @@ }

stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
additionalAssets: true
additionalAssets: true,
}, (assets) => __awaiter(this, void 0, void 0, function* () {
for (const file of Object.keys(assets)) {
let asset = compilation.getAsset(file);
if (asset && asset.info.related && asset.info.related.sourceMapLineToAppend) {
if (asset &&
asset.info.related &&
asset.info.related.sourceMapLineToAppend &&
!this.useEdgePAT) {
console.log(`Adding SourceMap comment to ${asset.name}`);
const content = asset.info.related.sourceMapLineToAppend;
compilation.updateAsset(file, source => new webpack.sources.ConcatSource(source, content), undefined);
compilation.updateAsset(file, (source) => new webpack.sources.ConcatSource(source, content), undefined);
}

@@ -95,7 +109,9 @@ }

name: pluginName,
}, stats => {
}, (stats) => {
const id = (x) => x;
stats.hooks.print
.for("asset.info.related.sourceMapLineToAppend")
.tap(pluginName, (sourceMapLineToAppend, { cyan, formatFlag }) => sourceMapLineToAppend ? (cyan || id)((formatFlag || id)("azure sourcemap")) : "");
.tap(pluginName, (sourceMapLineToAppend, { cyan, formatFlag }) => sourceMapLineToAppend
? (cyan || id)((formatFlag || id)("azure sourcemap"))
: "");
});

@@ -102,0 +118,0 @@ });

{
"name": "azure-devops-symbols-webpack-plugin",
"version": "1.3.3",
"version": "1.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "lib/plugin.js",

// Only use the static one for types, so that we can use the dynamic version of webpack we get from the plugin intialization
import * as webpackTypes from "webpack";
import * as path from "path";
import { computeSourceMapUrlLine, setClientKeyOnSourceMap } from "azure-devops-symbols-sourcemap";
import {
computeSourceMapUrlLine,
setClientKeyOnSourceMap,
} from "azure-devops-symbols-sourcemap";

@@ -9,118 +12,154 @@ const pluginName = "AzureDevOpsSymbolsPlugin";

export interface AzureDevOpsSymbolsPluginOptions {
organization: string;
organization: string;
// Using the Edge AzureDevOps PersonalAccessToken route. In this case the 'sourceMappingURL' isn't appended, and users must add their ADO PAT in Edge DevTools
// See https://blogs.windows.com/msedgedev/2022/04/12/retrieve-source-maps-securely-in-production-in-microsoft-edge-devtools/
useEdgePAT?: boolean;
}
export class AzureDevOpsSymbolsPlugin
{
organization: string = "<Organization>";
constructor(options?: AzureDevOpsSymbolsPluginOptions)
{
if (options) {
this.organization = options.organization;
}
export class AzureDevOpsSymbolsPlugin {
organization: string = "<Organization>";
useEdgePAT: boolean = false;
constructor(options?: AzureDevOpsSymbolsPluginOptions) {
if (options) {
this.organization = options.organization;
this.useEdgePAT = !!options.useEdgePAT;
}
}
apply(compiler: webpackTypes.Compiler) {
// ensure proper runtime version of webpack is used below
const { webpack, options } = compiler;
apply(compiler: webpackTypes.Compiler) {
// ensure proper runtime version of webpack is used below
const { webpack, options } = compiler;
// If we don't have source-map as a dev-tool this plugin doesn't need to do anything
if (!options.devtool || !options.devtool.includes("source-map")) {
return;
}
// If we don't have source-map as a dev-tool this plugin doesn't need to do anything
if (!options.devtool || !options.devtool.includes("source-map")) {
return;
}
const hidden = options.devtool.includes("hidden");
if (!hidden) {
throw new Error(`When using plugin ${pluginName} you must set 'hidden' on the 'devtool' settings to true. To avoid declaring two sourcemap comments.`)
}
const hidden = options.devtool.includes("hidden");
if (!hidden) {
throw new Error(
`When using plugin ${pluginName} you must set 'hidden' on the 'devtool' settings to true. To avoid declaring two sourcemap comments.`
);
}
// The options we pass to extract the source map must match exactly what SourceMapDevToolPlugin
// does internally, because else when we ask to get the sourcemap object we get a newly
// computed one with differnt options, so when we add the extra fields, they won't be
// in the final .js.map file
const cheap = options.devtool.includes("cheap");
const moduleMaps = options.devtool.includes("module");
const sourceMapOptions = {
module: moduleMaps ? true : cheap ? false : true,
columns: cheap ? false : true,
};
// The options we pass to extract the source map must match exactly what SourceMapDevToolPlugin
// does internally, because else when we ask to get the sourcemap object we get a newly
// computed one with differnt options, so when we add the extra fields, they won't be
// in the final .js.map file
const cheap = options.devtool.includes("cheap");
const moduleMaps = options.devtool.includes("module");
const sourceMapOptions = {
module: moduleMaps ? true : cheap ? false : true,
columns: cheap ? false : true,
};
compiler.hooks.compilation.tap(pluginName,
compilation => {
compiler.hooks.compilation.tap(pluginName, (compilation) => {
// Register a hook just before CommonJsChunkFormatPlugin runs
// and add field to the .js.map sourceMap file that contains the
// symbol client key to which the Azure DevOps symbol upload task
// should push the symbols.
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
// This should run just before the CommonJsChunkFormatPlugin runs
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1,
},
async (assets) => {
for (const file of Object.keys(assets)) {
let asset = compilation.getAsset(file);
if (asset) {
const sourceMap = asset.source.map(sourceMapOptions);
if (sourceMap) {
// Compute the hash of the sourcefile (this is the hash before appending the sourceUrl comment, if appended)
const hashFunc = this.useEdgePAT
? "sha256"
: compilation.outputOptions.hashFunction || "md4";
const hash = compiler.webpack.util.createHash(hashFunc);
asset.source.updateHash(hash);
const clientKey = <string>hash.digest("hex");
// Register a hook just before CommonJsChunkFormatPlugin runs
// and add field to the .js.map sourceMap file that contains the
// symbol client key to which the Azure DevOps symbol upload task
// should push the symbols.
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
// This should run just before the CommonJsChunkFormatPlugin runs
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1,
},
async (assets) => {
for (const file of Object.keys(assets)) {
let asset = compilation.getAsset(file);
if (asset) {
const sourceMap = asset.source.map(sourceMapOptions);
if (sourceMap){
// Compute the hash of the sourcefile (before appending the sourceUrl comment)
const hash = compiler.webpack.util.createHash(compilation.outputOptions.hashFunction || "md4")
asset.source.updateHash(hash);
const clientKey = <string>hash.digest("hex");
console.log(
`Tagging sourcemap with ${clientKey} to ${asset.name}`
);
console.log(`Tagging sourcemap with ${clientKey} to ${asset.name}`);
// Add the sourcemap client id field to the sourcemap json object.
setClientKeyOnSourceMap(clientKey, sourceMap);
// Add the sourcemap client id field to the sourcemap json object.
setClientKeyOnSourceMap(clientKey, sourceMap);
const sourceMapFileName = path.basename(file) + ".map";
const sourceMapLineToAppend = computeSourceMapUrlLine(
this.organization,
clientKey,
sourceMapFileName
);
const sourceMapFileName = path.basename(file) + ".map";
const sourceMapLineToAppend = computeSourceMapUrlLine(this.organization, clientKey, sourceMapFileName);
const source = new webpack.sources.SourceMapSource(asset.source.buffer(), asset.name, sourceMap, undefined, undefined, true);
compilation.updateAsset(
asset.name,
source,
info => Object.assign(info, {adoSourecMapEnabled: true, related: {sourceMapLineToAppend: sourceMapLineToAppend, clientKey: clientKey}})
);
}
}
}
});
const source = new webpack.sources.SourceMapSource(
asset.source.buffer(),
asset.name,
sourceMap,
undefined,
undefined,
true
);
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
additionalAssets: true
},
async (assets) => {
for (const file of Object.keys(assets)) {
let asset = compilation.getAsset(file);
if (asset && asset.info.related && asset.info.related.sourceMapLineToAppend) {
console.log(`Adding SourceMap comment to ${asset.name}`);
const content = <string>asset.info.related.sourceMapLineToAppend;
compilation.updateAsset(asset.name, source, (info) =>
Object.assign(info, {
adoSourecMapEnabled: true,
related: {
sourceMapLineToAppend: sourceMapLineToAppend,
clientKey: clientKey,
},
})
);
}
}
}
}
);
compilation.updateAsset(
file,
source => new webpack.sources.ConcatSource(source, content),
undefined
);
}
}
});
compilation.hooks.processAssets.tapPromise(
{
name: pluginName,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
additionalAssets: true,
},
async (assets) => {
for (const file of Object.keys(assets)) {
let asset = compilation.getAsset(file);
if (
asset &&
asset.info.related &&
asset.info.related.sourceMapLineToAppend &&
!this.useEdgePAT
) {
console.log(`Adding SourceMap comment to ${asset.name}`);
const content = <string>asset.info.related.sourceMapLineToAppend;
compilation.hooks.statsPrinter.tap(
{
name: pluginName,
},
stats => {
const id = (x: string) => x
stats.hooks.print
.for("asset.info.related.sourceMapLineToAppend")
.tap(pluginName, (sourceMapLineToAppend, {cyan, formatFlag}) => sourceMapLineToAppend ? (cyan || id) ( (formatFlag || id) ("azure sourcemap")) : "");
});
});
}
compilation.updateAsset(
file,
(source) => new webpack.sources.ConcatSource(source, content),
undefined
);
}
}
}
);
compilation.hooks.statsPrinter.tap(
{
name: pluginName,
},
(stats) => {
const id = (x: string) => x;
stats.hooks.print
.for("asset.info.related.sourceMapLineToAppend")
.tap(pluginName, (sourceMapLineToAppend, { cyan, formatFlag }) =>
sourceMapLineToAppend
? (cyan || id)((formatFlag || id)("azure sourcemap"))
: ""
);
}
);
});
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc