@sentry/webpack-plugin
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -5,4 +5,8 @@ # Changelog | ||
- "Would I rather be feared or loved? Easy. Both. I want people to be afraid of how much they love me." | ||
- "Would I rather be feared or loved? Easy. Both. I want people to be afraid of how much they love me." — Michael Scott | ||
## v1.14.0 | ||
- feat: Add support for Webpack 5 entry descriptors (#241) | ||
## v1.13.0 | ||
@@ -9,0 +13,0 @@ |
{ | ||
"name": "@sentry/webpack-plugin", | ||
"description": "Official webpack plugin for Sentry", | ||
"keywords": ["sentry", "sentry-cli", "webpack", "source-map"], | ||
"keywords": [ | ||
"sentry", | ||
"sentry-cli", | ||
"webpack", | ||
"source-map" | ||
], | ||
"author": "Sentry", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"license": "MIT", | ||
@@ -28,3 +33,2 @@ "repository": "git@github.com:getsentry/sentry-webpack-plugin.git", | ||
"prettier-check": "^2.0.0", | ||
"snyk": "^1.240.1", | ||
"webpack": "^4.39.3" | ||
@@ -42,7 +46,4 @@ }, | ||
"test:watch": "jest --watch --notify", | ||
"codecov": "codecov", | ||
"snyk-protect": "snyk protect", | ||
"prepublish": "npm run snyk-protect" | ||
}, | ||
"snyk": true | ||
"codecov": "codecov" | ||
} | ||
} |
@@ -64,23 +64,29 @@ <p align="center"> | ||
---------|------|----------|------------- | ||
release | `string` | optional | unique name of a release, must be a `string`, should uniquely identify your release, defaults to `sentry-cli releases propose-version` command which should always return the correct version (**requires access to `git` CLI and root directory to be a valid repository**). | ||
include | `string`/`array` | required | one or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files | | ||
entries | `array`/`RegExp`/`function(key: string): bool` | optional | a filter for entry points that should be processed. By default, the release will be injected into all entry points. | | ||
| ignoreFile | `string` | optional | path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with same format | | ||
| ignore | `string`/`array` | optional | one or more paths to ignore during upload. Overrides entries in `ignoreFile` file. If neither `ignoreFile` or `ignore` are present, defaults to `['node_modules']` | | ||
| configFile | `string` | optional | path to Sentry CLI config properties, as described in https://docs.sentry.io/learn/cli/configuration/#properties-files. By default, the config file is looked for upwards from the current path and defaults from `~/.sentryclirc` are always loaded | | ||
| ext | `array` | optional | this sets the file extensions to be considered. By default the following file extensions are processed: js, map, jsbundle and bundle. | | ||
| urlPrefix | `string` | optional | this sets an URL prefix at the beginning of all files. This defaults to `~/` but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: `url-prefix '~/static/js'` | | ||
| urlSuffix | `string` | optional | this sets an URL suffix at the end of all files. Useful for appending query parameters. | | ||
| validate | `boolean` | optional | this attempts sourcemap validation before upload when rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. This is not the default as this can cause false positives. | | ||
| stripPrefix | `array` | optional | when paired with `rewrite` this will chop-off a prefix from uploaded files. For instance you can use this to remove a path that is build machine specific. | | ||
| stripCommonPrefix | `boolean` | optional | when paired with `rewrite` this will add `~` to the `stripPrefix` array. | | ||
| sourceMapReference | `boolean` | optional | this prevents the automatic detection of sourcemap references. | | ||
| rewrite | `boolean` | optional | enables rewriting of matching sourcemaps so that indexed maps are flattened and missing sources are inlined if possible. defaults to `true` | | ||
| finalize | `boolean` | optional | determines whether processed release should be automatically finalized after artifacts upload. defaults to `true` | | ||
| dryRun | `boolean` | optional | attempts a dry run (useful for dev environments) | | ||
| debug | `boolean` | optional | print some useful debug information | | ||
| silent | `boolean` | optional | if `true`, all logs are suppressed (useful for `--json` option) | | ||
| errorHandler | `function(err: Error, invokeErr: function(): void, compilation: Compilation): void` | optional | when Cli error occurs, plugin calls this function. webpack compilation failure can be chosen by calling `invokeErr` callback or not. If you don't want this plugin to prevent further compilation, you can use a compilation warning instead by setting this option to `(err, invokeErr, compilation) => { compilation.warnings.push('Sentry CLI Plugin: ' + err.message) }` instead. defaults to `(err, invokeErr) => { invokeErr() }` | | ||
| setCommits | `Object` | optional | Adds commits to sentry - [see own table below](#setCommits) for more details | | ||
| deploy | `Object` | optional | Creates a new release deployment - [see own table below](#deploy) for more details | | ||
| include | `string`/`array` | required | One or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. | | ||
| org | `string` | optional | The slug of the Sentry organization associated with the app. | | ||
| project | `string` | optional | The slug of the Sentry project associated with the app. | | ||
| authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. | | ||
| url | `string` | optional | The base URL of your Sentry instance. Defaults to https://sentry.io/, which is the correct value for SAAS customers. | | ||
| vcsRemote | `string` | optional | The name of the remote in the version control system. Defaults to `origin`. | | ||
| release | `string` | optional | Unique identifier for the release. Defaults to the output of the `sentry-cli releases propose-version` command, which automatically detects values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses `HEAD`'s commit SHA. (**For `HEAD` option, requires access to `git` CLI and for the root directory to be a valid repository**). | | ||
| dist | `string` | optional | Unique identifier for the distribution, used to further segment your release. Usually your build number. | | ||
| entries | `array`/`RegExp`/`function(key: string): bool` | optional | Filter for entry points that should be processed. By default, the release will be injected into all entry points. | | ||
| ignoreFile | `string` | optional | Path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with the same format. | | ||
| ignore | `string`/`array` | optional | One or more paths to ignore during upload. Overrides entries in `ignoreFile` file. If neither `ignoreFile` nor `ignore` is present, defaults to `['node_modules']`. | | ||
| configFile | `string` | optional | Path to Sentry CLI config properties, as described in https://docs.sentry.io/product/cli/configuration/#configuration-file. By default, the config file is looked for upwards from the current path, and defaults from `~/.sentryclirc` are always loaded | | ||
| ext | `array` | optional | The file extensions to be considered. By default the following file extensions are processed: `js`, `map`, `jsbundle`, and `bundle`. | | ||
| urlPrefix | `string` | optional | URL prefix to add to the beginning of all filenames. Defaults to `~/` but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: `url-prefix '~/static/js'`. | | ||
| urlSuffix | `string` | optional | URL suffix to add to the end of all filenamess. Useful for appending query parameters. | | ||
| validate | `boolean` | optional | When `true`, attempts source map validation before upload if rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. Defaults to `false` to prevent false positives canceling upload. | | ||
| stripPrefix | `array` | optional | When paired with `rewrite`, will remove a prefix from uploaded filenames. Useful for removing a path that is build-machine-specific. | | ||
| stripCommonPrefix | `boolean` | optional | When paired with `rewrite`, will add `~` to the `stripPrefix` array. Defaults to `false`.| | ||
| sourceMapReference | `boolean` | optional | Prevents the automatic detection of sourcemap references. Defaults to `false`.| | ||
| rewrite | `boolean` | optional | Enables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to `true` | | ||
| finalize | `boolean` | optional | Determines whether Sentry release record should be automatically finalized (`date_released` timestamp added) after artifact upload. Defaults to `true` | | ||
| dryRun | `boolean` | optional | Attempts a dry run (useful for dev environments). Defaults to `false`. | | ||
| debug | `boolean` | optional | Print useful debug information. Defaults to `false`.| | ||
| silent | `boolean` | optional | Suppresses all logs (useful for `--json` option). Defaults to `false`. | | ||
| errorHandler | `function(err: Error, invokeErr: function(): void, compilation: Compilation): void` | optional | Function to call a when CLI error occurs. Webpack compilation failure can be triggered by calling `invokeErr` callback. Can emit a warning rather than an error (allowing compilation to continue) by setting this to `(err, invokeErr, compilation) => { compilation.warnings.push('Sentry CLI Plugin: ' + err.message) }`. Defaults to `(err, invokeErr) => { invokeErr() }`. | | ||
| setCommits | `Object` | optional | Adds commits to Sentry. See [table below](#setCommits) for details. | | ||
| deploy | `Object` | optional | Creates a new release deployment in Sentry. See [table below](#deploy) for details. | | ||
@@ -92,6 +98,6 @@ | ||
---------|------|----------|------------- | ||
| repo | `string` | optional/required | the full git repo name as defined in Sentry. Required if `auto` option is not `true`. | | ||
| commit | `string` | optional/required | the current (last) commit in the release. Required if `auto` option is not `true`. | | ||
| previousCommit | `string` | optional | the commit before the beginning of this release (in other words, the last commit of the previous release). If omitted, this will default to the last commit of the previous release in Sentry. If there was no previous release, the last 10 commits will be used | | ||
| auto | `boolean` | optional | automatically choose the associated commit (uses the current commit). Overrides other options | | ||
| repo | `string` | see notes | The full git repo name as defined in Sentry. Required if `auto` option is not `true`, otherwise optional. | | ||
| commit | `string` | see notes | The current (most recent) commit in the release. Required if `auto` option is not `true`, otherwise optional. | | ||
| previousCommit | `string` | optional | The last commit of the previous release. Defaults to the most recent commit of the previous release in Sentry, or if no previous release is found, 10 commits back from `commit`. | | ||
| auto | `boolean` | optional | Automatically set `commit` and `previousCommit`. Defaults `commit` to `HEAD` and `previousCommit` as described above. Overrides other options | | ||
@@ -102,10 +108,10 @@ #### <a name="deploy"></a>options.deploy: | ||
---------|------|----------|------------- | ||
| env | `string` | required | environment for this release. Values that make sense here would be `production` or `staging` | | ||
| started | `number` | optional | unix timestamp when the deployment started | | ||
| finished | `number` | optional | unix timestamp when the deployment finished | | ||
| time | `number` | optional | deployment duration in seconds. This can be specified alternatively to `started` and `finished` | | ||
| name | `string` | optional | human readable name for this deployment | | ||
| url | `string` | optional | URL that points to the deployment | | ||
| env | `string` | required | Environment value for the release, for example `production` or `staging`. | | ||
| started | `number` | optional | UNIX timestamp for deployment start. | | ||
| finished | `number` | optional | UNIX timestamp for deployment finish. | | ||
| time | `number` | optional | Deployment duration in seconds. Can be used instead of `started` and `finished`. | | ||
| name | `string` | optional | Human-readable name for this deployment. | | ||
| url | `string` | optional | URL that points to the deployment. | | ||
You can find more information about these options in our official docs: | ||
https://docs.sentry.io/cli/releases/#sentry-cli-sourcemaps | ||
https://docs.sentry.io/product/cli/releases/#sentry-cli-sourcemaps. |
@@ -304,3 +304,3 @@ /*eslint-disable*/ | ||
test('injects a `rule` for our mock module', done => { | ||
test('injects a `rule` for our mock module', () => { | ||
expect.assertions(1); | ||
@@ -311,17 +311,14 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.module.rules[0]).toEqual({ | ||
test: /sentry-webpack\.module\.js$/, | ||
use: [ | ||
{ | ||
loader: expect.stringMatching(SENTRY_LOADER_RE), | ||
options: { releasePromise: expect.any(Promise) }, | ||
}, | ||
], | ||
}); | ||
done(); | ||
expect(compiler.options.module.rules[0]).toEqual({ | ||
test: /sentry-webpack\.module\.js$/, | ||
use: [ | ||
{ | ||
loader: expect.stringMatching(SENTRY_LOADER_RE), | ||
options: { releasePromise: expect.any(Promise) }, | ||
}, | ||
], | ||
}); | ||
}); | ||
test('injects a `loader` for our mock module', done => { | ||
test('injects a `loader` for our mock module', () => { | ||
expect.assertions(1); | ||
@@ -332,23 +329,17 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.module.loaders[0]).toEqual({ | ||
test: /sentry-webpack\.module\.js$/, | ||
loader: expect.stringMatching(SENTRY_LOADER_RE), | ||
options: { releasePromise: expect.any(Promise) }, | ||
}); | ||
done(); | ||
expect(compiler.options.module.loaders[0]).toEqual({ | ||
test: /sentry-webpack\.module\.js$/, | ||
loader: expect.stringMatching(SENTRY_LOADER_RE), | ||
options: { releasePromise: expect.any(Promise) }, | ||
}); | ||
}); | ||
test('defaults to `rules` when nothing is specified', done => { | ||
test('defaults to `rules` when nothing is specified', () => { | ||
expect.assertions(1); | ||
sentryCliPlugin.apply(compiler); | ||
setImmediate(() => { | ||
expect(compiler.options.module.rules).toBeInstanceOf(Array); | ||
done(); | ||
}); | ||
expect(compiler.options.module.rules).toBeInstanceOf(Array); | ||
}); | ||
test('creates the `module` option if missing', done => { | ||
test('creates the `module` option if missing', () => { | ||
expect.assertions(1); | ||
@@ -359,6 +350,3 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.module).not.toBeUndefined(); | ||
done(); | ||
}); | ||
expect(compiler.options.module).not.toBeUndefined(); | ||
}); | ||
@@ -379,13 +367,10 @@ }); | ||
test('creates an entry if none is specified', done => { | ||
test('creates an entry if none is specified', () => { | ||
expect.assertions(1); | ||
sentryCliPlugin.apply(compiler); | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toMatch(SENTRY_MODULE_RE); | ||
done(); | ||
}); | ||
expect(compiler.options.entry).toMatch(SENTRY_MODULE_RE); | ||
}); | ||
test('injects into a single entry', done => { | ||
test('injects into a single entry', () => { | ||
expect.assertions(1); | ||
@@ -396,12 +381,9 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
]); | ||
done(); | ||
}); | ||
expect(compiler.options.entry).toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
]); | ||
}); | ||
test('injects into an array entry', done => { | ||
test('injects into an array entry', () => { | ||
expect.assertions(1); | ||
@@ -412,13 +394,10 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/preload.js', | ||
'./src/index.js', | ||
]); | ||
done(); | ||
}); | ||
expect(compiler.options.entry).toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/preload.js', | ||
'./src/index.js', | ||
]); | ||
}); | ||
test('injects into multiple entries', done => { | ||
test('injects into multiple entries', () => { | ||
expect.assertions(1); | ||
@@ -432,12 +411,9 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual({ | ||
main: [expect.stringMatching(SENTRY_MODULE_RE), './src/index.js'], | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}); | ||
done(); | ||
expect(compiler.options.entry).toEqual({ | ||
main: [expect.stringMatching(SENTRY_MODULE_RE), './src/index.js'], | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}); | ||
}); | ||
test('injects into multiple entries with array chunks', done => { | ||
test('injects into multiple entries with array chunks', () => { | ||
expect.assertions(1); | ||
@@ -451,20 +427,17 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual({ | ||
main: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
'./src/common.js', | ||
], | ||
admin: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/admin.js', | ||
'./src/common.js', | ||
], | ||
}); | ||
done(); | ||
expect(compiler.options.entry).toEqual({ | ||
main: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
'./src/common.js', | ||
], | ||
admin: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/admin.js', | ||
'./src/common.js', | ||
], | ||
}); | ||
}); | ||
test('injects into entries specified by a function', done => { | ||
test('injects into entries specified by a function', () => { | ||
expect.assertions(1); | ||
@@ -475,14 +448,84 @@ | ||
setImmediate(() => { | ||
compiler.options.entry().then(entry => { | ||
expect(entry).toEqual([ | ||
expect(compiler.options.entry()).resolves.toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
]); | ||
}); | ||
test('injects into entries specified by entry descriptor with single import', () => { | ||
expect.assertions(1); | ||
compiler.options.entry = { | ||
main: { | ||
import: './src/index.js', | ||
out: '[name].bundle.js', | ||
}, | ||
}; | ||
sentryCliPlugin.apply(compiler); | ||
expect(compiler.options.entry).toEqual({ | ||
main: { | ||
import: [expect.stringMatching(SENTRY_MODULE_RE), './src/index.js'], | ||
out: '[name].bundle.js', | ||
}, | ||
}); | ||
}); | ||
test('injects into entries specified by entry descriptor with multiple imports', () => { | ||
expect.assertions(1); | ||
compiler.options.entry = { | ||
main: { | ||
import: ['./src/index.js', './src/common.js'], | ||
out: '[name].bundle.js', | ||
}, | ||
}; | ||
sentryCliPlugin.apply(compiler); | ||
expect(compiler.options.entry).toEqual({ | ||
main: { | ||
import: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/index.js', | ||
]); | ||
done(); | ||
}); | ||
'./src/common.js', | ||
], | ||
out: '[name].bundle.js', | ||
}, | ||
}); | ||
}); | ||
test('filters entry points by name', done => { | ||
test('injects into entries specified by all possible methods at the same time', () => { | ||
expect.assertions(2); | ||
compiler.options.entry = { | ||
home: './home.js', | ||
about: ['./about.js'], | ||
contact: () => './contact.js', | ||
login: { | ||
import: './login.js', | ||
}, | ||
logout: { | ||
import: ['./logout.js'], | ||
}, | ||
}; | ||
sentryCliPlugin.apply(compiler); | ||
expect(compiler.options.entry).toEqual({ | ||
home: [expect.stringMatching(SENTRY_MODULE_RE), './home.js'], | ||
about: [expect.stringMatching(SENTRY_MODULE_RE), './about.js'], | ||
contact: expect.any(Function), | ||
login: { | ||
import: [expect.stringMatching(SENTRY_MODULE_RE), './login.js'], | ||
}, | ||
logout: { | ||
import: [expect.stringMatching(SENTRY_MODULE_RE), './logout.js'], | ||
}, | ||
}); | ||
expect(compiler.options.entry.contact()).resolves.toEqual([ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./contact.js', | ||
]); | ||
}); | ||
test('filters entry points by name', () => { | ||
expect.assertions(1); | ||
@@ -493,2 +536,5 @@ | ||
admin: './src/admin.js', | ||
login: { | ||
import: './src/login.js', | ||
}, | ||
}; | ||
@@ -498,12 +544,12 @@ sentryCliPlugin.options.entries = ['admin']; | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual({ | ||
main: './src/index.js', | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}); | ||
done(); | ||
expect(compiler.options.entry).toEqual({ | ||
main: './src/index.js', | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
login: { | ||
import: './src/login.js', | ||
}, | ||
}); | ||
}); | ||
test('filters entry points by RegExp', done => { | ||
test('filters entry points by RegExp', () => { | ||
expect.assertions(1); | ||
@@ -514,2 +560,5 @@ | ||
admin: ['./src/admin.js', './src/common.js'], | ||
adminButBetter: { | ||
import: './src/admin.js', | ||
}, | ||
}; | ||
@@ -519,16 +568,16 @@ sentryCliPlugin.options.entries = /^ad/; | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual({ | ||
main: './src/index.js', | ||
admin: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/admin.js', | ||
'./src/common.js', | ||
], | ||
}); | ||
done(); | ||
expect(compiler.options.entry).toEqual({ | ||
main: './src/index.js', | ||
admin: [ | ||
expect.stringMatching(SENTRY_MODULE_RE), | ||
'./src/admin.js', | ||
'./src/common.js', | ||
], | ||
adminButBetter: { | ||
import: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}, | ||
}); | ||
}); | ||
test('filters entry points by function', done => { | ||
test('filters entry points by function', () => { | ||
expect.assertions(1); | ||
@@ -543,8 +592,5 @@ | ||
setImmediate(() => { | ||
expect(compiler.options.entry).toEqual({ | ||
main: ['./src/index.js', './src/common.js'], | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}); | ||
done(); | ||
expect(compiler.options.entry).toEqual({ | ||
main: ['./src/index.js', './src/common.js'], | ||
admin: [expect.stringMatching(SENTRY_MODULE_RE), './src/admin.js'], | ||
}); | ||
@@ -551,0 +597,0 @@ }); |
@@ -190,3 +190,3 @@ const SentryCli = require('@sentry/cli'); | ||
/** Checks if the given named entry point should be handled. */ | ||
checkEntry(key) { | ||
shouldInjectEntry(key) { | ||
const { entries } = this.options; | ||
@@ -215,28 +215,82 @@ if (entries == null) { | ||
/** Injects the release string into the given entry point. */ | ||
injectEntry(originalEntry, newEntry) { | ||
if (Array.isArray(originalEntry)) { | ||
return [newEntry].concat(originalEntry); | ||
injectEntry(entry, sentryModule) { | ||
if (!entry) { | ||
return sentryModule; | ||
} | ||
if (originalEntry !== null && typeof originalEntry === 'object') { | ||
return Object.keys(originalEntry).reduce((acc, key) => { | ||
acc[key] = this.checkEntry(key) | ||
? this.injectEntry(originalEntry[key], newEntry) | ||
: originalEntry[key]; | ||
return acc; | ||
}, {}); | ||
/** | ||
* in: | ||
* entry: 'index.js' | ||
* out: | ||
* entry: ['sentry-webpack.module.js', 'index.js'] | ||
*/ | ||
if (typeof entry === 'string') { | ||
return [sentryModule, entry]; | ||
} | ||
if (typeof originalEntry === 'string') { | ||
return [newEntry, originalEntry]; | ||
/** | ||
* in: | ||
* entry: ['index.js', 'header.js', 'footer.js'] | ||
* out: | ||
* entry: ['sentry-webpack.module.js', 'index.js', 'header.js', 'footer.js'] | ||
*/ | ||
if (Array.isArray(entry)) { | ||
return [sentryModule].concat(entry); | ||
} | ||
if (typeof originalEntry === 'function') { | ||
/** | ||
* in: | ||
* entry: () => 'index.js' | ||
* entry: () => ['index.js'] | ||
* out: | ||
* entry: ['sentry-webpack.module.js', 'index.js'] | ||
* entry: ['sentry-webpack.module.js', 'index.js'] | ||
*/ | ||
if (typeof entry === 'function') { | ||
return () => | ||
Promise.resolve(originalEntry()).then(entry => | ||
this.injectEntry(entry, newEntry) | ||
Promise.resolve(entry()).then(resolvedEntry => | ||
this.injectEntry(resolvedEntry, sentryModule) | ||
); | ||
} | ||
return newEntry; | ||
/** | ||
* in: | ||
* entry: { | ||
* home: './home.js', | ||
* about: ['./about.js'], | ||
* contact: () => './contact.js', | ||
* login: { | ||
* import: './login.js', | ||
* }, | ||
* logout: { | ||
* import: ['./logout.js'] | ||
* } | ||
* } | ||
* out: | ||
* entry: { | ||
* home: ['sentry-webpack.module.js', './home.js'], | ||
* about: ['sentry-webpack.module.js', './about.js'], | ||
* contact: ['sentry-webpack.module.js', './contact.js'], | ||
* login: { | ||
* import: ['sentry-webpack.module.js', './login.js'] | ||
* }, | ||
* logout: { | ||
* import: ['sentry-webpack.module.js', './logout.js'] | ||
* } | ||
* } | ||
*/ | ||
const modifiedEntry = { ...entry }; | ||
Object.keys(modifiedEntry) | ||
.filter(key => this.shouldInjectEntry(key)) | ||
.forEach(key => { | ||
if (entry[key] && entry[key].import) { | ||
modifiedEntry[key].import = this.injectEntry( | ||
entry[key].import, | ||
sentryModule | ||
); | ||
} else { | ||
modifiedEntry[key] = this.injectEntry(entry[key], sentryModule); | ||
} | ||
}); | ||
return modifiedEntry; | ||
} | ||
@@ -243,0 +297,0 @@ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance 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
62720
10
1088
115
1