@sentry/webpack-plugin
Advanced tools
Comparing version 1.17.3 to 1.18.0
@@ -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 @@ |
@@ -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); | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50860
693
7