Skip to content

Commit

Permalink
fix(vite-plugin): Ensure post order of `sentry-vite-release-injecti…
Browse files Browse the repository at this point in the history
…on-plugin` to avoid breaking `@rollup/plugin-commonjs` step (#578)
  • Loading branch information
andreiborza authored Aug 5, 2024
1 parent a11470f commit 6867395
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
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

0 comments on commit 6867395

Please sign in to comment.