-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support #__NO_SIDE_EFFECTS__
comment from Rollup
#3149
Comments
Currently, when using It would be great to esbuild been able to preserve it, or even provide tree-shaking capability with that convention. |
#__NO_SIDE_EFFECTS__
from Rollup#__NO_SIDE_EFFECTS__
comment from Rollup
Why is it |
@paulmillr I believe both |
I can look into preserving comments containing |
I looked into this. A few questions:
Edit: I'm going with copying Rollup's current observable behavior (at least as far as I can tell). So to be clear, the annotation can now be used in all of these positions: /* @__NO_SIDE_EFFECTS__ */ function f() {}
/* @__NO_SIDE_EFFECTS__ */ function* f() {}
/* @__NO_SIDE_EFFECTS__ */ export function f() {}
/* @__NO_SIDE_EFFECTS__ */ export function* f() {}
/* @__NO_SIDE_EFFECTS__ */ export default function f() {}
/* @__NO_SIDE_EFFECTS__ */ export default function* f() {}
export default /* @__NO_SIDE_EFFECTS__ */ function f() {}
export default /* @__NO_SIDE_EFFECTS__ */ function* f() {}
const f = /* @__NO_SIDE_EFFECTS__ */ function() {}
const f = /* @__NO_SIDE_EFFECTS__ */ function*() {}
export const f = /* @__NO_SIDE_EFFECTS__ */ function() {}
export const f = /* @__NO_SIDE_EFFECTS__ */ function*() {}
/* @__NO_SIDE_EFFECTS__ */ const f = function() {}
/* @__NO_SIDE_EFFECTS__ */ const f = function*() {}
/* @__NO_SIDE_EFFECTS__ */ export const f = function() {}
/* @__NO_SIDE_EFFECTS__ */ export const f = function*() {}
const f = /* @__NO_SIDE_EFFECTS__ */ () => {}
export const f = /* @__NO_SIDE_EFFECTS__ */ () => {}
/* @__NO_SIDE_EFFECTS__ */ const f = () => {}
/* @__NO_SIDE_EFFECTS__ */ export const f = () => {}
class Foo { static f = /* @__NO_SIDE_EFFECTS__ */ function() {} }
class Foo { static f = /* @__NO_SIDE_EFFECTS__ */ function*() {} }
class Foo { static f = /* @__NO_SIDE_EFFECTS__ */ () => {} }
x = { f: /* @__NO_SIDE_EFFECTS__ */ function() {} }
x = { f: /* @__NO_SIDE_EFFECTS__ */ function*() {} }
x = { f: /* @__NO_SIDE_EFFECTS__ */ () => {} } And the annotation cannot be used in any of these positions (not an exhaustive list, but perhaps still worth listing for clarity): /* @__NO_SIDE_EFFECTS__ */ async function f() {}
/* @__NO_SIDE_EFFECTS__ */ async function* f() {}
/* @__NO_SIDE_EFFECTS__ */ export async function f() {}
/* @__NO_SIDE_EFFECTS__ */ export async function* f() {}
/* @__NO_SIDE_EFFECTS__ */ export default async function f() {}
/* @__NO_SIDE_EFFECTS__ */ export default async function* f() {}
export default /* @__NO_SIDE_EFFECTS__ */ async function f() {}
export default /* @__NO_SIDE_EFFECTS__ */ async function* f() {}
const f = /* @__NO_SIDE_EFFECTS__ */ async function() {}
const f = /* @__NO_SIDE_EFFECTS__ */ async function*() {}
export const f = /* @__NO_SIDE_EFFECTS__ */ async function() {}
export const f = /* @__NO_SIDE_EFFECTS__ */ async function*() {}
/* @__NO_SIDE_EFFECTS__ */ const f = async function() {}
/* @__NO_SIDE_EFFECTS__ */ const f = async function*() {}
/* @__NO_SIDE_EFFECTS__ */ export const f = async function() {}
/* @__NO_SIDE_EFFECTS__ */ export const f = async function*() {}
const f = /* @__NO_SIDE_EFFECTS__ */ async () => {}
export const f = /* @__NO_SIDE_EFFECTS__ */ async () => {}
/* @__NO_SIDE_EFFECTS__ */ const f = async () => {}
/* @__NO_SIDE_EFFECTS__ */ export const f = async () => {}
class Foo { /* @__NO_SIDE_EFFECTS__ */ static f = function() {} }
class Foo { /* @__NO_SIDE_EFFECTS__ */ static f = function*() {} }
class Foo { /* @__NO_SIDE_EFFECTS__ */ static f = () => {} }
class Foo { /* @__NO_SIDE_EFFECTS__ */ static f() {} }
class Foo { /* @__NO_SIDE_EFFECTS__ */ static *f() {} }
class Foo { /* @__NO_SIDE_EFFECTS__ */ static get f() {} }
x = { /* @__NO_SIDE_EFFECTS__ */ f: function() {} }
x = { /* @__NO_SIDE_EFFECTS__ */ f: function*() {} }
x = { /* @__NO_SIDE_EFFECTS__ */ f: () => {} }
x = { /* @__NO_SIDE_EFFECTS__ */ f() {} }
x = { /* @__NO_SIDE_EFFECTS__ */ *f() {} }
x = { /* @__NO_SIDE_EFFECTS__ */ get f() {} } |
Thanks a lot for the prompt support! We were discussing with @lukastaegert that we should have a repo hosting the spec for As for the async function and generator, that's a good point and actually was my mistake to miss them. I will send a PR to fix it on Rollup soon. I guess that makes sense for esbuild to still present the comments for them as well. |
With a similar reasoning:
We recently shipped
#__NO_SIDE_EFFECTS__
in Rollup (rollup/rollup#5024). We wish to push this convention to be supported in other build tools and to benefit library authors to make more portable and flexible libraries.Would love the hear the thoughts from
esbuild
side. Thanks!The text was updated successfully, but these errors were encountered: