Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(vite-plugin): Ensure post order of sentry-vite-release-injection-plugin to avoid breaking @rollup/plugin-commonjs step #578

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
yarn-error.log

.vscode/settings.json
.idea

*.tgz

Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface SentryUnpluginFactoryOptions {
*
* 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;"`)
* 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.
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/vite.config.smallNodeApp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { sentryVitePlugin } from "@sentry/bundler-plugin-core";
import { sentryVitePlugin } from "@sentry/vite-plugin";
import { defineConfig } from "vite";
import * as path from "path";

Expand Down
4 changes: 3 additions & 1 deletion packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { UnpluginOptions } from "unplugin";
function viteReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
return {
name: "sentry-vite-release-injection-plugin",
enforce: "pre" as const, // need this so that vite runs the resolveId hook
// run `post` to avoid tripping up @rollup/plugin-commonjs when cjs is used
// as we inject an `import` statement
enforce: "post" as const, // need this so that vite runs the resolveId hook
vite: createRollupReleaseInjectionHooks(injectionCode),
};
}
Expand Down
Loading