@sentry/vite-plugin
Advanced tools
Comparing version 0.0.1-alpha.0 to 0.1.0
{ | ||
"name": "@sentry/vite-plugin", | ||
"version": "0.0.1-alpha.0", | ||
"version": "0.1.0", | ||
"description": "Official Sentry Vite plugin", | ||
@@ -35,2 +35,6 @@ "repository": "git://github.com/getsentry/sentry-javascript-bundler-plugins.git", | ||
"check:types:test": "tsc --project ./test/tsconfig.json --noEmit", | ||
"clean": "run-s clean:build", | ||
"clean:all": "run-p clean clean:deps", | ||
"clean:build": "rimraf ./dist *.tgz", | ||
"clean:deps": "rimraf node_modules", | ||
"test": "jest", | ||
@@ -40,3 +44,3 @@ "lint": "eslint ./src ./test" | ||
"dependencies": { | ||
"@sentry/bundler-plugin-core": "0.0.1-alpha.0" | ||
"@sentry/bundler-plugin-core": "0.1.0" | ||
}, | ||
@@ -51,4 +55,4 @@ "devDependencies": { | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@sentry-internal/eslint-config": "0.0.1-alpha.0", | ||
"@sentry-internal/sentry-bundler-plugin-tsconfig": "0.0.1-alpha.0", | ||
"@sentry-internal/eslint-config": "0.1.0", | ||
"@sentry-internal/sentry-bundler-plugin-tsconfig": "0.1.0", | ||
"@swc/core": "^1.2.205", | ||
@@ -60,7 +64,12 @@ "@swc/jest": "^0.2.21", | ||
"jest": "^28.1.1", | ||
"npm-run-all": "^4.1.5", | ||
"rimraf": "^3.0.2", | ||
"rollup": "2.75.7", | ||
"typescript": "^4.7.4" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"engines": { | ||
"node": ">= 10" | ||
} | ||
} |
150
README.md
@@ -18,23 +18,141 @@ <p align="center"> | ||
## Installation | ||
Using npm: | ||
```bash | ||
$ npm install @sentry/vite-plugin --save-dev | ||
``` | ||
Using yarn: | ||
```bash | ||
$ yarn add @sentry/vite-plugin --dev | ||
``` | ||
## Usage | ||
```ts | ||
// vite.config.ts | ||
import sentryVitePlugin from "@sentry/vite-plugin"; | ||
export default { | ||
plugins: [ | ||
sentryVitePlugin({ | ||
include: ".", | ||
ignore: ["node_modules", "vite.config.ts"], | ||
org: process.env.SENTRY_ORG, | ||
project: process.env.SENTRY_PROJECT, | ||
authToken: process.env.SENTRY_AUTH_TOKEN, | ||
}), | ||
], | ||
}; | ||
``` | ||
As an alternative to passing options explicitly, you can also use a `.sentryclirc` file or environment variables as described in https://docs.sentry.io/product/cli/configuration/. | ||
### Configuration | ||
Every plugin takes an options argument with the following properties: | ||
The Sentry Vite Plugin takes an options argument with the following properties: | ||
| Option | Type | Required | Description | | ||
| -------------- | ----------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| include | `string` | required | A path that the plugin should scan recursively for source maps. 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/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). | | ||
| url | `string` | optional | The base URL of your Sentry instance. Defaults to https://sentry.io/, which is the correct value for SAAS customers. | | ||
| release | `string` | optional | Unique identifier for the release. Defaults to automatically detected values for CI environments like Vercel, AWS, Heroku, CircleCI. If no such CI environment is detected, the plugin uses the git `HEAD`'s commit SHA. (**For `HEAD` option, requires access to the `git` CLI**). | | ||
| entries | `(string \| RegExp)[] \| RegExp \| string \| function(absoluteFilePath: string): boolean` | optional | Filter for entry points that should be processed. By default, the release will be injected into all entry points. | | ||
| ext | `array` | optional | The file extensions to be considered for the sourcemaps upload. By default the following file extensions are processed: `js`, `map`, `jsbundle`, and `bundle`. | | ||
| finalize | `boolean` | optional | Indicates whether Sentry release record should be automatically finalized (`date_released` timestamp added) after artifact upload. Defaults to `true` | | ||
| debug | `boolean` | optional | Print useful debug information. Defaults to `false`. | | ||
| cleanArtifacts | `boolean` | optional | Remove all existing artifacts in the Sentry release before uploading sourcemaps. Defaults to `false`. | | ||
| errorHandler | `function(err: Error): void` | optional | Function that is called when an error occurs during rlease creation or sourcemaps upload. When this function is provided, thrown errors will not cause the process to abort. If you still want to abort the process you can throw an error in the function. | | ||
| Option | Type | Required | Description | | ||
| ------------------ | -------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. | | ||
| org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | | ||
| project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | | ||
| 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/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | | ||
| url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | | ||
| customHeader | `string` | optional | A header added to every outgoing network request. The format should be `header-key: header-value`. This value can also be specified via the `CUSTOM_HEADER` environment variable. | | ||
| vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | | ||
| release | `string` | optional | Unique identifier for the release. This value can also be specified via the `SENTRY_RELEASE` environment variable. 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 the git `HEAD`'s commit SHA. (**the latter 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`/`(string \| RegExp)[]`/`function(filePath: string): bool` | optional | Filter for bundle entry points that should contain the provided release. This option takes a string, a regular expression, or an array containing strings, regular expressions, or both. It's also possible to provide a filter function that takes the absolute path of a processed entrypoint and should return `true` if the release should be injected into the entrypoint and `false` otherwise. String values of this option require a full match with the absolute path of the bundle. 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. Defaults to `['node_modules']` if neither `ignoreFile` nor `ignore` is set. | | ||
| 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 | Array of file extensions of files to be collected for the file upload. 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 filenames. 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` as this can cause false positives. | | ||
| stripPrefix | `array` | optional | When paired with the `rewrite` option, this will remove a prefix from filename references inside of sourcemaps. For instance you can use this to remove a path that is build machine specific. Note that this will NOT change the names of uploaded files. | | ||
| stripCommonPrefix | `boolean` | optional | When paired with the `rewrite` option, this will add `~` to the `stripPrefix` array. | | ||
| sourceMapReference | `boolean` | optional | Determines whether sentry-cli should attempt to link minified files with their corresponding maps. By default, it will match files and maps based on name, and add a Sourcemap header to each minified file for which it finds a map. Can be disabled if all minified files contain a `sourceMappingURL`. Defaults to `true`. | | ||
| 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 if the Sentry release record should be automatically finalized (meaning a date_released timestamp is added) after artifact upload. Defaults to `true`. | | ||
| dryRun | `boolean` | optional | Attempts a dry run (useful for dev environments), making release creation a no-op. Defaults to `false`. | | ||
| debug | `boolean` | optional | Print useful debug information. Defaults to `false`. | | ||
| silent | `boolean` | optional | Suppresses all logs. Defaults to `false`. | | ||
| cleanArtifacts | `boolean` | optional | Remove all the artifacts in the release before the upload. Defaults to `false`. | | ||
| errorHandler | `function(err: Error): void` | optional | When an error occurs during rlease creation or sourcemaps upload, the plugin will call this function. By default, the plugin will simply throw an error, thereby stopping the bundling process. If an `errorHandler` callback is provided, compilation will continue, unless an error is thrown in the provided callback. | | ||
| setCommits | `Object` | optional | Associates the release with its commits in Sentry. See [table below](#setCommits) for details. | | ||
| deploy | `Object` | optional | Adds deployment information to the release in Sentry. See [table below](#deploy) for details. | | ||
| injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | | ||
| telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | | ||
### More information | ||
#### <a name="include"></a>options.include: | ||
| Option | Type | Required | Description | | ||
| ------------------ | ------------------- | -------- | ---------------------------------------------- | | ||
| paths | `string[]` | required | One or more paths to scan for files to upload. | | ||
| ignoreFile | `string` | optional | See above. | | ||
| ignore | `string`/`string[]` | optional | See above. | | ||
| ext | `array` | optional | See above. | | ||
| urlPrefix | `string` | optional | See above. | | ||
| urlSuffix | `string` | optional | See above. | | ||
| stripPrefix | `array` | optional | See above. | | ||
| stripCommonPrefix | `boolean` | optional | See above. | | ||
| sourceMapReference | `boolean` | optional | See above. | | ||
| rewrite | `boolean` | optional | See above. | | ||
Example: | ||
```ts | ||
// vite.config.ts | ||
import sentryVitePlugin from "@sentry/vite-plugin"; | ||
export default { | ||
plugins: [ | ||
sentryVitePlugin({ | ||
// ... | ||
include: [ | ||
{ | ||
paths: ["./packages"], | ||
urlPrefix: "~/path/to/packages", | ||
}, | ||
{ | ||
paths: ["./client"], | ||
urlPrefix: "~/path/to/client", | ||
}, | ||
], | ||
}), | ||
], | ||
}; | ||
``` | ||
#### <a name="setCommits"></a>options.setCommits: | ||
| Option | Type | Required | Description | | ||
| -------------- | --------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| repo | `string` | see notes | The full git repo name as defined in Sentry. Required if the `auto` option is not `true`, otherwise optional. | | ||
| commit | `string` | see notes | The current (most recent) commit in the release. Required if the `auto` option is not `true`, otherwise optional. | | ||
| previousCommit | `string` | optional | The commit before the beginning of this release (in other words, the last commit of the previous release). Defaults 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 sets `commit` and `previousCommit`. Sets `commit` to `HEAD` and `previousCommit` as described in the option's documentation. If you set this to `true`, manually specified `commit` and `previousCommit` options will be overridden. It is best to not specify them at all if you set this option to `true`. | | ||
| ignoreMissing | `boolean` | optional | If the flag is to `true` and the previous release commit was not found in the repository, the plugin creates a release with the default commits count instead of failing the command. Defaults to `false`. | | ||
#### <a name="deploy"></a>options.deploy: | ||
| Option | Type | Required | Description | | ||
| -------- | -------- | -------- | -------------------------------------------------------------------------------- | | ||
| env | `string` | required | Environment value for the release, for example `production` or `staging`. | | ||
| started | `number` | optional | Deployment start time in Unix timestamp (in seconds) or ISO 8601 format. | | ||
| finished | `number` | optional | Deployment finish time in Unix timestamp (in seconds) or ISO 8601 format. | | ||
| 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/product/cli/releases/#sentry-cli-sourcemaps. | ||
## More information | ||
- [Sentry Documentation](https://docs.sentry.io/quickstart/) | ||
@@ -41,0 +159,0 @@ - [Troubleshooting Sourcemaps](https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js/) |
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
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
33402
18
162
+ Added@sentry/bundler-plugin-core@0.1.0(transitive)
+ Added@sentry/cli@1.77.3(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedunplugin@0.10.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removed@sentry/bundler-plugin-core@0.0.1-alpha.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaxios@0.27.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedunplugin@0.9.4(transitive)