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

@sentry/webpack-plugin

Package Overview
Dependencies
Maintainers
12
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/webpack-plugin - npm Package Compare versions

Comparing version 1.17.3 to 1.18.0

4

CHANGELOG.md

@@ -8,2 +8,6 @@ # Changelog

## v1.18.0
- feat: Add support for multiple apps using Webpack Module Federation (#307)
## v1.17.3

@@ -10,0 +14,0 @@

2

package.json

@@ -11,3 +11,3 @@ {

"author": "Sentry",
"version": "1.17.3",
"version": "1.18.0",
"license": "MIT",

@@ -14,0 +14,0 @@ "repository": "git@github.com:getsentry/sentry-webpack-plugin.git",

@@ -77,2 +77,59 @@ const SentryCli = require('@sentry/cli');

function attachAfterCodeGenerationHook(compiler, options) {
if (!compiler.hooks || !compiler.hooks.make) {
return;
}
let webpackSources;
try {
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
webpackSources = require('webpack-sources');
} catch (_e) {
console.warn(
'Coud not resolve package: webpack-sources. Skipping injection for the remote entry file.'
);
return;
}
const { RawSource } = webpackSources;
const moduleFederationPlugin =
compiler.options &&
compiler.options.plugins &&
compiler.options.plugins.find(
x => x.constructor.name === 'ModuleFederationPlugin'
);
if (!moduleFederationPlugin) {
return;
}
compiler.hooks.make.tapAsync('SentryCliPlugin', (compilation, cb) => {
options.releasePromise.then(version => {
compilation.hooks.afterCodeGeneration.tap('SentryCliPlugin', () => {
compilation.modules.forEach(module => {
// eslint-disable-next-line no-underscore-dangle
if (module._name !== moduleFederationPlugin._options.name) return;
const sourceMap = compilation.codeGenerationResults.get(module)
.sources;
const rawSource = sourceMap.get('javascript');
sourceMap.set(
'javascript',
new RawSource(
`${rawSource.source()}
(function (){
var globalThis = (typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {});
globalThis.SENTRY_RELEASES = globalThis.SENTRY_RELEASES || {};
globalThis.SENTRY_RELEASES["${options.project}@${
options.org
}"] = {"id":"${version}"};
})();`
)
);
});
});
cb();
});
});
}
class SentryCliPlugin {

@@ -322,2 +379,4 @@ constructor(options = {}) {

releasePromise: this.release,
org: this.options.org || process.env.SENTRY_ORG,
project: this.options.project || process.env.SENTRY_PROJECT,
},

@@ -338,2 +397,4 @@ };

releasePromise: this.release,
org: this.options.org || process.env.SENTRY_ORG,
project: this.options.project || process.env.SENTRY_PROJECT,
},

@@ -507,2 +568,8 @@ },

attachAfterCodeGenerationHook(compiler, {
releasePromise: this.release,
org: this.options.org || process.env.SENTRY_ORG,
project: this.options.project || process.env.SENTRY_PROJECT,
});
attachAfterEmitHook(compiler, (compilation, cb) => {

@@ -509,0 +576,0 @@ if (!this.options.include || !this.options.include.length) {

module.exports = function sentryLoader(content, map, meta) {
const { releasePromise } = this.query;
const { releasePromise, org, project } = this.query;
const callback = this.async();
releasePromise.then(version => {
const sentryRelease = `(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}).SENTRY_RELEASE={id:"${version}"};`;
let sentryRelease = `const _global = (typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); _global.SENTRY_RELEASE={id:"${version}"};`;
if (project) {
const key = org ? `${project}@${org}` : project;
sentryRelease += `
_global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};
_global.SENTRY_RELEASES["${key}"]={id:"${version}"};
`;
}
callback(null, sentryRelease, map, meta);
});
};
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