You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whether to use arrow functions for auto-generated code snippets. Note that in certain places like module wrappers, Rollup will keep using regular functions wrapped in parentheses as in some JavaScript engines, these will provide [noticeably better performance](https://v8.dev/blog/preparser#pife).
This will use `const` instead of `var` in certain places and helper functions. This will allow Rollup to generate more efficient helpers due to block scoping.
Determine whether reserved words like "default" can be used as prop names without using quotes. This will make the syntax of the generated code ES3 compliant. Note however that for full ES3 compliance, you may also need to polyfill some builtin functions like `Object.keys` or `Array.prototype.forEach`.
Whether to allow the use of `Symbol` in auto-generated code snippets. Currently, this only controls if namespaces will have the `Symbol.toStringTag` property set to the correct value of `Module`, which means that for a namespace, `String(namespace)` logs `[object Module]`. This again is used for feature detection in certain libraries and frameworks.
The path that will be prepended to the auto generated ID. This is useful if the build is going to be placed inside another AMD project, and is not at the root.
1465
1483
1466
-
Only valid with `output.amd.autoId`.
1484
+
Only valid with [`output.amd.autoId`](#output-amd-autoid).
Whether to apply tree-shaking and to fine-tune the tree-shaking process. Setting this option to `false` will produce bigger bundles but may improve build performance. You may also choose one of three presets that will automatically be updated if new options are added:
1700
1722
1701
1723
- `"smallest"` will choose option values for you to minimize output size as much as possible. This should work for most code bases as long as you do not rely on certain patterns, which are currently:
1702
-
- getters with side effects will only be retained if the return value is used (`treeshake.propertyReadSideEffects:false`)
1703
-
- code from imported modules will only be retained if at least one exported value is used (`treeshake.moduleSideEffects:false`)
1704
-
- you should not bundle polyfills that rely on detecting broken builtins (`treeshake.tryCatchDeoptimization:false`)
1705
-
- some semantic issues may be swallowed (`treeshake.unknownGlobalSideEffects:false`, `treeshake.correctVarValueBeforeDeclaration:false`)
1724
+
- getters with side effects will only be retained if the return value is used ([`treeshake.propertyReadSideEffects:false`](#treeshake-propertyreadsideeffects))
1725
+
- code from imported modules will only be retained if at least one exported value is used ([`treeshake.moduleSideEffects:false`](#treeshake-modulesideeffects))
1726
+
- you should not bundle polyfills that rely on detecting broken builtins ([`treeshake.tryCatchDeoptimization:false`](#treeshake-trycatchdeoptimization))
1727
+
- some semantic issues may be swallowed ([`treeshake.unknownGlobalSideEffects:false`](#treeshake-unknownglobalsideeffects), [`treeshake.correctVarValueBeforeDeclaration:false`](#treeshake-correctvarvaluebeforedeclaration))
1706
1728
- `"recommended"` should work well for most usage patterns. Some semantic issues may be swallowed, though (`treeshake.unknownGlobalSideEffects:false`, `treeshake.correctVarValueBeforeDeclaration:false`)
1707
1729
- `"safest"` tries to be as spec compliant as possible while still providing some basic tree-shaking capabilities.
1708
1730
- `true` is equivalent to not specifying the option and will always choose the default value (see below).
1709
1731
1710
1732
If you discover a bug caused by the tree-shaking algorithm, please file an issue! Setting this option to an object implies tree-shaking is enabled and grants the following additional options:
If `false`, ignore hints from pure annotations, i.e. comments containing `@__PURE__` or `#__PURE__`, when determining side effects of function calls and constructor invocations. These annotations need to immediately precede the call invocation to take effect. The following code will be completely removed unless this option is set to `false`, in which case it will remain unchanged.
In some edge cases if a variable is accessed before its declaration assignment and is not reassigned, then Rollup may incorrectly assume that variable is constant throughout the program, as in the example below. This is not true if the variable is declared with `var`, however, as those variables can be accessed before their declaration where they will evaluate to `undefined`. Choosing `true` will make sure Rollup does not make any assumptions about the value of variables declared with `var`. Note though that this can have a noticeable negative impact on tree-shaking results.
Allows to manually define a list of function names that should always be considered "pure", i.e. they have no side effects like changing global state etc. when called. The check is performed solely by name.
If `false`, assume modules and external dependencies from which nothing is imported do not have other side effects like mutating global variables or logging without checking. For external dependencies, this will suppress empty imports:
1789
1819
@@ -1867,7 +1897,9 @@ console.log(foo);
1867
1897
1868
1898
Note that despite the name, this option does not "add" side effects to modules that do not have side effects. If it is important that e.g. an empty module is "included" in the bundle because you need this for dependency tracking, the plugin interface allows you to designate modules as being excluded from tree-shaking via the [`resolveId`](../plugin-development/index.md#resolveid), [`load`](../plugin-development/index.md#load) or [`transform`](../plugin-development/index.md#transform) hook.
If `true`, retain unused property reads that Rollup can determine to have side effects. This includes accessing properties of `null` or `undefined` or triggering explicit getters via property access. Note that this does not cover destructuring assignment or getters on objects passed as function parameters.
By default, Rollup assumes that many builtin globals of the runtime behave according to the latest specs when tree-shaking and do not throw unexpected errors. In order to support e.g. feature detection workflows that rely on those errors being thrown, Rollup will by default deactivate tree-shaking inside try-statements. If a function parameter is called from within a try-statement, this parameter will be deoptimized as well. Set `treeshake.tryCatchDeoptimization` to `false` if you do not need this feature and want to have tree-shaking inside try-statements.
Since accessing a non-existing global variable will throw an error, Rollup does by default retain any accesses to non-builtin global variables. Set this option to `false` to avoid this check. This is probably safe for most code-bases.
1943
1981
@@ -1955,7 +1993,7 @@ const element = angular.element;
1955
1993
constelement=angular.element;
1956
1994
```
1957
1995
1958
-
In the example, the last line is always retained as accessing the `element` property could also throw an error if `angular` is e.g. `null`. To avoid this check, set `treeshake.propertyReadSideEffects` to `false` as well.
1996
+
In the example, the last line is always retained as accessing the `element` property could also throw an error if `angular` is e.g. `null`. To avoid this check, set [`treeshake.propertyReadSideEffects`](#treeshake-propertyreadsideeffects) to `false` as well.
1959
1997
1960
1998
## Experimental options
1961
1999
@@ -2101,13 +2139,13 @@ This will rename the dynamic import function to the chosen name when outputting
0 commit comments