Skip to content

Should inject banner code after use strict #507

Description

@anothertempore

Environment

webpack@5.87.0, @sentry/webpack-plugin@2.10.2

Steps to Reproduce

This injection logic should be placed below use strict:

new BannerPlugin({
raw: true,
include: /\.(js|ts|jsx|tsx|mjs|cjs)$/,
banner: injectionCode,

In our case, TerserPlugin removes all the use strict because it is not at the top of the file.

Possible Solution

A possible solution is to do like below:

new BannerPlugin({
  raw: true,
  include: /\.(js|ts|jsx|tsx|mjs|cjs)$/,
  banner: injectionCode,
  footer: true,
})

However, from webpack side, better not to use BannerPlugin to inject code, it's not designed for this. Can refer to webpack/webpack#18202

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions