Skip to content

[Question/Feature Request/Bug] Is Terser /*@__INLINE__*/ annotation supported by Webpack ? #19470

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

Closed
denis-migdal opened this issue Apr 26, 2025 · 3 comments

Comments

@denis-migdal
Copy link

Hi,

IIRC, Webpack uses Terser to minify/uglify scripts.

Then annotations like /*@__INLINE__*/ should be supported ?

However, this doesn't seem to be the case :

/*@__INLINE__*/
export function foo() {
    console.warn("foo");
}

foo();
foo();
foo();
foo();

Gives the following code:

function R(){console.warn("foo")}
// ....
R(),R(),R(),R();

This issue is at the same time :

  • a question : is this feature officially supported by Webpack ?
  • a feature request : if not, asking for a way to have macro/inline functions.
  • a bug report : if so, well it seems there is an issue somewhere.
@alexander-akait
Copy link
Member

/*@__INLINE__*/ should be used in expressions, not on declaration, i.e.

export function foo() {
	console.warn("foo");
}

/*@__INLINE__*/
foo();
/*@__INLINE__*/
foo();
/*@__INLINE__*/
foo();
/*@__INLINE__*/
foo();

If you want to improve this, open an issue in terser, as this is outside of webpack, other minimizers use the same logic.

Feel free to feedback

@denis-migdal
Copy link
Author

Thanks for your answer.

/@INLINE/ should be used in expressions, not on declaration, i.e.

Ouch, I'm really blind. Didn't even noticed it after reading Terser documentation several times. I'm sorry for that, shame on me.

I assume I could use the DefinePluging to define CALL_FOO_INLINE( as being /* ... */ foo(. Enabling me to globally enable/disable the inlining when I think this is necessary.

I will come back later about bundles with performances constraints (other things to work on before).

@alexander-akait
Copy link
Member

@denis-migdal You can do it using DefinePluging, we inject a raw code, that is why we ask to use JSON.stringify for real JS values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants