Skip to content

Commit 6867395

Browse files
authored
fix(vite-plugin): Ensure post order of sentry-vite-release-injection-plugin to avoid breaking @rollup/plugin-commonjs step (#578)
1 parent a11470f commit 6867395

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
yarn-error.log
33

44
.vscode/settings.json
5+
.idea
56

67
*.tgz
78

packages/bundler-plugin-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface SentryUnpluginFactoryOptions {
4343
*
4444
* Release injection:
4545
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
46-
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
46+
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector";`)
4747
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
4848
* by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
4949
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.

packages/playground/vite.config.smallNodeApp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
import { sentryVitePlugin } from "@sentry/bundler-plugin-core";
2+
import { sentryVitePlugin } from "@sentry/vite-plugin";
33
import { defineConfig } from "vite";
44
import * as path from "path";
55

packages/vite-plugin/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import { UnpluginOptions } from "unplugin";
1414
function viteReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
1515
return {
1616
name: "sentry-vite-release-injection-plugin",
17-
enforce: "pre" as const, // need this so that vite runs the resolveId hook
17+
// run `post` to avoid tripping up @rollup/plugin-commonjs when cjs is used
18+
// as we inject an `import` statement
19+
enforce: "post" as const, // need this so that vite runs the resolveId hook
1820
vite: createRollupReleaseInjectionHooks(injectionCode),
1921
};
2022
}

0 commit comments

Comments
 (0)