Skip to content

Should inject banner code after use strictΒ #507

Open
@anothertempore

Description

@anothertempore

Environment

[email protected], @sentry/[email protected]

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions