Socket
Socket
Sign inDemoInstall

@sentry/bundler-plugin-core

Package Overview
Dependencies
Maintainers
12
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/bundler-plugin-core - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

dist/types/plugins/debug-id-upload.d.ts

70

dist/types/index.d.ts

@@ -0,7 +1,67 @@

import { UnpluginOptions } from "unplugin";
import { Options } from "./types";
import "@sentry/tracing";
export declare const sentryVitePlugin: (options: Options) => any;
export declare const sentryRollupPlugin: (options: Options) => any;
export declare const sentryWebpackPlugin: (options: Options) => any;
export declare const sentryEsbuildPlugin: (options: Options) => any;
interface SentryUnpluginFactoryOptions {
releaseInjectionPlugin: (injectionCode: string) => UnpluginOptions;
debugIdInjectionPlugin: () => UnpluginOptions;
}
/**
* The sentry bundler plugin concerns itself with two things:
* - Release injection
* - Sourcemaps upload
*
* Release injection:
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
* by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
*
* Source maps upload:
*
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
* is all done in the `writeBundle` hook. In this hook the sentry plugin will execute the
* release creation pipeline:
*
* 1. Create a new release
* 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
* 3. Upload sourcemaps based on `include` and source-map-specific options
* 4. Associate a range of commits with the release (if `setCommits` is specified)
* 5. Finalize the release (unless `finalize` is disabled)
* 6. Add deploy information to the release (if `deploy` is specified)
*
* This release creation pipeline relies on Sentry CLI to execute the different steps.
*/
export declare function sentryUnpluginFactory({ releaseInjectionPlugin, debugIdInjectionPlugin, }: SentryUnpluginFactoryOptions): import("unplugin").UnpluginInstance<Options, true>;
export declare function getBuildInformation(): {
deps: string[];
depsVersions: Record<string, number>;
nodeVersion: number | undefined;
};
/**
* Determines whether the Sentry CLI binary is in its expected location.
* This function is useful since `@sentry/cli` installs the binary via a post-install
* script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
*/
export declare function sentryCliBinaryExists(): boolean;
export declare function createRollupReleaseInjectionHooks(injectionCode: string): {
resolveId(id: string): {
id: string;
external: boolean;
moduleSideEffects: boolean;
} | null;
load(id: string): string | null;
transform(code: string, id: string): {
code: string;
map: import("magic-string").SourceMap;
} | null;
};
export declare function createRollupDebugIdInjectionHooks(): {
renderChunk(code: string, chunk: {
fileName: string;
}): {
code: string;
map: import("magic-string").SourceMap;
} | null;
};
export declare function getDebugIdSnippet(debugId: string): string;
export type { Options } from "./types";

71

dist/types/options-mapping.d.ts
import { Logger } from "./sentry/logger";
import { IncludeEntry as UserIncludeEntry, Options as UserOptions } from "./types";
declare type RequiredInternalOptions = Required<Pick<UserOptions, "finalize" | "dryRun" | "debug" | "silent" | "cleanArtifacts" | "telemetry" | "injectReleasesMap">>;
declare type OptionalInternalOptions = Partial<Pick<UserOptions, "org" | "project" | "authToken" | "url" | "vcsRemote" | "dist" | "errorHandler" | "setCommits" | "deploy" | "configFile" | "headers">>;
declare type NormalizedInternalOptions = {
releaseInjectionTargets: (string | RegExp)[] | ((filePath: string) => boolean) | undefined;
include: InternalIncludeEntry[];
import { Options as UserOptions } from "./types";
export declare type NormalizedOptions = ReturnType<typeof normalizeUserOptions>;
export declare const SENTRY_SAAS_URL = "https://sentry.io";
export declare function normalizeUserOptions(userOptions: UserOptions): {
org: string | undefined;
project: string | undefined;
authToken: string | undefined;
url: string;
headers: Record<string, string> | undefined;
debug: boolean;
silent: boolean;
errorHandler: ((err: Error) => void) | undefined;
telemetry: boolean;
disable: boolean;
sourcemaps: {
assets: string | string[];
ignore?: string | string[] | undefined;
rewriteSources?: ((source: string, map: any) => string) | undefined;
deleteAfterUpload?: string | string[] | undefined;
} | undefined;
release: {
name: string | undefined;
inject: boolean;
create: boolean;
finalize: boolean;
dist?: string | undefined;
vcsRemote: string;
setCommits?: (({
auto: true;
repo?: undefined;
commit?: undefined;
} | {
auto?: false | undefined;
repo: string;
commit: string;
}) & {
previousCommit?: string | undefined;
ignoreMissing?: boolean | undefined;
ignoreEmpty?: boolean | undefined;
}) | undefined;
deploy?: {
env: string;
started?: string | number | undefined;
finished?: string | number | undefined;
time?: number | undefined;
name?: string | undefined;
url?: string | undefined;
} | undefined;
cleanArtifacts: boolean;
uploadLegacySourcemaps?: string | import("./types").IncludeEntry | (string | import("./types").IncludeEntry)[] | undefined;
};
_experiments: {
injectBuildInformation?: boolean | undefined;
};
};
export declare type InternalOptions = RequiredInternalOptions & OptionalInternalOptions & NormalizedInternalOptions;
declare type RequiredInternalIncludeEntry = Required<Pick<UserIncludeEntry, "paths" | "ext" | "stripCommonPrefix" | "sourceMapReference" | "rewrite" | "validate">>;
declare type OptionalInternalIncludeEntry = Partial<Pick<UserIncludeEntry, "ignoreFile" | "urlPrefix" | "urlSuffix" | "stripPrefix">>;
export declare type InternalIncludeEntry = RequiredInternalIncludeEntry & OptionalInternalIncludeEntry & {
ignore: string[];
};
export declare const SENTRY_SAAS_URL = "https://sentry.io";
export declare function normalizeUserOptions(userOptions: UserOptions): InternalOptions;
/**

@@ -29,3 +69,2 @@ * Validates a few combinations of options that are not checked by Sentry CLI.

*/
export declare function validateOptions(options: InternalOptions, logger: Logger): boolean;
export {};
export declare function validateOptions(options: NormalizedOptions, logger: Logger): boolean;

@@ -1,13 +0,8 @@

import { Hub, NodeClient, Span } from "@sentry/node";
import { InternalOptions } from "../options-mapping";
import { BuildContext } from "../types";
export declare function makeSentryClient(dsn: string, allowedToSendTelemetryPromise: Promise<boolean>, userProject: string | undefined): {
import { Hub, NodeClient } from "@sentry/node";
import { NormalizedOptions } from "../options-mapping";
export declare function createSentryInstance(options: NormalizedOptions, shouldSendTelemetry: Promise<boolean>, bundler: string): {
sentryHub: Hub;
sentryClient: NodeClient;
};
/**
* Adds a span to the passed parentSpan or to the current transaction that's on the passed hub's scope.
*/
export declare function addSpanToTransaction(ctx: BuildContext, op?: string, description?: string): Span | undefined;
export declare function addPluginOptionInformationToHub(options: InternalOptions, hub: Hub, bundler: "rollup" | "webpack" | "vite" | "esbuild"): void;
export declare function shouldSendTelemetry(options: InternalOptions): Promise<boolean>;
export declare function setTelemetryDataOnHub(options: NormalizedOptions, hub: Hub, bundler: string): void;
export declare function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean>;

@@ -1,13 +0,4 @@

import { Hub } from "@sentry/core";
import { Span } from "@sentry/tracing";
import { SentryCLILike } from "./sentry/cli";
import { createLogger } from "./sentry/logger";
/**
* The main options object holding all plugin options available to users
*/
export declare type Options = Omit<IncludeEntry, "paths"> & {
export interface Options {
/**
* The slug of the Sentry organization associated with the app.
*
* This value can also be specified via the `SENTRY_ORG` environment variable.
*/

@@ -39,55 +30,2 @@ org?: string;

/**
* 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).
*/
release?: string;
/**
* Unique identifier for the distribution, used to further segment your release.
* Usually your build number.
*/
dist?: string;
/**
* Filter for modules that the release should be injected in.
*
* 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 module. It should return `true`
* if the release should be injected into the module and `false` otherwise. String
* values of this option require a full match with the absolute path of the module.
*
* By default, the release will be injected into all entrypoints. If release
* injection should be disabled, provide an empty array here.
*/
releaseInjectionTargets?: (string | RegExp)[] | RegExp | string | ((filePath: string) => boolean);
/**
* Determines if the Sentry release record should be automatically finalized
* (meaning a date_released timestamp is added) after artifact upload.
*
* Defaults to `true`.
*/
finalize?: boolean;
/**
* One or more paths that Sentry CLI 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
*
* This is a required field.
*/
include: string | IncludeEntry | Array<string | IncludeEntry>;
/**
* Version control system remote name.
*
* This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable.
*
* Defaults to 'origin'.
*/
vcsRemote?: string;
/**
* Headers added to every outgoing network request.

@@ -97,10 +35,2 @@ */

/**
* Attempts a dry run (useful for dev environments), making release creation
* a no-op.
*
* Defaults to `false`, but may be automatically set to `true` in development environments
* by some framework integrations (Next.JS, possibly others).
*/
dryRun?: boolean;
/**
* Print useful debug information.

@@ -118,8 +48,2 @@ *

/**
* Remove all the artifacts in the release before the upload.
*
* Defaults to `false`.
*/
cleanArtifacts?: boolean;
/**
* When an error occurs during rlease creation or sourcemaps upload, the plugin will call this function.

@@ -141,10 +65,2 @@ *

/**
* Associates the release with its commits in Sentry.
*/
setCommits?: SetCommitsOptions;
/**
* Adds deployment information to the release in Sentry.
*/
deploy?: DeployOptions;
/**
* If set to true, internal plugin errors and performance data will be sent to Sentry.

@@ -161,18 +77,141 @@ *

/**
* Path to Sentry CLI config properties, as described in
* https://docs.sentry.io/product/cli/configuration/#configuration-file.
* Completely disables all functionality of the plugin.
*
* By default, the config file is looked for upwards from the current path, and
* defaults from ~/.sentryclirc are always loaded
* Defaults to `false`.
*/
configFile?: string;
disable?: boolean;
/**
* 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.
* Options for source maps uploading.
* Leave this option undefined if you do not want to upload source maps to Sentry.
*/
sourcemaps?: {
/**
* A glob or an array of globs that specifies the build artifacts that should be uploaded to Sentry.
*
* The globbing patterns follow the implementation of the `glob` package. (https://www.npmjs.com/package/glob)
*
* Use the `debug` option to print information about which files end up being uploaded.
*/
assets: string | string[];
/**
* A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
*
* Default: `[]`
*
* The globbing patterns follow the implementation of the `glob` package. (https://www.npmjs.com/package/glob)
*
* Use the `debug` option to print information about which files end up being uploaded.
*/
ignore?: string | string[];
/**
* Hook to rewrite the `sources` field inside the source map before being uploaded to Sentry. Does not modify the actual source map.
*
* Defaults to making all sources relative to `process.cwd()` while building.
*
* @hidden Not yet implemented.
*/
rewriteSources?: (source: string, map: any) => string;
/**
* A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact upload to Sentry has been completed.
*
* The globbing patterns follow the implementation of the `glob` package. (https://www.npmjs.com/package/glob)
*
* Use the `debug` option to print information about which files end up being deleted.
*
* @hidden Not yet implemented.
*/
deleteAfterUpload?: string | string[];
};
/**
* Options related to managing the Sentry releases for a build.
*
* Defaults to `false`.
* More info: https://docs.sentry.io/product/releases/
*/
injectReleasesMap?: boolean;
};
release?: {
/**
* Unique identifier for the release you want to create.
*
* This value can also be specified via the `SENTRY_RELEASE` environment variable.
*
* Defaults to automatically detecting a value for your environment.
* This includes values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA.
* (the latterrequires access to git CLI and for the root directory to be a valid repository)
*
* If you didn't provide a value and the plugin can't automatically detect one, no release will be created.
*/
name?: string;
/**
* Whether the plugin should inject release information into the build for the SDK to pick it up when sending events. (recommended)
*
* Defaults to `true`.
*/
inject?: boolean;
/**
* Whether the plugin should create a release on Sentry during the build.
* Note that a release may still appear in Sentry even if this is value is `false` because any Sentry event that has a release value attached will automatically create a release.
* (for example via the `inject` option)
*
* Defaults to `true`.
*/
create?: boolean;
/**
* Whether the Sentry release should be automatically finalized (meaning an end timestamp is added) after the build ends.
*
* Defaults to `true`.
*/
finalize?: boolean;
/**
* Unique identifier for the distribution, used to further segment your release.
* Usually your build number.
*/
dist?: string;
/**
* Version control system remote name.
*
* This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable.
*
* Defaults to 'origin'.
*/
vcsRemote?: string;
/**
* Associates the release with its commits in Sentry.
*/
setCommits?: SetCommitsOptions;
/**
* Adds deployment information to the release in Sentry.
*/
deploy?: DeployOptions;
/**
* Remove all previously uploaded artifacts for this release on Sentry before the upload.
*
* Defaults to `false`.
*/
cleanArtifacts?: boolean;
/**
* Legacy method of uploading source maps. (not recommended unless necessary)
*
* One or more paths that should be scanned recursively for sources.
*
* Each path can be given as a string or an object with more specific options.
*
* The modern version of doing source maps upload is more robust and way easier to get working but has to inject a very small snippet of JavaScript into your output bundles.
* In situations where this leads to problems (e.g subresource integrity) you can use this option as a fallback.
*/
uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;
};
/**
* Options that are considered experimental and subject to change.
*
* @experimental API that does not follow semantic versioning and may change in any release
*/
_experiments?: {
/**
* If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable.
* This contains information about the build, e.g. dependencies, node version and other useful data.
*
* Defaults to `false`.
*/
injectBuildInformation?: boolean;
};
}
export declare type IncludeEntry = {

@@ -330,12 +369,2 @@ /**

};
/**
* Holds data for internal purposes
* (e.g. telemetry and logging)
*/
export declare type BuildContext = {
hub: Hub;
parentSpan?: Span;
logger: ReturnType<typeof createLogger>;
cli: SentryCLILike;
};
export {};

@@ -8,1 +8,34 @@ /**

export declare function arrayify<T = unknown>(maybeArray: T | T[]): T[];
declare type PackageJson = Record<string, unknown>;
/**
* Get the closes package.json from a given starting point upwards.
* This handles a few edge cases:
* * Check if a given file package.json appears to be an actual NPM package.json file
* * Stop at the home dir, to avoid looking too deeply
*/
export declare function getPackageJson({ cwd, stopAt }?: {
cwd?: string;
stopAt?: string;
}): PackageJson | undefined;
export declare function parseMajorVersion(version: string): number | undefined;
export declare function getDependencies(packageJson: PackageJson): {
deps: string[];
depsVersions: Record<string, number>;
};
/**
* Deterministically hashes a string and turns the hash into a uuid.
*/
export declare function stringToUUID(str: string): string;
/**
* Tries to guess a release name based on environmental data.
*/
export declare function determineReleaseName(): string | undefined;
/**
* Generates code for the global injector which is responsible for setting the global
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
*/
export declare function generateGlobalInjectorCode({ release, injectBuildInformation, }: {
release: string;
injectBuildInformation: boolean;
}): string;
export {};
{
"name": "@sentry/bundler-plugin-core",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "Sentry Bundler Plugin Core",

@@ -13,3 +13,5 @@ "repository": "git://github.com/getsentry/sentry-javascript-bundler-plugins.git",

"files": [
"dist"
"dist",
"sentry-release-injection-file.js",
"sentry-esbuild-debugid-injection-file.js"
],

@@ -19,3 +21,12 @@ "exports": {

"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js"
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
},
"./sentry-release-injection-file": {
"import": "./sentry-release-injection-file.js",
"require": "./sentry-release-injection-file.js"
},
"./sentry-esbuild-debugid-injection-file": {
"import": "./sentry-esbuild-debugid-injection-file.js",
"require": "./sentry-esbuild-debugid-injection-file.js"
}

@@ -46,5 +57,6 @@ },

"dependencies": {
"@sentry/cli": "^2.10.0",
"@sentry/node": "^7.19.0",
"@sentry/tracing": "^7.19.0",
"@sentry/cli": "^2.17.0",
"@sentry/node": "7.50.0",
"find-up": "5.0.0",
"glob": "9.3.2",
"magic-string": "0.27.0",

@@ -58,8 +70,7 @@ "unplugin": "1.0.1"

"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-commonjs": "22.0.1",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@sentry-internal/eslint-config": "2.0.0-alpha.1",
"@sentry-internal/sentry-bundler-plugin-tsconfig": "2.0.0-alpha.1",
"@sentry-internal/eslint-config": "2.0.0-alpha.2",
"@sentry-internal/sentry-bundler-plugin-tsconfig": "2.0.0-alpha.2",
"@swc/core": "^1.2.205",

@@ -80,3 +91,7 @@ "@swc/jest": "^0.2.21",

"node": ">= 10"
}
},
"sideEffects": [
"./sentry-release-injection-file.js",
"./sentry-esbuild-debugid-injection-file.js"
]
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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