New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack BannerPlugin with raw
option should put use strict
on the very first line
#18202
Comments
You don't need "use strict" when your output is ESM... |
@alexander-akait Sorry I just updated to Non-ESM code, seems like get the same behaviour. Could you please check it again, Thanks! https://github.com/anothertempore/webpack-banner-use-strict/tree/main |
hey I cloned the code and tried out the steps and I see that "use strict" is infact on the 2 nd line , could you please elaborate more as to what is the main bug. Thank you . I am a student wanting to help contribute as part of the google summer of code |
I want to say it is not a bug, because BannerPlugin is not for including acustom code, but yes, you can use this for it and in some cases it will work, #13842 is not related to your problem, we don't remove/generate
for code |
@alexander-akait Thanks for your suggestion. I want to double check if I understand this correctly. I tried webpack
The However the webpack after
The No need to modify any source code can notice the difference, so I am wondering which part is related to the source code? |
@anothertempore This change was due another things, but yes, it affected your code, but |
hey @anothertempore there is an issue while cloning this repository can you help me with this: |
that is a network issue consider downloading it as a zip file |
Anyway, maybe we can implement |
On Wed, 27 Mar 2024 at 10:23 PM, Alexander Akait ***@***.***> wrote:
Anyway, maybe we can implement options.afterDirectives, but it will cost
perfomance because we will need recalculate source maps
—
Reply to this email directly, view it on GitHub
<#18202 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BBXMGA2SRJ7WTFYYH2WPMRLY2L2PZAVCNFSM6AAAAABEYBSPTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRTGMYDCOJSHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
Thank you for considering my issue.
|
Bug report
What is the current behavior?
raw
option, it appends the code before"use strict"
, this will cause strict mode to not function properly.minimize
to true,TerserPlugin
will remove"use strict"
in between.Context: Before #13842, webpack add
"use strict"
inside each function, so we don't have this issue. But after this, webpack seems like shift all"use strict"
to the top, that's the root cause of this issue.If the current behavior is a bug, please provide the steps to reproduce.
Repo to reproduce the bug: https://github.com/anothertempore/webpack-banner-use-strict
Steps:
pnpm install
pnpm build
, then checkdist/async
file,"use strict"
is not in the very first line, which is incorrect.dist/async
,"use strict"
will be removed.What is the expected behavior?
"use strict"
statement should always in the very first line.Other relevant information:
webpack version: 5.90.3
Node.js version: 18
Operating System: MacOS
Additional tools:
The text was updated successfully, but these errors were encountered: